Expand description
Agent loop domain types.
These types define the core abstractions for the backend agentic loop. They are pure domain primitives: no LLM backend references, no MCP types, no infrastructure concerns.
§Modules
| Module | Contents |
|---|---|
config | AgentConfig — loop control parameters |
tool_types | ToolDefinition, ToolCall, ToolResult |
messages | AgentMessage — closed conversation-turn enum |
messages_serde | Custom Serialize/Deserialize impls for AssistantContent |
events | AgentEvent (SSE units), LlmStreamEvent (stream protocol) |
§Design Principles
AgentMessageis a closed enum so the type system prevents invalid states (e.g. aUsermessage carryingtool_calls).ToolDefinitionis a dedicated type — adapter layers convertMcpTool → ToolDefinition; the agent domain must not depend on MCP domain types.ToolResultwithsuccess: falseis context for the LLM, not an error; tool failures are fed back into the conversation so the model can reason about them and retry or adjust its approach.AgentEventis the unit of SSE emission; every observable state change in the loop corresponds to exactly one variant.
Re-exports§
pub use config::AgentConfig;pub use config::AgentConfigError;pub use config::DEFAULT_MAX_ITERATIONS;pub use config::DEFAULT_MAX_PARALLEL_TOOLS;pub use config::MAX_ITERATIONS_CEILING;pub use config::MAX_PARALLEL_TOOLS_CEILING;pub use config::MAX_TOOL_TIMEOUT_MS_CEILING;pub use config::MIN_CONTEXT_BUDGET_CHARS;pub use config::MIN_TOOL_TIMEOUT_MS;pub use events::AGENT_EVENT_CHANNEL_CAPACITY;pub use events::AgentEvent;pub use events::LlmStreamEvent;pub use messages::AgentMessage;pub use messages::AssistantContent;pub use tool_types::ToolCall;pub use tool_types::ToolDefinition;pub use tool_types::ToolResult;
Modules§
- config
AgentConfig— configuration for a single agentic loop run.- events
AgentEventandLlmStreamEvent— observable events in the agentic loop.- messages
AgentMessage— A single message in the agent conversation.- messages_
serde 🔒 - Custom
Serialize/Deserializeimplementations for agent message types. - tool_
types - Tool-schema and tool-call/result types.