Skip to main content

BaseAgent

Struct BaseAgent 

Source
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 state_action_deserializer_registry: Arc<StateActionDeserializerRegistry>,
}
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: String

Unique identifier for this agent.

§model: String

Model identifier (e.g., “gpt-4”, “claude-3-opus”).

§system_prompt: String

System prompt for the LLM.

§max_rounds: usize

Optional 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: LlmRetryPolicy

Retry 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.

§state_action_deserializer_registry: Arc<StateActionDeserializerRegistry>

Registry for deserializing persisted state-action intents during crash recovery.

Implementations§

Source§

impl BaseAgent

Source

pub fn new(model: impl Into<String>) -> Self

Create a new instance with the given model id.

Source

pub fn with_id(id: impl Into<String>, model: impl Into<String>) -> Self

Create a new instance with explicit id and model.

Source

pub fn with_system_prompt(self, prompt: impl Into<String>) -> Self

Set system prompt.

Source

pub fn with_max_rounds(self, max_rounds: usize) -> Self

Set max rounds.

Source

pub fn with_chat_options(self, options: ChatOptions) -> Self

Set chat options.

Source

pub fn with_fallback_models(self, models: Vec<String>) -> Self

Set fallback model ids to try after the primary model.

Source

pub fn with_fallback_model(self, model: impl Into<String>) -> Self

Add a single fallback model id.

Source

pub fn with_llm_retry_policy(self, policy: LlmRetryPolicy) -> Self

Set LLM retry policy.

Source

pub fn with_tool_executor(self, executor: Arc<dyn ToolExecutor>) -> Self

Set tool executor strategy.

Source

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.

Source

pub fn with_step_tool_provider( self, provider: Arc<dyn StepToolProvider>, ) -> Self

Set per-step tool provider.

Source

pub fn with_llm_executor(self, executor: Arc<dyn LlmExecutor>) -> Self

Set LLM executor.

Source

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.

Source

pub fn has_behavior(&self) -> bool

Check if any behavior is configured.

Trait Implementations§

Source§

impl Agent for BaseAgent

Source§

fn id(&self) -> &str

Unique identifier for this agent.
Source§

fn model(&self) -> &str

Model identifier (e.g., “gpt-4”, “claude-3-opus”).
Source§

fn system_prompt(&self) -> &str

System prompt for the LLM.
Source§

fn max_rounds(&self) -> usize

Loop-budget hint (core loop does not enforce this directly).
Source§

fn chat_options(&self) -> Option<&ChatOptions>

Chat options for the LLM.
Source§

fn fallback_models(&self) -> &[String]

Fallback model ids used when the primary model fails.
Source§

fn llm_retry_policy(&self) -> &LlmRetryPolicy

Retry policy for LLM inference failures.
Source§

fn tool_executor(&self) -> Arc<dyn ToolExecutor>

Tool execution strategy (parallel, sequential, or custom).
Source§

fn step_tool_provider(&self) -> Option<Arc<dyn StepToolProvider>>

Optional per-step tool provider. Read more
Source§

fn llm_executor(&self) -> Option<Arc<dyn LlmExecutor>>

Optional LLM executor override. Read more
Source§

fn behavior(&self) -> &dyn AgentBehavior

The agent behavior (phase hooks) dispatched by the loop.
Source§

fn state_action_deserializer_registry( &self, ) -> Arc<StateActionDeserializerRegistry>

Registry for deserializing persisted state-action intents during crash recovery.
Source§

impl Clone for BaseAgent

Source§

fn clone(&self) -> BaseAgent

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BaseAgent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for BaseAgent

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more