构建异步/事件驱动 Agent,或让 Agent 响应外部事件(新邮件、webhook 回调、IM 消息、定时器、系统告警)、 处理工具执行期间的用户打断与多任务并发时使用。覆盖事件循环与安全点、三类事件触发工具、用户沟通与多渠道召回、 虚拟身份与隔离执行环境、队列式/取消式/并行式三种事件处理策略及紧急度判定,以及模型原生异步与同步接口兼容两条路线。 触发词:异步 Agent、事件驱动、event-driven、webhook、定时器、心跳、任务句柄、打断、steering、并行工具执行。
88%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
user.interrupt、supervisor.instruction、agent.interrupt、紧急告警):停当前操作 → 清空队列 → 所有事件连同紧急事件一次性追加到轨迹 → 立即重新调 LLM。user.input、tool.result、timer.trigger):放入队尾不打断,等本轮到达安全点后批量追加,减少往返。initiate_phone_call 立即返回任务 ID 和初始状态,进展通过 phone_call_connected / phone_call_ended 等事件通知。工具名和描述本身就要传达异步语义("任务发起后立即返回 ID,你可以继续处理其他事项,结束后会收到单独通知")。asyncio 不等于模型具备异步能力,仍需应用层管理事件来源、工具生命周期与结果归属。chapter6/async-agent/ 的 runtime.py::AgentRuntime(_dispatcher 路由紧急度、_handle_interrupt 在安全点取消、run_llm_turn 推进轨迹)。[未处理事件 2/4] ...),末尾附汇总,提示模型必须回应全部,防止只记住最后一条。/workspace/shared)以文件路径而非内容传数据,避免占满上下文;必须登录用户真实账号时走 Human-in-the-Loop(VNC/RDP 让用户亲自登录,会话令牌有效期内复用)。ctx.Done()),"停止"消息发出去任务还在跑。chapter6/async-agent/ — 实验 6-2:事件驱动异步 Agent 框架(Flux),并行工具、打断取消、检查点持久化,含零依赖离线 demo。chapter6/agent-with-event-trigger/ — 实验 6-1:FastAPI 事件驱动 Agent + 42 个 MCP 工具,演示"事件到达 → Agent 处理 → 结果输出"最小闭环。chapter6/async-agent/ 同时给出离线验收 demo(并行 vs 串行墙钟时间、打断取消后恢复、检查点持久化与还原)与 LLM 场景复现两条路径,适合先跑离线 demo 验证运行时再上真实模型。chapter6/astra-async-steering/ — 实验 6-3:GPT-6 Astra 原生异步工具调用与回合中途引导,含 sync / async / steer_reasoning / async_steer / unsupported_steer 五组对照与真实 API 运行记录。chapter6/end-to-end-speech/、chapter6/streaming-speech/、chapter6/controllable-tts/、chapter6/live-audio/、chapter6/phone-agent/。chapter6/gemini-xlerobot-navigation/、chapter6/rgb-sim2real-grasping/、chapter6/xlerobot-teleoperation/。book/chapter6.md「模态与触发时机的扩展」book/chapter6.md「异步与事件驱动:当世界主动找上门」chapter6/async-agent/agent_framework_design.md(Flux 框架的运行时设计)bojieli/ai-agent-book
dbc046e
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.