pub struct BaseAgent {Show 14 fields
pub id: String,
pub model: String,
pub system_prompt: String,
pub max_rounds: usize,
pub tool_executor: Arc<dyn ToolExecutor>,
pub chat_options: Option<ChatOptions>,
pub fallback_models: Vec<String>,
pub llm_retry_policy: LlmRetryPolicy,
pub behavior: Arc<dyn AgentBehavior>,
pub lattice_registry: Arc<LatticeRegistry>,
pub state_scope_registry: Arc<StateScopeRegistry>,
pub step_tool_provider: Option<Arc<dyn StepToolProvider>>,
pub llm_executor: Option<Arc<dyn LlmExecutor>>,
pub action_deserializer_registry: Arc<ActionDeserializerRegistry>,
}Expand description
Standard Agent implementation.
Bundles all configuration and behavior for running an agent loop.
Constructed by AgentOS from an AgentDefinition, or directly for tests.
Fields§
§id: StringUnique identifier for this agent.
model: StringModel identifier (e.g., “gpt-4”, “claude-3-opus”).
system_prompt: StringSystem prompt for the LLM.
max_rounds: usizeOptional loop-budget hint (core loop does not enforce this directly).
tool_executor: Arc<dyn ToolExecutor>Tool execution strategy (parallel, sequential, or custom).
chat_options: Option<ChatOptions>Chat options for the LLM.
fallback_models: Vec<String>Fallback model ids used when the primary model fails.
llm_retry_policy: LlmRetryPolicyRetry policy for LLM inference failures.
behavior: Arc<dyn AgentBehavior>Agent behavior (declarative model).
lattice_registry: Arc<LatticeRegistry>Lattice registry for CRDT-aware conflict resolution.
state_scope_registry: Arc<StateScopeRegistry>State scope registry mapping StateSpec types to their declared scopes.
step_tool_provider: Option<Arc<dyn StepToolProvider>>Optional per-step tool provider.
llm_executor: Option<Arc<dyn LlmExecutor>>Optional LLM executor override.
action_deserializer_registry: Arc<ActionDeserializerRegistry>Registry for deserializing pending-write actions during crash recovery.
Implementations§
Source§impl BaseAgent
impl BaseAgent
Sourcepub fn with_id(id: impl Into<String>, model: impl Into<String>) -> Self
pub fn with_id(id: impl Into<String>, model: impl Into<String>) -> Self
Create a new instance with explicit id and model.
Sourcepub fn with_system_prompt(self, prompt: impl Into<String>) -> Self
pub fn with_system_prompt(self, prompt: impl Into<String>) -> Self
Set system prompt.
Sourcepub fn with_max_rounds(self, max_rounds: usize) -> Self
pub fn with_max_rounds(self, max_rounds: usize) -> Self
Set max rounds.
Sourcepub fn with_chat_options(self, options: ChatOptions) -> Self
pub fn with_chat_options(self, options: ChatOptions) -> Self
Set chat options.
Sourcepub fn with_fallback_models(self, models: Vec<String>) -> Self
pub fn with_fallback_models(self, models: Vec<String>) -> Self
Set fallback model ids to try after the primary model.
Sourcepub fn with_fallback_model(self, model: impl Into<String>) -> Self
pub fn with_fallback_model(self, model: impl Into<String>) -> Self
Add a single fallback model id.
Sourcepub fn with_llm_retry_policy(self, policy: LlmRetryPolicy) -> Self
pub fn with_llm_retry_policy(self, policy: LlmRetryPolicy) -> Self
Set LLM retry policy.
Sourcepub fn with_tool_executor(self, executor: Arc<dyn ToolExecutor>) -> Self
pub fn with_tool_executor(self, executor: Arc<dyn ToolExecutor>) -> Self
Set tool executor strategy.
Sourcepub fn with_tools(self, tools: HashMap<String, Arc<dyn Tool>>) -> Self
pub fn with_tools(self, tools: HashMap<String, Arc<dyn Tool>>) -> Self
Set static tool map (wraps in [StaticStepToolProvider]).
Prefer passing tools directly to [run_loop] / [run_loop_stream];
use this only when you need to set tools via step_tool_provider.
Sourcepub fn with_step_tool_provider(
self,
provider: Arc<dyn StepToolProvider>,
) -> Self
pub fn with_step_tool_provider( self, provider: Arc<dyn StepToolProvider>, ) -> Self
Set per-step tool provider.
Sourcepub fn with_llm_executor(self, executor: Arc<dyn LlmExecutor>) -> Self
pub fn with_llm_executor(self, executor: Arc<dyn LlmExecutor>) -> Self
Set LLM executor.
Sourcepub fn with_behavior(self, behavior: Arc<dyn AgentBehavior>) -> Self
pub fn with_behavior(self, behavior: Arc<dyn AgentBehavior>) -> Self
Set the agent behavior (declarative model), replacing any existing behavior.
The loop dispatches all phase hooks exclusively through this behavior.
Sourcepub fn has_behavior(&self) -> bool
pub fn has_behavior(&self) -> bool
Check if any behavior is configured.