agentscope-skill
AgentScopeフレームワークの設計思想や基本概念、具体的な使い方に関する質問に答えたり、AgentScopeを使ったエージェントアプリケーションの構築を支援したり、サンプルや関数などの情報を検索したりできるSkill。
📜 元の英語説明(参考)
This guide covers the design philosophy, core concepts, and practical usage of the AgentScope framework. Use this skill whenever the user wants to do anything with the AgentScope (Python) library. This includes building agent applications using AgentScope, answering questions about AgentScope, looking for guidance on how to use AgentScope, searching for examples or specific information (functions/classes/modules).
🇯🇵 日本人クリエイター向け解説
AgentScopeフレームワークの設計思想や基本概念、具体的な使い方に関する質問に答えたり、AgentScopeを使ったエージェントアプリケーションの構築を支援したり、サンプルや関数などの情報を検索したりできるSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o agentscope-skill.zip https://jpskill.com/download/10336.zip && unzip -o agentscope-skill.zip && rm agentscope-skill.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/10336.zip -OutFile "$d\agentscope-skill.zip"; Expand-Archive "$d\agentscope-skill.zip" -DestinationPath $d -Force; ri "$d\agentscope-skill.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
agentscope-skill.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
agentscope-skillフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
AgentScope の理解
AgentScope とは?
AgentScope は、大規模言語モデルを用いたマルチエージェントアプリケーションを構築するための、本番環境に対応したエンタープライズグレードのオープンソースフレームワークです。その機能は以下をカバーします。
- 開発: ReAct エージェント、コンテキスト圧縮、短期/長期記憶、ツール利用、ヒューマンインザループ、マルチエージェントオーケストレーション、エージェントフック、構造化出力、プランニング、MCP との統合、エージェントスキル、LLM API、音声インタラクション (TTS/リアルタイム)、RAG
- 評価: 統計分析による多段階エージェントアプリケーションの評価
- トレーニング: エージェント強化学習
- デプロイメント: セッション/状態管理、サンドボックス、ローカル/サーバーレス/Kubernetes デプロイメント
インストール
pip install agentscope
# or
uv pip install agentscope
主要な概念
- Message: エージェント間の情報交換のためのコアな抽象概念。異種コンテンツブロック (テキスト、画像、ツール呼び出し、ツール結果) をサポートします。
from agentscope.message import Msg, TextBlock, ImageBlock, URLSource
msg = Msg( name="user", content=[TextBlock("Hello world"), ImageBlock(type="image", source=URLSource(type="url", url="..."))], role="user" )
- **Agent**: 推論、ツール利用、反復的な思考と行動ループによる応答生成が可能な、LLM によって強化されたエージェント。
- **Toolkit**: エージェントが呼び出すことができるツール (Python 関数、MCP、エージェントスキル) を登録および管理します。
- **Memory**: 会話履歴/コンテキストとして `Msg` オブジェクトを保存し、高度なメモリ管理 (圧縮、検索) のためのマーキングメカニズムを備えています。
- **ChatModel**: ツール利用とストリーミングをサポートし、さまざまなプロバイダー (OpenAI、Anthropic、DashScope、Ollama など) にわたる統一されたインターフェース。
- **Formatter**: `Msg` オブジェクトを LLM API 固有の形式に変換します。対応する ChatModel と共に使用する必要があります。異なるエージェント識別子を持つマルチエージェント会話をサポートします。
### 基本的な使用例
#### 例 1: シンプルなチャットボット
```python
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, execute_shell_command
import os, asyncio
async def main():
# ツールで Toolkit を初期化
toolkit = Toolkit()
toolkit.register_tool_function(execute_python_code)
toolkit.register_tool_function(execute_shell_command)
# モデル、メモリ、formatter、および toolkit を使用して ReActAgent を作成
agent = ReActAgent(
name="Friday",
sys_prompt="You're a helpful assistant named Friday.",
model=DashScopeChatModel(
model_name="qwen-max",
api_key=os.getenv("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())
例 2: マルチエージェント会話
AgentScope は、マルチエージェント会話のために明示的なメッセージパッシング (PyTorch のような動的グラフ) を採用し、柔軟な情報フロー制御を可能にします。
alice, bob, carol, david = ReActAgent(...), ReActAgent(...), ReActAgent(...), ReActAgent(...)
msg_alice = await alice()
msg_bob = await bob(msg_alice) # Bob は Alice のメッセージを受信して応答を生成します。Alice は、明示的に渡されない限り、Bob のメッセージを受信しません。
msg_carol = await carol(msg_alice) # 同様に、エージェントは、明示的に渡されない限り、他のエージェントからのメッセージを受信できません。
# MsgHub を使用したブロードキャスト。エージェントグループ内のメッセージブロードキャストのための糖衣構文
from agentscope.pipeline import MsgHub
async with MsgHub(
participants=[alice, bob, carol],
announcement=Msg("Host", "Let's discuss", "user")
) as hub:
await alice() # Bob と Carol はこれを受信
await bob() # Alice と Carol はこれを受信
# 手動ブロードキャスト
await hub.broadcast(Msg("Host", "New topic", "user"))
# 動的な参加者管理
hub.add(david)
hub.delete(bob)
例 3: マスターワーカーパターン
ワーカーエージェントをマスターエージェントのツールとしてラップします。
from agentscope.tool import ToolResponse, Toolkit
async def create_worker(task: str) -> ToolResponse:
"""指定されたタスクのワーカーエージェントを作成します。
Args:
task (`str`): 特定かつ簡潔であるべき指定されたタスク。
"""
task_msg = Msg(name="master", content=task, role="user") # 入力タスクを使用するか、より複雑なプロンプトにラップします
worker = ReActAgent(...)
res = await worker(task_msg)
return ToolResponse(content=res.content) # ワーカーの応答をツール応答として返します
toolkit = Toolkit()
toolkit.register_tool_function(create_worker)
AgentScope の操作
このセクションでは、AgentScope に関する質問に効果的に答えたり、フレームワークでコーディングしたりする方法について説明します。
ステップ 1: まずリポジトリをクローンする
重要: 他の何よりも先に、AgentScope リポジトリをクローンまたは更新してください。リポジトリには、重要な例とリファレンスが含まれています。
# このスキルディレクトリにクローンして、異なるセッションで参照できるようにします
cd /path/to/this/skill/directory
git clone -b main https://github.com/agentscope-ai/agentscope.git
# または、すでにクローンされている場合は更新します
cd /path/to/this/skill/directory/agentscope
git pull
これが重要な理由: リポジトリには、動作する例、ソースコード内の完全な API ドキュメント、および推測よりも信頼性の高い実装パターンが含まれています。
ステップ 2: リポジトリ構造を理解する
クローンされたリポジトリは、次のように構成されています。これはプロジェクトの進化に伴い古くなっている可能性があることに注意してください。
(原文がここで切り詰められています)
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Understanding AgentScope
What is AgentScope?
AgentScope is a production-ready, enterprise-grade open-source framework for building multi-agent applications with large language models. Its functionalities cover:
- Development: ReAct agent, context compression, short/long-term memory, tool use, human-in-the-loop, multi-agent orchestration, agent hooks, structured output, planning, integration with MCP, agent skill, LLMs API, voice interaction (TTS/Realtime), RAG
- Evaluation: Evaluate multistep agentic applications with statistical analysis
- Training: Agentic reinforcement learning
- Deployment: Session/state management, sandbox, local/serverless/Kubernetes deployment
Installation
pip install agentscope
# or
uv pip install agentscope
Core Concepts
- Message: The core abstraction for information exchange between agents. Supports heterogeneous content blocks (text, images, tool calls, tool results).
from agentscope.message import Msg, TextBlock, ImageBlock, URLSource
msg = Msg( name="user", content=[TextBlock("Hello world"), ImageBlock(type="image", source=URLSource(type="url", url="..."))], role="user" )
- **Agent**: LLM-empowered agent that can reason, use tools, and generate responses through iterative thinking and action loops.
- **Toolkit**: Register and manage tools (Python functions, MCP, agent skills) that agents can call.
- **Memory**: Store `Msg` objects as conversation history/context with a marking mechanism for advanced memory management (compression, retrieval).
- **ChatModel**: Unified interface across different providers (OpenAI, Anthropic, DashScope, Ollama, etc.) with support for tool use and streaming.
- **Formatter**: Convert `Msg` objects to LLM API-specific formats. Must be used with the corresponding ChatModel. Supports multi-agent conversations with different agent identifiers.
### Basic Usage Examples
#### Example 1: Simple Chatbot
```python
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, execute_shell_command
import os, asyncio
async def main():
# Initialize toolkit with tools
toolkit = Toolkit()
toolkit.register_tool_function(execute_python_code)
toolkit.register_tool_function(execute_shell_command)
# Create ReActAgent with model, memory, formatter, and toolkit
agent = ReActAgent(
name="Friday",
sys_prompt="You're a helpful assistant named Friday.",
model=DashScopeChatModel(
model_name="qwen-max",
api_key=os.getenv("DASHSCOPE_API_KEY"),
stream=True,
),
memory=InMemoryMemory(),
formatter=DashScopeChatFormatter(),
toolkit=toolkit,
)
# Create user agent for terminal input
user = UserAgent(name="user")
# Conversation loop
msg = None
while True:
msg = await agent(msg) # Agent processes and replies
msg = await user(msg) # User inputs next message
if msg.get_text_content() == "exit":
break
asyncio.run(main())
Example 2: Multi-Agent Conversation
AgentScope adopts explicit message passing for multi-agent conversations (PyTorch-like dynamic graph), allowing flexible information flow control.
alice, bob, carol, david = ReActAgent(...), ReActAgent(...), ReActAgent(...), ReActAgent(...)
msg_alice = await alice()
msg_bob = await bob(msg_alice) # Bob receives Alice's message and generate a reply. Alice doesn't receive Bob's message unless explicitly passed back.
msg_carol = await carol(msg_alice) # Similarly, the agent cannot receive messages from other agents unless explicitly passed.
# Broadcasting with MsgHub, a syntactic sugar for message broadcasting within a group of agents
from agentscope.pipeline import MsgHub
async with MsgHub(
participants=[alice, bob, carol],
announcement=Msg("Host", "Let's discuss", "user")
) as hub:
await alice() # Bob and Carol receive this
await bob() # Alice and Carol receive this
# Manual broadcast
await hub.broadcast(Msg("Host", "New topic", "user"))
# Dynamic participant management
hub.add(david)
hub.delete(bob)
Example 3: Master-Worker Pattern
Wrap worker agents as tools for the master agent.
from agentscope.tool import ToolResponse, Toolkit
async def create_worker(task: str) -> ToolResponse:
"""Create a worker agent for the given task.
Args:
task (`str`): The given task, which should be specific and concise.
"""
task_msg = Msg(name="master", content=task, role="user") # Use the input task or wrap it into a more complex prompt
worker = ReActAgent(...)
res = await worker(task_msg)
return ToolResponse(content=res.content) # Return the worker's response as the tool response
toolkit = Toolkit()
toolkit.register_tool_function(create_worker)
Working with AgentScope
This section provides guidance on how to effectively answer questions about AgentScope or coding with the framework.
Step 1: Clone the Repository First
CRITICAL: Before doing anything else, clone or update the AgentScope repository. The repository contains essential examples and references.
# Clone into this skill directory so that you can refer to it across different sessions
cd /path/to/this/skill/directory
git clone -b main https://github.com/agentscope-ai/agentscope.git
# Or update if already cloned
cd /path/to/this/skill/directory/agentscope
git pull
Why this matters: The repository contains working examples, complete API documentation in source code, and implementation patterns that are more reliable than guessing.
Step 2: Understand the Repository Structure
The cloned repository is organized as follows. Note this may be outdated as the project evolves, you should always check the actual structure after cloning.
agentscope/
├── src/agentscope/ # Main library source code
│ ├── agent/ # Agent implementations (ReActAgent, etc.)
│ ├── model/ # LLM API wrappers (OpenAI, Anthropic, DashScope, etc.)
│ ├── formatter/ # Message formatters for different models
│ ├── memory/ # Memory implementations
│ ├── tool/ # Tool management and built-in tools
│ ├── message/ # Msg class and content blocks
│ ├── pipeline/ # Multi-agent orchestration (MsgHub, etc.)
│ ├── session/ # Session/state management
│ ├── mcp/ # MCP integration
│ ├── rag/ # RAG functionality
│ ├── realtime/ # Realtime voice interaction
│ ├── tts/ # Text-to-speech
│ ├── evaluate/ # Evaluation tools
│ └── ... # Other modules
│
├── examples/ # Working examples organized by category
│ ├── agent/ # Different agent types
│ │ └── ...
│ ├── workflows/ # Multi-agent workflows
│ │ └── ...
│ ├── functionality/ # Specific features
│ │ └── ...
│ ├── deployment/ # Deployment patterns
│ ├── integration/ # Third-party integrations
│ ├── evaluation/ # Evaluation examples
│ └── game/ # Game examples (e.g., werewolves)
│
├── docs/ # Documentation
│ ├── tutorial/ # Tutorial markdown files
│ ├── changelog.md # Version history
│ └── roadmap.md # Development roadmap
│
└── tests/ # Test files
Step 3: Browse Examples by Category
When looking for similar implementations, browse the examples directory by category rather than searching by keywords alone:
- Start with the category that matches your use case:
- Building a specific agent type? →
examples/agent/ - Multi-agent system? →
examples/workflows/ - Need a specific feature (MCP, RAG, session)? →
examples/functionality/ - Deployment patterns? →
examples/deployment/
- Building a specific agent type? →
- List the subdirectories to see what's available:
- Use file listing tools to explore directory structure
- Read directory names to understand what each example covers
- Read example files to understand implementation patterns:
- Most examples contain a main script and supporting files
- Look for README files in subdirectories for explanations
- Combine with text search when needed:
- After identifying relevant directories, search within them for specific patterns
- Search for class names, method calls, or specific functionality
Example workflow:
User asks: "Build a FastAPI app with AgentScope"
→ Browse: List files in examples/deployment/
→ Check: Are there any web service examples?
→ Search: Look for "fastapi", "flask", "api", "server" in examples/
→ Read: Found examples and adapt to user's needs
Step 4: Verify Functionality Exists
Before implementing custom solutions, verify if AgentScope already provides the functionality:
- List required functionalities (e.g., session management, MCP integration, RAG)
- Check if provided:
- Browse
examplesfor examples - Search tutorial documentation in
docs/tutorial/ - Use the provided scripts (see Part 3) to explore API structure
- Read source code in
src/agentscope/for implementation details
- Browse
- If not provided: Check how to customize by reading base classes and inheritance patterns in source code
Step 5: Make a Plan
Always create a plan before coding:
- Identify what AgentScope components you'll use
- Determine what needs custom implementation
- Outline the architecture and data flow
- Consider edge cases and error handling
Step 6: Code with API Reference
When writing code:
- Check docstrings and arguments before using any class/method
- Read source code files to see signatures and documentation, or
- Use the provided scripts to view module/class structures
- NEVER make up classes, methods, or arguments
- Check parent classes - A class's functionality includes inherited methods
- Manage lifecycle - Clean up resources when needed (close connections, release memory)
Common Pitfalls to Avoid
- ❌ Guessing API signatures without checking documentation
- ❌ Implementing features that already exist in AgentScope
- ❌ Mixing incompatible Model and Formatter (e.g., OpenAI model with DashScope formatter)
- ❌ Forgetting to await async agent calls
- ❌ Not checking parent class methods when searching for functionality
- ❌ Searching by keywords only without browsing the organized examples directory structure
Resources
This section lists all available resources for working with AgentScope.
Official Documentation
- Tutorial: Comprehensive step-by-step guide covering most functionalities in detail. This is the primary resource for learning AgentScope.
GitHub Resources
- Main Repository: Source code, examples, and documentation
- Project Board: Official development roadmap and task tracking
- Design Discussions: In-depth explanations about specific modules/functions/components
Repository Structure
When the repository is cloned locally, the following structure is available for reference:
src/agentscope/: Main library source code- Read this for API implementation details
- Check docstrings for parameter descriptions
- Understand inheritance hierarchies
examples/: Working examples demonstrating features- Start here when building similar applications
- Examples cover: basic agents, multi-agent systems, tool usage, deployment patterns
docs/tutorial/: Tutorial documentation source files- Markdown files explaining concepts and usage
- More detailed than README files
Scripts
Located in scripts/ directory of this skill.
view_pypi_latest_version.sh: View the latest version of AgentScope on PyPI.cd /path/to/this/skill/directory/scripts/ bash view_pypi_latest_version.shview_module_signature.py: Explore the structure of AgentScope modules, classes, and methods. Search strategy: Use deep-first search - start broad, then narrow down:
agentscope→ see all submodulesagentscope.agent→ see agent-related classesagentscope.agent.ReActAgent→ see specific class methods
cd /path/to/this/skill/directory/scripts/
# View top-level module
python view_module_signature.py --module agentscope
# View specific submodule
python view_module_signature.py --module agentscope.agent
# View specific class
python view_module_signature.py --module agentscope.agent.ReActAgent
Reference
Located in references/ directory of this skill.
multi_agent_orchestration.md: Multi-agent orchestration concepts and implementationdeployment_guide.md: Deployment patterns and best practices