pub trait Agent: Send + Sync {
// Required methods
fn id(&self) -> &str;
fn model(&self) -> &str;
fn system_prompt(&self) -> &str;
fn max_rounds(&self) -> usize;
fn chat_options(&self) -> Option<&ChatOptions>;
fn fallback_models(&self) -> &[String];
fn llm_retry_policy(&self) -> &LlmRetryPolicy;
fn tool_executor(&self) -> Arc<dyn ToolExecutor>;
fn behavior(&self) -> &dyn AgentBehavior;
// Provided methods
fn step_tool_provider(&self) -> Option<Arc<dyn StepToolProvider>> { ... }
fn llm_executor(&self) -> Option<Arc<dyn LlmExecutor>> { ... }
fn action_deserializer_registry(&self) -> Arc<ActionDeserializerRegistry> { ... }
}Expand description
The sole interface the agent loop sees.
Agent encapsulates all runtime configuration, execution strategies,
and agent behavior into a single trait. The loop calls methods on this trait
to obtain LLM settings, tool execution strategies, and phase-hook behavior.
§Three-Layer Architecture
- Loop: pure engine — calls
Agentmethods, manages lifecycle - Agent: complete agent unit — provides config + behavior
- AgentOS: assembly — resolves definitions into
Agentinstances
The default implementation is BaseAgent.
Required Methods§
Sourcefn system_prompt(&self) -> &str
fn system_prompt(&self) -> &str
System prompt for the LLM.
Sourcefn max_rounds(&self) -> usize
fn max_rounds(&self) -> usize
Loop-budget hint (core loop does not enforce this directly).
Sourcefn chat_options(&self) -> Option<&ChatOptions>
fn chat_options(&self) -> Option<&ChatOptions>
Chat options for the LLM.
Sourcefn fallback_models(&self) -> &[String]
fn fallback_models(&self) -> &[String]
Fallback model ids used when the primary model fails.
Sourcefn llm_retry_policy(&self) -> &LlmRetryPolicy
fn llm_retry_policy(&self) -> &LlmRetryPolicy
Retry policy for LLM inference failures.
Sourcefn tool_executor(&self) -> Arc<dyn ToolExecutor>
fn tool_executor(&self) -> Arc<dyn ToolExecutor>
Tool execution strategy (parallel, sequential, or custom).
Sourcefn behavior(&self) -> &dyn AgentBehavior
fn behavior(&self) -> &dyn AgentBehavior
The agent behavior (phase hooks) dispatched by the loop.
Provided Methods§
Sourcefn step_tool_provider(&self) -> Option<Arc<dyn StepToolProvider>>
fn step_tool_provider(&self) -> Option<Arc<dyn StepToolProvider>>
Optional per-step tool provider.
When None, the loop uses a static provider derived from the tool map.
Sourcefn llm_executor(&self) -> Option<Arc<dyn LlmExecutor>>
fn llm_executor(&self) -> Option<Arc<dyn LlmExecutor>>
Optional LLM executor override.
When None, the loop uses GenaiLlmExecutor with Client::default().
Sourcefn action_deserializer_registry(&self) -> Arc<ActionDeserializerRegistry>
fn action_deserializer_registry(&self) -> Arc<ActionDeserializerRegistry>
Registry for deserializing pending-write actions during crash recovery.