Skip to main content
Agent Manager is the assistant runtime inside Hiro Server. Communication Manager prepares inbound messages and places them on inbound_queue. Agent Manager consumes that queue, resolves the conversation and character, builds the agent input, invokes the LLM agent with tools and memory, then sends replies back through Communication Manager. The component is the link between Hiro’s message pipeline and the LLM runtime.

Responsibilities

Queue consumption - Agent Manager runs as a long-lived worker. It waits on CommunicationManager.inbound_queue, processes one prepared UnifiedMessage at a time, and always marks the queue item done. Conversation resolution - For each message, it maps routing.channel and routing.sender_id to a conversation channel row. That row supplies the memory thread ID, database channel ID, and character ID. Character and model resolution - It loads the conversation character, builds the effective system prompt, resolves the chat model from character preferences and workspace defaults, and reuses a workspace credential store. Agent input preparation - It builds a text input from direct text content plus adapter-provided descriptions on non-text content. Audio transcripts and image descriptions enter the LLM here. Agent execution - It invokes a LangChain or LangGraph agent with Hiro tools, persistent conversation memory, and optional summarization. Reply delivery - It converts provider output into a Hiro text reply, saves the reply to data.db, and enqueues the reply through Communication Manager. Voice reply delivery - When the device requests a voice reply and policy allows it, Agent Manager synthesizes speech after the text reply has already been queued, then emits a message.voiced event.

Main components

AgentManager

The worker and per-message orchestrator in runtime/agent_manager.py. It owns the run loop, agent cache, checkpointer lifecycle, credential store reuse, per-message processing, reply construction, and optional TTS scheduling.

Queue worker

The run() coroutine opens the LangGraph SQLite checkpointer against workspace.db, creates a workspace CredentialStore, clears the compiled agent cache, then drains CommunicationManager.inbound_queue. The queue boundary is important. Communication Manager owns message validation, adaptation, transcript events, and inbound persistence. Agent Manager starts only after a message is agent-ready.

Message preparation

Message preparation converts a UnifiedMessage into one agent input string.
Content sourceHow it becomes agent input
Text content itemUses the item body directly.
Audio content itemUses metadata.description, produced by the audio adapter.
Image content itemUses metadata.description, produced by the image adapter, prefixed with the content type.
Unsupported or failed itemLogged and skipped.
If no usable text remains, the message is dropped for agent purposes.

Thread and character resolver

The resolver uses ConversationChannelGetTool with the canonical channel name:
{routing.channel}:{routing.sender_id}
The conversation channel row provides:
ValuePurpose
idLangGraph thread ID and message-store channel ID.
character_idCharacter profile and model preferences for this conversation.
If the row has no character ID, Agent Manager falls back to the workspace default character.

Agent runtime factory

Agent Manager compiles the actual LLM runtime from:
InputRole
Character system promptPersona and behavior instructions.
Resolved chat modelProvider/model/temperature/token configuration.
Hiro tool registryTool set exposed to the agent.
LangGraph checkpointerPersistent per-thread memory.
Memory preferencesWhether to use summarization.
Compiled agents are cached by model settings, summarization settings, and system prompt hash. This avoids rebuilding the graph for every message while still separating distinct character/model configurations.

Memory and summarization

Conversation memory is backed by AsyncSqliteSaver in workspace.db. When summarization is disabled, Agent Manager uses LangChain’s standard create_agent() with the shared checkpointer. When summarization is enabled and a summarization model is available, it builds the custom graph in summarizing_agent_graph.py. That graph runs:
summarize -> call_model -> tools -> summarize -> call_model
The full message history remains in the checkpoint. The model receives the summarized working context when the configured token threshold is crossed.

Reply pipeline

The reply pipeline normalizes provider-native content into plain text, constructs an outbound UnifiedMessage, saves the reply to the message store, and enqueues it through Communication Manager. If the LLM call fails, Agent Manager still sends a human-readable fallback reply. If saving the reply fails, delivery still proceeds.

Voice reply pipeline

Voice output is a post-reply side effect. The text reply is queued first. If routing.metadata.request_voice_reply is true and workspace/character voice settings resolve to a usable TTS model, Agent Manager starts a detached TTS task. The task emits message.voiced with base64 audio, MIME type, duration, and a ref_id pointing to the text reply.

Processing flow


Communication Manager

Communication Manager is Agent Manager’s input and output boundary. It supplies agent-ready messages through inbound_queue and accepts replies through enqueue_outbound().

Message Adapter Pipeline

The adapter pipeline prepares non-text content before Agent Manager sees it. Agent Manager reads adapter output from metadata.description.

Character and preferences domain

Characters define the system prompt and optional model preferences. Workspace preferences define default chat, summarization, STT, and TTS behavior.

Tool registry

Agent Manager exposes Hiro tools to the LangChain or LangGraph agent. The same tool implementations are shared with CLI and server surfaces.

Message store

Inbound persistence happens before Agent Manager through Communication Manager’s post-adapt hooks. Outbound agent replies are saved by Agent Manager after reply construction.

See also

Communication Manager

The message router that prepares inbound messages and dispatches replies.

Hiro Server components

How the main server components relate to each other.

Channel Manager

The transport manager that owns channel plugins and WebSocket JSON-RPC.