多智能体与 A2AMulti-agent & A2A · 单元Unit 09
多智能体与 A2A:角色、委派与边界Multi-agent and A2A: roles, delegation and boundaries
多智能体不是把 Agent 复制多份,而是设计角色、交付物和路由。学完本单元,你能避免循环委派、重复检索和无法追踪的任务链路。Multi-agent is not copying an agent many times; it is designing roles, deliverables and routing. After this unit you can avoid delegation loops, duplicate retrieval and untraceable task chains.
学习目标Learning goals
- 设计角色边界与交付物Design role boundaries and deliverables
- 使用 A2A 接入远端智能体并管理状态Use A2A to connect remote agents and manage state
- 用深度、预算和白名单约束委派Constrain delegation with depth, budgets and allowlists
概念闪卡Concept cards
点击卡片翻面查看解释。Click a card to flip it and reveal the explanation.
关键 APIKey APIs
点击进入对应的 Python 或 Java 参考页。Open the exact Python or Java reference for each type.
问题巩固Check yourself
完成 10 道题;答错会自动进入错题本。Answer all ten questions. Wrong answers are added to your wrong-answer book automatically.
01Python 中面向远端 A2A 智能体的适配器是?Which Python adapter talks to a remote A2A agent?
解析Why A2AAgent 提供 reply、reply_stream、observe 和 aclose,但把模型与工具职责交给远端。A2AAgent provides reply, reply_stream, observe and aclose while delegating model and tool concerns to the remote side.
02A2A 客户端保存远端会话与任务状态的类型是?Which type stores the A2A remote conversation and task state?
解析Why A2AAgentState 保存 context_id 与 task_id,是继续多轮任务的关键。A2AAgentState stores context_id and task_id, which are essential for continuing multi-turn tasks.
03团队成员的描述类型是?Which type describes a team member?
解析Why TeamMember 声明成员角色与能力,供流水线或团队编排使用。TeamMember declares a member's role and capabilities for pipeline or team orchestration.
04防止循环委派最直接的手段是?What is the most direct way to prevent delegation loops?
解析Why 没有边界时 A 委派 B、B 又委派 A,会造成成本爆炸和无法终止。Without boundaries A delegates to B and B back to A, causing runaway cost and non-termination.
05关闭 Python A2A 客户端连接的方法是?How do you close a Python A2A client?
解析Why A2AAgent 拥有自己的 A2A 客户端,aclose 后不可重新打开,应按单次使用管理。A2AAgent owns its A2A client; after aclose it cannot reopen, so treat it as single-use.
06Java 中面向 A2A 的智能体类是?Which Java class represents an A2A agent?
解析Why A2aAgent 由 agentscope-core 的 a2a 包提供,配置由 A2aAgentConfig 承载。A2aAgent lives in the a2a package of agentscope-core and is configured by A2aAgentConfig.
07Java 中汇聚子智能体事件的接口是?Which Java interface aggregates subagent events?
解析Why SubagentEventBus 把子智能体事件接入父级事件流,便于统一追踪。SubagentEventBus feeds subagent events into the parent stream for unified tracing.
08跨智能体追踪一次任务链路依赖什么?What is required to trace one task across agents?
解析Why 没有统一 id,日志无法拼出完整链路,故障定位只能靠猜。Without a shared id logs cannot reconstruct the chain, leaving failure diagnosis to guesswork.
09多智能体设计应该先确定什么?What should be designed first in a multi-agent system?
解析Why 先定义每个角色负责什么、交付什么,再选择团队拓扑,避免一群全能 Agent 互相抢活。Define what each role owns and delivers before choosing topology, avoiding generalist agents competing for work.
10子智能体重复检索相同信息会导致?What happens when subagents duplicate the same retrieval?
解析Why 应在委派时携带上下文摘要,并约定共享缓存或检索结果。Pass context summaries on delegation and agree on shared caches or retrieval results.