Why AgentScope
AgentScope is an open-source Python framework for building LLM agents that reason, call tools, remember context, and work together. It favours transparency over magic: every prompt, message, and tool call is something you can see and change.
The project comes from Alibaba's Tongyi Lab. Its 1.0 release, described in an August 2025 arXiv paper, rebuilt the framework around asynchronous execution and tool-based interaction between agents and their environment. A Java edition now exists as well, but this article sticks to Python.
If you have used LangChain or AutoGen, the ideas will feel familiar. What sets AgentScope apart is how few layers sit between you and the model. This article walks through the core pieces, a first working agent, tools, and simple multi-agent setups.
Your first agent
AgentScope needs Python 3.10 or newer. Install it from PyPI with pip install agentscope, or pip install "agentscope[full]" for the optional extras.
The script below builds a ReAct agent on an OpenAI model, gives it one tool, and opens a chat loop in the terminal. Type exit to stop.
import asyncio import os from agentscope.agent import ReActAgent, UserAgent from agentscope.formatter import OpenAIChatFormatter from agentscope.memory import InMemoryMemory from agentscope.model import OpenAIChatModel from agentscope.tool import Toolkit, execute_python_code async def main() -> None: toolkit = Toolkit() toolkit.register_tool_function(execute_python_code) agent = ReActAgent( name="Ada", sys_prompt="You are Ada, a concise data assistant.", model=OpenAIChatModel( model_name="gpt-4o-mini", api_key=os.environ["OPENAI_API_KEY"], stream=True, ), formatter=OpenAIChatFormatter(), memory=InMemoryMemory(), toolkit=toolkit, ) user = UserAgent(name="User") msg = None while True: msg = await user(msg) if msg.get_text_content() == "exit": break msg = await agent(msg) asyncio.run(main()) Ask Ada for the mean of five numbers and watch the loop work. The agent reasons about the request, decides to call execute_python_code, reads the result, and replies. Each step prints to the console, so you see exactly what went to the model and what came back.
To use another provider, change only the model and formatter. DashScopeChatModel with DashScopeChatFormatter is the pairing used in the official quickstart; Ollama has its own pair for local models.
Adding your own tools
A tool is a plain Python function with type hints and a docstring. The toolkit reads both to build the JSON schema the model sees, so a clear docstring is effectively part of your prompt. The function returns a ToolResponse holding content blocks.
from agentscope.message import TextBlock from agentscope.tool import ToolResponse def get_fx_rate(base: str, quote: str) -> ToolResponse: """Return the latest exchange rate between two currencies. Args: base (str): ISO code of the base currency, e.g. "CAD". quote (str): ISO code of the quote currency, e.g. "INR". """ rate = lookup_rate(base, quote) # your own data source return ToolResponse( content=[TextBlock(type="text", text=f"1 {base} = {rate} {quote}")] ) toolkit.register_tool_function(get_fx_rate) Tools can be sync or async, can stream partial results, and can run in parallel when the model requests several at once. The toolkit also groups tools, so an agent can switch whole sets on or off as a task changes.
For tools that live outside your codebase, AgentScope speaks the Model Context Protocol. Create an MCP client, such as HttpStatelessClient for a streamable-HTTP server, and register it on the toolkit. Its tools then appear to the agent alongside your local functions.
Making agents work together
Multi-agent work in AgentScope rests on two ideas: pipelines that set the order of turns, and a message hub that decides who hears what.
A pipeline is the simplest pattern. sequential_pipeline passes a message through agents one after another, each output becoming the next input. fanout_pipeline sends the same message to several agents and collects their replies.
from agentscope.pipeline import MsgHub, sequential_pipeline # Draft, review, and edit in a fixed order final = await sequential_pipeline([writer, reviewer, editor], msg=task) # A shared room: every reply is broadcast to all participants async with MsgHub(participants=[alice, bob, carol], announcement=intro): await sequential_pipeline([alice, bob, carol]) Inside a MsgHub, each agent's reply is automatically added to the others' memory. That gives you group discussions, debates, and voting without wiring the messages by hand. You can add or remove participants while the hub is open.
Because the agent is just an object you call, ordinary Python control flow handles the rest. A loop, an if, or asyncio.gather is often all the orchestration you need.
Tips before you build further
• One agent instance per conversation. Agents and toolkits hold state, so do not share one instance across concurrent users. Create a fresh agent per session.
• Treat docstrings as prompts. Vague tool descriptions are the most common reason an agent picks the wrong tool or passes bad arguments.
• Use hooks instead of subclassing. ReActAgent exposes hooks around its reasoning and acting steps, which suit logging, guardrails, and metrics.
• Ask for structured output when a downstream system needs fields rather than prose. Pass a Pydantic model and the agent returns validated data.
• Watch it run. AgentScope Studio gives a visual trace of messages and tool calls, which beats reading console logs once several agents are involved.
Wrapping up
AgentScope's basics fit in an afternoon: messages carry content, a model and formatter talk to the provider, memory holds context, a toolkit exposes functions, and an agent runs the loop. Pipelines and MsgHub scale that to teams of agents.
Start with the single ReAct agent above, add one real tool from your own work, then try a two-agent review pipeline. That sequence covers most of what production agentic applications need.
![AMR Mechanical and Electrical Engineering — Ch.12: Contents {#contents .TOC-Heading} [KR]](https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwzu7uvk9b9zcljsl3gz5.png)
![AMR Mechanical and Electrical Engineering — Ch.14: Contents {#contents .TOC-Heading} [KR]](https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6nel7ut2runbhcvsezvf.png)
