消息总线支持点对点与发布订阅,监督者的派活走点对点并行
team_runtime 下的 MessageBus 同时支持点对点(send)与发布订阅(publish / subscribe),主题按团队与会话隔离。层级团队里,子代理以 AgentCard 的形式出现在监督者的工具列表中;监督者一次发出的多个工具调用会被分成两组:调用子代理的走总线点对点发送、用信号量限制并发(默认 10),普通工具交给基类照常执行,两组并行后按原顺序归并结果。另有 handoff(接力)与 hierarchical_tools(子代理即工具)两种团队形态并存。
- 适合
- 需要多种协作拓扑(层级、接力、广播)并存的团队编排。
- 代价
- 点对点与发布订阅都要维护主题隔离与订阅关系,心智负担较重。
此后的变化
- 2026-W41 →
新增跨团队的 Team Organization:Leader 消息先落共享数据库再发唤醒事件,按收件团队建 receipt,处理成功后 ack,重新绑定时重投未确认消息。原格的消息总线之上多了一层带确认的可靠投递,当前限同一进程、同一数据库实例。
class P2PAbilityManager(AbilityManager):
"""AbilityManager that routes AgentCard tool calls via TeamRuntime P2P send().
AgentCard calls are dispatched in parallel, bounded by
``max_parallel_sub_agents``. All other ability types are forwarded to
the base-class ``execute()`` unchanged.
Args:
supervisor: The supervisor agent whose ``send()`` is used for P2P dispatch.
max_parallel_sub_agents: Max concurrent AgentCard dispatches per :meth:`execute` call.
"""
# ...(30-77 行:构造与信号量;把工具调用规范化为列表)
# Partition into agent-calls vs. non-agent calls.
agent_indices = [
i for i, tc in enumerate(tool_calls) if tc.name in self._agents
]
other_indices = [
i for i in range(len(tool_calls)) if i not in set(agent_indices)
]
# ...(85-95 行:没有 Agent 调用时直接交给基类)
semaphore = self._get_semaphore()
async def _dispatch_one(tc: ToolCall) -> Tuple[Any, ToolMessage]:
async with semaphore:
return await self._execute_single_tool_call(tc, session, tag)
agent_coros = [_dispatch_one(tool_calls[i]) for i in agent_indices]