A multi-agent platform based on large language models, providing developer-friendly message exchange mechanisms and distributed deployment capabilities.
AgentScope - A Flexible and Powerful Multi-Agent Development Platform
Project Overview
AgentScope is an innovative multi-agent platform specifically designed for developers to build multi-agent applications based on Large Language Models (LLMs). The platform uses message exchange as its core communication mechanism, significantly lowering the barrier to development and understanding.
GitHub Address: https://github.com/agentscope-ai/agentscope
Core Features
1. Developer-Friendly Design Principles
- Transparency First: Fully transparent to developers, including prompt engineering, API calls, agent construction, and workflow orchestration, all of which are visible and controllable.
- Real-time Control: Agents can be interrupted at any time, and their handling can be customized.
- Model Agnosticism: Code once, work with all models.
- LEGO-style Agent Construction: All components are modular and independent.
2. Multi-Agent Oriented Design
- Explicit Message Passing: Designed specifically for multi-agent systems, supporting explicit message passing and workflow orchestration.
- No Deep Encapsulation: Avoids complex encapsulation, maintaining code readability and maintainability.
- Highly Customizable: Tools, prompts, agents, workflows, third-party libraries, and visualizations all support customization.
3. Robust Fault Tolerance Mechanism
AgentScope provides built-in and customizable fault tolerance mechanisms, along with system-level support for managing and utilizing multimodal data, tools, and external knowledge. This includes:
- Service-level retry mechanisms to ensure API reliability.
- Rule-based correction tools to handle format issues in LLM responses.
- Customizable fault tolerance configurations (parse_func, fault_handler, max_retries, etc.).
- A dedicated logging system for multi-agent applications.
4. Distributed Architecture Support
- Actor-based Distributed Framework: Supports easy transition between local and distributed deployments.
- Automatic Parallel Optimization: Achieves parallel optimization without extra effort.
- Large-scale Simulation Support: Capable of simulating 1 million agents on 4 devices.
AgentScope 1.0 New Features
Asynchronous Execution Support
- Fully embraces asynchronous execution patterns.
- Provides various new features and improvements.
Core Module Functionality
Module | Function | Description |
---|---|---|
Model | Asynchronous Call Support | Supports asynchronous calls for various LLMs |
Tool | Tool Integration | A rich library of tool functions |
MCP | Model Control Protocol | Supports Model Control Protocol integration |
Tracing | Tracing and Monitoring | Application execution tracing and visualization |
Memory | Long-term Memory | Agent long-term memory management |
Session | Session Management | State and session management |
Evaluation | Evaluation System | Agent performance evaluation |
Prompt Formatter | Prompt Formatting | Smart prompt formatting tools |
Technical Architecture
Message Exchange Mechanism
AgentScope adopts a message-based communication mechanism:
from agentscope.message import Msg
message_from_alice = Msg("Alice", "Hi!")
message_with_media = Msg("Bob", "What about this picture?", url="/path/to/picture.jpg")
Agent Creation
from agentscope.agent import ReActAgent, UserAgent
from agentscope.model import DashScopeChatModel
from agentscope.formatter import DashScopeChatFormatter
from agentscope.memory import InMemoryMemory
from agentscope.tool import Toolkit, execute_python_code
import os, asyncio
async def main():
toolkit = Toolkit()
toolkit.register_tool_function(execute_python_code)
agent = ReActAgent(
name="Friday",
sys_prompt="You're a helpful assistant named Friday.",
model=DashScopeChatModel(
model_name="qwen-max",
api_key=os.environ["DASHSCOPE_API_KEY"],
stream=True,
),
memory=InMemoryMemory(),
formatter=DashScopeChatFormatter(),
toolkit=toolkit,
)
user = UserAgent(name="user")
msg = None
while True:
msg = await agent(msg)
msg = await user(msg)
if msg.get_text_content() == "exit":
break
asyncio.run(main())
Pipelines and Workflows
from agentscope.pipeline import MsgHub, sequential_pipeline
from agentscope.message import Msg
async def multi_agent_conversation():
agent1 = ...
agent2 = ...
agent3 = ...
pipeline = sequential_pipeline([agent1, agent2, agent3])
result = await pipeline(initial_message)
MCP (Model Control Protocol) Integration
from agentscope.mcp import HttpStatelessClient
from agentscope.tool import Toolkit
import os
async def fine_grained_mcp_control():
client = HttpStatelessClient(
name="gaode_mcp",
transport="streamable_http",
url=f"https://mcp.amap.com/mcp?key={os.environ['GAODE_API_KEY']}",
)
func = await client.get_callable_function(func_name="maps_geo")
await func(address="Tiananmen Square", city="Beijing")
toolkit = Toolkit()
toolkit.register_tool_function(func)
Multimodal Data Support
AgentScope employs a lazy loading strategy, decoupling multimodal data transmission from storage by providing unified URL-based attributes within messages. It supports:
- Text, image, audio, and video data processing.
- URL-based data referencing.
- On-demand loading mechanism.
Tool and Service Ecosystem
Built-in Service Capabilities
- Python code execution
- Web search
- File operations
- External knowledge integration
RAG (Retrieval Augmented Generation) Support
- End-to-end knowledge processing module.
- Highly configurable retrieval system.
- Shareable knowledge processing components.
Installation and Usage
System Requirements
- Python 3.10 or higher
Installation Methods
Install from Source (Recommended)
git clone -b main https://github.com/agentscope-ai/agentscope.git
cd agentscope
pip install -e .
Install from PyPI
pip install agentscope
AgentScope Studio
npm install -g @agentscope/studio
as_studio
Model Support
AgentScope supports a wide range of Large Language Models:
Cloud APIs
- OpenAI GPT series
- DashScope (Alibaba Cloud)
- Google Gemini
- ZhipuAI
- LiteLLM API
Local Deployment
- Ollama
- Flask + Transformers/ModelScope
- FastChat
- vLLM
Application Scenarios
Large-scale Simulation
- Financial market simulation
- Urban planning modeling
- Policy impact analysis
- Social behavior research
Collaborative Tasks
- Software development team simulation
- Multi-turn dialogue systems
- Complex problem solving
- Knowledge collaboration and processing
Enterprise Applications
- Customer service automation
- Business process optimization
- Intelligent decision support
- Risk management modeling
Community and Support
- Official Documentation: https://doc.agentscope.io/
- GitHub Repository: https://github.com/agentscope-ai/agentscope
- PyPI Package: https://pypi.org/project/agentscope/
- Tutorials and Examples: Comprehensive tutorial documentation and rich example code.
AgentScope represents a significant advancement in multi-agent system development, providing researchers and developers with a powerful, flexible, and easy-to-use platform to fully unleash the potential of agents.