Agent Loop:AIAgent 执行流程深拆
本篇拆官方 Agent Loop Internals 文档(hermes-agent.nousresearch.com/docs/developer-guide/agent-loop)。所有 turn 生命周期、API mode、工具执行、回调、预算与 fallback 原文均来自官方。这是 Hermes 架构里最核心的一个类——理解 AIAgent 就理解了 Hermes 怎么"跑"。
一、案例溯源:AIAgent 是什么
官方原文定位:
The core orchestration engine is the
AIAgentclass.run_agent.pyis now a thin facade: the loop itself lives inagent/conversation_loop.py, each turn phase inagent/turn_*.py(iteration prep, API call, API error, overflow, truncation, recovery), constructor wiring inagent/agent_init.py, and everything from prompt assembly to tool dispatch to p