用 feat 完整版替换 dev 旧版:references 补 studio-rest-api + v2-overview/v2-building-blocks/v2-deploy(docs.agentscope.io 2026-06-22 快照),SKILL.md 补索引。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
15 KiB
What's AgentScope 2.0?
More secure, more efficient, more flexible, and more complete agent development.
AgentScope 2.0 is a major update to our agent framework, with a focus on improving the developer experience and making it easier to build and run agents in production.
AgentScope 2.0 is a breaking change from 1.0, with significant improvements in the core abstractions, APIs and architecture. We recommend users to migrate to 2.0 to take advantage of the new features and improvements.2.0 brings the following major changes and improvements:
- Event System: Every step the agent takes — text, thinking, tool call, tool result — is observable as a typed stream, so you can render rich, responsive UIs and integrate with AG-UI or A2A without writing adapters.
- Execution Security: Dangerous tool calls can be denied or held for review, and untrusted code can run inside a sandbox — the agent never silently touches the host or leaks credentials.
- Human-in-the-loop: Users can confirm or edit tool arguments mid-run, and sensitive actions can be handed off to your own backend instead of executed in-process, with the agent resuming exactly where it paused.
- More Efficient: Multi-tool steps finish faster through concurrent execution, long conversations stay within the context window automatically, oversized tool outputs no longer blow up the prompt, and transient provider failures fall back gracefully.
- Workspace System: Move an agent from your laptop to a Docker host or an E2B sandbox by changing one line, with working directory, MCP clients and skills cleanly isolated per user, agent or session.
- Agent Service: Host any agent over REST + SSE with multi-tenant, multi-session concurrency, resumable streams, durable sessions, scheduled runs and managed credentials — without writing the service plumbing yourself.
If you are still evaluating whether to migrate, check out the Changelog for a full breakdown of every change — it should give you everything you need to plan your migration to AgentScope 2.0.
Observe every step of the agent and stream it straight into your UI. Gate or sandbox dangerous tool calls before they touch the host. Let users review and edit tool arguments before execution, or delegate sensitive actions to your own backend entirely. Tool calls are auto-batched and run concurrently or sequentially based on each tool's properties. Swap Local, Docker or E2B without rewriting the agent. Ship agents over REST + SSE with multi-tenant, multi-session concurrency, sessions, schedules and credentials.Quickstart
Get up and running with AgentScope 2.0 in minutes
Installation
AgentScope requires Python 3.11+, and you can install it from PyPI or from source.
It's recommended to install AgentScope by using uv.
From PyPI
uv pip install agentscope
From Source
git clone -b main https://github.com/agentscope-ai/agentscope
cd agentscope
uv pip install -e .
Verify Installation
To ensure AgentScope is installed successfully, check via executing the following code:
import agentscope
print(agentscope.__version__)
Your First Agent
The snippet below builds the minimal agent: a DashScope credential, the matching chat model, an empty toolkit, and an Agent. The agent exposes two entry points — reply returns the final message, while reply_stream yields incremental events as the agent reasons and acts.
import asyncio
import os
from agentscope.agent import Agent
from agentscope.credential import DashScopeCredential
from agentscope.event import EventType
from agentscope.message import UserMsg
from agentscope.model import DashScopeChatModel
from agentscope.tool import Toolkit, Bash, Read, Write, Edit
async def main() -> None:
agent = Agent(
name="Friday",
system_prompt="You are a helpful assistant named Friday.",
model=DashScopeChatModel(
credential=DashScopeCredential(
api_key=os.getenv("DASHSCOPE_API_KEY"),
),
model="qwen-plus",
),
toolkit=Toolkit(tools=[Bash(), Read(), Write(), Edit()]),
)
user_msg = UserMsg(name="user", content="Hello, who are you?")
# Option 1: await the final assistant message.
reply_msg = await agent.reply(user_msg)
# `reply_msg` is an `AssistantMsg` whose `content` is a list of blocks.
# Inspect text blocks, tool calls, etc. as needed.
...
# Option 2: stream incremental events (text deltas, tool calls, ...).
async for event in agent.reply_stream(user_msg):
# Dispatch on `event.type` — each branch handles one event kind.
match event.type:
case EventType.TEXT_BLOCK_DELTA:
# Streaming text chunk from the model — append to UI / stdout.
...
case EventType.TOOL_CALL_START:
# The agent is about to invoke a tool — surface the call.
...
case _:
# Other events: thinking blocks, tool results, reply end, ...
...
asyncio.run(main())
Set `DASHSCOPE_API_KEY` in your environment before running the script. To use a different provider, swap `DashScopeCredential` and `DashScopeChatModel` for the matching pair (e.g. `OpenAICredential` and `OpenAIChatModel`).
Extra Dependencies
To satisfy the requirements of different functionalities, AgentScope provides extra dependencies that can be installed based on your needs.
- full: including extra dependencies for model APIs, tool functions and more.
- dev: development dependencies, including testing and documentation tools.
For example, when installing the full dependencies, the installation command varies depending on your operating system.
- For Windows users:
uv pip install agentscope[full]
- For Mac and Linux users:
uv pip install agentscope\[full\]
Changelog
Core differences between AgentScope 2.0 and 1.0
AgentScope 2.0 is a breaking release. The notes below summarize the differences against 1.0, grouped by module.
Agent
- Refactor
ReActAgentinto a new unifiedAgentclass implementation. - Replace the
__call__method in 1.0 with thereply_streamandreplypublic methods. - Support yielding agent events from
reply_streamfor richer observability and control. - Support permission checks and human-in-the-loop confirmations through the event stream.
- Support offloading the compressed context and oversized tool results via a new
Offloaderinterface. - Deprecate the hook mechanism and replace it with a new agent middleware system.
- Deprecate the
state_dictandload_state_dictmethods, moving towards explicit state management through the newAgentStatetype. - Deprecate the
printinterface of the agent class, turning the agent into a pure producer. - Deprecate the OpenTelemetry integration within the agent class and leave it to a new middleware implementation.
Event New
- Add event system for better frontend integration and human-in-the-loop support.
Message
Content blocks refactor:
- Refactor all content blocks by inheriting from the Pydantic
BaseModelfor better validation, serialization, and extensibility. - Refactor
ImageBlock,AudioBlock,VideoBlockinto a unifiedDataBlockwith amedia_typefield for extensibility. - Add
HintBlockfor agent guidance and intermediate reasoning. - Rename
ToolUseBlocktoToolCallBlock. - Add
stateandsuggested_rulesfields toToolCallBlockfor richer tool-call lifecycle modeling. - Add
statefield toToolResultBlockfor richer tool-call lifecycle modeling. - Add
idfield for all blocks for better traceability and referencing.
Msg class refactor:
- Refactor
Msgto inherit fromBaseModeland enforce content validation. - Add
created_at,finished_at, andusagefields to theMsgclass for better observability and accounting. - Add
append_eventmethod toMsgfor yielding events from the agent's reply stream. - Add factory methods
UserMsg,AssistantMsg, andSystemMsgto create messages with the appropriate role. - Add
contentfield constraints with the specifiedroletypes.
Permission New
- Add a new permission system for gating tool execution, human-in-the-loop confirmation, and overall agent autonomy control.
Tool
- Add
ToolBaseabstraction for all tools. - Refactor built-in tools:
- Add
Bash,Edit,Glob,Grep,Read, andWritewith permission control. - Add
TaskCreate,TaskGet,TaskList, andTaskUpdatefor task management.
- Add
Toolkit refactor:
- Support tools, skills, MCPs, and tool groups as first-class citizens in the
Toolkitabstraction. - Add
ToolGroupfor on-demand activation, with the reservedbasicgroup always active. - Add the
ResetToolsmeta-tool for the agent to switch tool groups at runtime. - Add
MCPToolandFunctionTooladapters for uniform tool registration.
MCP
- Refactor MCP implementation into a single
MCPClientclass for a unified client surface. - Add
StdioMCPConfigandHttpMCPConfigdeclarative configuration types for typed MCP setup.
Skill New
- Add skill loader abstraction to support in-time skill loading from the filesystem/sandbox/web.
- Add
LocalSkillLoaderclass to support directory-based skill loading and monitoring. - Support packaging skills into
ToolGroups for on-demand activation and better organization.
Workspace New
- Add the workspace abstraction supplying tools, MCPs, skills, and context offloading through one unified interface.
- Add
LocalWorkspace,DockerWorkspace, andE2BWorkspaceimplementations sharing the same agent-facing API for swappable execution backends. - Add the
Offloaderprotocol consumed byAgentfor context compression and oversized tool-result handling. - Add
LocalWorkspaceManager,DockerWorkspaceManager, andE2BWorkspaceManagerwith agent-level isolation for multi-tenant services. - Add an in-workspace MCP gateway so host-side agents can reach MCP servers running inside containers and sandboxes.
Model
- Decouple credential management from the model classes and centralize it in a new
Credentialmodule. - Support credential-aware model listing and retrieval.
- Support Kimi, Moonshot, DeepSeek, XAI, and OpenAI Response API.
- Integrate formatter into the chat model abstraction and support default formatters for different model providers.
- Add the
ModelCardschema describing model identity, capabilities, and parameter overrides. - Add class method
list_modelsfor frontend model listing and selection. - Deprecate the
Trinitymodel wrapper.
Middleware New
- Refactor the hook mechanism into a more general agent middleware system.
- Add
TracingMiddlewareas the new entry point for OpenTelemetry tracing, replacing the in-agent integration.
Agent Service New
- Add a new FastAPI-based agent service and sandbox support in the
appmodule. - Add the
create_appFastAPI factory exposing agent, chat, model, credential, session, schedule, workspace, and background-task routers. - Add lifespan-scoped
SessionManager,SchedulerManager,BackgroundTaskManager, and workspace managers for multi-tenant resource allocation. - Add
AGUIProtocolMiddlewarefor streaming andToolOffloadMiddlewarefor oversized payloads. - Add Redis-backed storage.
Memory
- Deprecate the memory module in 2.0 due to its tight coupling with agent logic.
RAG & Long-Term Memory
- Unify RAG and long-term memory into one module.
- Migration from 1.0 to 2.0 is in progress; the module — knowledge bases, document readers, and stores — will return on top of the 2.0 architecture in upcoming releases.
FAQ
No. AgentScope 2.0 is a breaking release that introduces a redesigned agent abstraction, a new event system, the workspace and permission systems, and many other new features. APIs are not source-compatible with 1.0, and there is no automatic migration path.Frequently asked questions about AgentScope v2.0
We recommend upgrading to 2.0 for all new projects to benefit from the new capabilities. The 1.0 documentation remains available for existing users.
Yes. The **workspace** abstraction is AgentScope's execution environment for agents and ships three implementations — `LocalWorkspace` (host filesystem), `DockerWorkspace` (container), and `E2BWorkspace` (E2B cloud sandbox) — sharing the same interface so the same agent code runs against any backend. Workspaces also own MCP server lifecycles, skill management, and context offloading.
See [Workspace](/v2/building-blocks/workspace) for the full overview, including how to plug a workspace into an `Agent` and the multi-tenant `WorkspaceManager`.
Yes, on two layers:
* **TypeScript SDK** — install with `pnpm install @agentscope-ai/agentscope`. It mirrors the Python `Msg` and `Event` types so frontend code can consume agent streams without re-implementing the protocol.
* **Frontend UI** — a ready-to-use web app for [Agent Service](/v2/deploy/agent-service), letting developers exercise their deployed agents without writing any UI code.
Yes. Both modules are being ported from 1.0 to the 2.0 architecture and will land in upcoming releases. Track the changelog and GitHub releases for availability.
Yes. AgentScope is available in three languages, each with its own repository:
* **Python** — [`agentscope-ai/agentscope`](https://github.com/agentscope-ai/agentscope) (this documentation)
* **TypeScript** — [`agentscope-ai/agentscope-typescript`](https://github.com/agentscope-ai/agentscope-typescript)
* **Java** — [`agentscope-ai/agentscope-java`](https://github.com/agentscope-ai/agentscope-java)