Handoff
create_handoff_tool() 产生 Command(scope=PARENT),让子 Agent 把控制权交回直接父图。跨图传递的状态必须明确写入 Command.update,不会隐式复制子图全部状态。
Map-reduce fan-out
条件边可返回多个Send(node, arg),为同一节点创建私有输入的并行任务。结果通过 Annotated reducer 合并回共享状态。不要让并行节点写同一个普通 LastValue 字段。
生产护栏
- 为 group chat 设置有限
max_turns或确定性 termination; - 父子图共享
max_model_calls、max_tool_calls、max_tokens、max_cost; - 为远端 Agent 设置 timeout、retry 和取消传播;
- handoff 状态只包含下一个角色需要的数据;
- 所有带副作用的专家工具使用稳定幂等键;
- 在 event metadata 中保留 agent、namespace 与 task path,便于追踪。
examples/multi_agent_supervisor.py、examples/map_reduce_send.py 和 examples/subgraph_team_review.py 提供可运行示例。