Entry & Boot Flow
源码版本v2026.7.20
Responsibility
Turn "a hermes command / a gateway message" into "an agent running in memory". The entry layer is deliberately thin — run_agent.py only forwards and assembles the CLI; the real dependency injection lives in agent_init.py. This way the gateway, TUI, CLI, ACP, and cron all share the same initialization path.
Key Files
gateway main:22965— gateway process entrymain()AIAgent class:400-497— thin entry class;__init__only stores parametersAIAgent.__init__ forwarder:497-560— comment explicitly says "Forwarder — see agent.agent_init.init_agent"run_conversation method:6350—AIAgent.run_conversationinstance method, callsmodule-level run_conversation:588CLI main:6434— CLI entryinit_agent:276-400— dependency injection main function_resolve_compression_threshold:93-127— startup-time config parsing examplehermes_bootstrap.py— earliest environment/path bootstrap (repo root)
Data Flow
- The user runs
hermes(CLI) or the gatewaymain()starts (run_agent.py:22965). - The process goes through
hermes_bootstrap.pyfor path/environment fixes, then entersCLI main:6434or the gateway loop. - An
AIAgent:400instance is constructed; its__init__forwards toinit_agent:276. init_agentresolves providers, toolsets, compression thresholds, custom provider extra_body, etc., assembling a runnable agent object.- The gateway holds this agent inside
GatewayRunneringateway/run.pyand feeds each inbound message torun_conversation:588.
Summary
The entry layer is "forward + assemble" and holds no business logic. AIAgent is a thin shell; init_agent is the assembly center. Once you understand this chain, the Agent Main Loop is just "what happens when a message is fed in".