How largebigbug/hermes-agent works
Purpose and principal workflow
Hermes is a multi-surface AI agent: people interact through the CLI, terminal UI, messaging gateway, desktop app, or ACP interface, and the agent runs model-driven turns that can invoke tools, preserve conversation context, and return results. In the main turn workflow, an external user’s message reaches the conversation orchestration, which prepares and sends a model request, handles tool rounds and retries, and can compact context. The README also documents persistent learning, cross-session search, and scheduled automations; the sampled excerpts do not establish all of their runtime wiring.
Components
User and application entry surfaces
• Hermes users — *null repository path*. Initiate conversations through the documented CLI, messaging platforms, desktop, or terminal UI; the README identifies these as product surfaces.
• Terminal UI input — ui-tui/src/app/useInputHandlers.ts. Handles keyboard and overlay actions and sends gateway RPC requests, including voice recording.
• Terminal UI turn controller — ui-tui/src/app/turnController.ts. Owns turn-facing UI state and coordination; its imports identify supporting stores and shared app code.
• Gateway application — tui_gateway/server.py. Implements the TUI gateway server; its source index references the conversation loop and local execution environment.
• OpenAI-compatible gateway routes — gateway/platforms/api_server_openai_routes.py. Provides API routes for callers that use the gateway’s OpenAI-compatible interface.
• ACP server — acp_adapter/server.py. Implements the Agent Client Protocol server and coordinates ACP session, command, event, permission, and tool modules.
• Safe console command engine — hermes_cli/console_engine.py. Registers and validates supported Hermes Console commands, rejecting interactive or otherwise blocked commands.
Agent turn and context
• Conversation orchestration — agent/conversation_loop.py. Drives a user turn through model calls, tool dispatch, retries, fallbacks, compression, and post-turn hooks.
• Context lifecycle interface — agent/context_engine.py. Defines the context-engine lifecycle, usage tracking, and compression decisions across sessions and turns.
• Default context compressor — agent/context_compressor.py. Reduces oversized conversation context, including pruning tool output and images while preserving selected turns.
• Provider and transport subsystem — agent/provider_registry.py. Organizes provider selection; provider-specific adapters and transports are separate modules in agent/ (the sampled excerpts do not establish their complete call path).
Tool execution and persistence
• Local execution environment — tools/environments/local.py. Implements the local tool environment and references shared environment interfaces and gateway session context.
• Tool-result spillover storage — tools/tool_result_storage.py. Persists large tool outputs and replaces them with previews and paths, with sandbox-copy and readability handling for remote environments.
• Runtime configuration — hermes_cli/config.py. Loads, validates, and saves Hermes configuration, including provider and fallback settings.
Documented product capabilities
• Cron scheduler worker — cron/scheduler_detached_worker.py. The README documents unattended scheduled automations and platform delivery; sampled source does not show how this worker dispatches jobs.
• Learning and memory subsystem — agent/memory_manager.py. The README describes curated memory, skill creation and improvement, and cross-session search; the sampled material does not establish the subsystem’s complete boundaries or wiring.
• Desktop main process — apps/desktop/electron/main.ts. The repository includes an Electron desktop application; the sampled excerpts do not establish its complete startup or backend-connection flow.
Relationships
• Hermes users -> Terminal UI input: enter commands and interact with overlays; evidence: ui-tui/src/app/useInputHandlers.ts.
• Terminal UI input -> Terminal UI turn controller: invokes turn-related input actions; evidence: ui-tui/src/app/useInputHandlers.ts (the excerpt imports the controller, but does not show every action’s dispatch).
• Terminal UI input -> Gateway application: sends voice-recording RPC; evidence: ui-tui/src/app/useInputHandlers.ts.
• Hermes users -> Gateway application: initiate TUI gateway sessions; evidence: none (inferred from the product surface documented in the README).
• Hermes users -> OpenAI-compatible gateway routes: call the gateway API; evidence: none (inferred from the route component’s role).
• Hermes users -> ACP server: connect as ACP clients; evidence: acp_adapter/server.py (implements the protocol server; the specific external client is not in the repository).
• Gateway application -> Conversation orchestration: references the conversation loop; evidence: tui_gateway/server.py (SOURCE INDEX).
• OpenAI-compatible gateway routes -> Gateway application: share gateway API and session modules; evidence: gateway/platforms/api_server_openai_routes.py (SOURCE INDEX; specific runtime routing is not shown).
• Conversation orchestration -> Context lifecycle interface: uses context-engine functionality; evidence: agent/conversation_loop.py (SOURCE INDEX).
• Context lifecycle interface -> Default context compressor: identifies the compressor as the default implementation; evidence: agent/context_engine.py (excerpt).
• Local execution environment -> Tool-result spillover storage: the storage module uses environment execution and is designed for host and sandbox paths; evidence: tools/tool_result_storage.py (excerpt; caller-side invocation is not established).
• Conversation orchestration -> Provider and transport subsystem: prepares and issues model calls; evidence: agent/conversation_loop.py (excerpt describes the loop; exact provider-selection wiring is not shown).
• Safe console command engine -> Runtime configuration: registers and dispatches supported configuration commands; evidence: hermes_cli/console_engine.py (SOURCE INDEX).
Coverage limits
The inputs provide a broad tree but only selected excerpts and index references. They do not establish the full CLI startup chain, all gateway routes, provider-selection sequence, tool-dispatch call sites, desktop renderer/backend wiring, or detailed learning and scheduler flows; relationships in those areas are deliberately limited or marked inferred.
Main entry points: server.py Gateway application · useInputHandlers.ts Terminal UI input · conversation_loop.py Conversation orchestration · api_server_openai_routes.py OpenAI-compatible gateway routes
Components 17
User Surfaces
External users and application entry points.
- Hermes users
- Terminal UI input
ui-tui/src/app/useInputHandlers.ts - Terminal UI turn controller
ui-tui/src/app/turnController.ts - Gateway application
tui_gateway/server.py - OpenAI-compatible gateway routes
gateway/platforms/api_server_openai_routes.py - ACP server
acp_adapter/server.py - Desktop main process
apps/desktop/electron/main.ts
Agent Turn
Conversation orchestration, context handling, and model transport.
- Conversation orchestration
agent/conversation_loop.py - Context lifecycle interface
agent/context_engine.py - Default context compressor
agent/context_compressor.py - Provider and transport subsystem
agent/provider_registry.py
Runtime Services
Tool execution, configuration, and console command handling.
- Local execution environment
tools/environments/local.py - Tool-result spillover storage
tools/tool_result_storage.py - Runtime configuration
hermes_cli/config.py - Safe console command engine
hermes_cli/console_engine.py
Product Capabilities
Documented capabilities whose runtime wiring is not established.
- Cron scheduler worker
cron/scheduler_detached_worker.py - Learning and memory subsystem
agent/memory_manager.py
Connections 13
- Hermes users → Terminal UI input: Interact
ui-tui/src/app/useInputHandlers.ts - Terminal UI input → Terminal UI turn controller: Turn actions
ui-tui/src/app/useInputHandlers.ts - Terminal UI input → Gateway application: Voice RPC
ui-tui/src/app/useInputHandlers.ts - Hermes users → Gateway application: Initiate sessions · Inferred; not shown in the code that was read.
- Hermes users → OpenAI-compatible gateway routes: Call API · Inferred; not shown in the code that was read.
- Hermes users → ACP server: Connect as client
acp_adapter/server.py - Gateway application → Conversation orchestration: References loop
tui_gateway/server.py - OpenAI-compatible gateway routes → Gateway application: Shares gateway modules
gateway/platforms/api_server_openai_routes.py - Conversation orchestration → Context lifecycle interface: Uses context engine
agent/conversation_loop.py - Context lifecycle interface → Default context compressor: Default implementation
agent/context_engine.py - Local execution environment → Tool-result spillover storage: Uses environment execution
tools/tool_result_storage.py - Conversation orchestration → Provider and transport subsystem: Issues model calls
agent/conversation_loop.py - Safe console command engine → Runtime configuration: Dispatches commands
hermes_cli/console_engine.py