Skip to main content

Agent

Struct Agent 

Source
pub struct Agent<C, T, S>{
    pub pending_skill_references: Option<Vec<SkillKey>>,
    /* private fields */
}
Expand description

The main Agent struct

Fields§

§pending_skill_references: Option<Vec<SkillKey>>

Skill references to resolve and inject for the next turn. Set by surfaces before calling run(), consumed on run start.

Implementations§

Source§

impl<C, T, S> Agent<C, T, S>
where C: AgentLlmClient + ?Sized + 'static, T: AgentToolDispatcher + ?Sized + 'static, S: AgentSessionStore + ?Sized + 'static,

Source

pub fn comms(&self) -> Option<&dyn CommsRuntime>

Get the comms runtime, if enabled.

Source

pub fn comms_arc(&self) -> Option<Arc<dyn CommsRuntime>>

Get a shared handle to the comms runtime, if enabled.

Source§

impl<C, T, S> Agent<C, T, S>

Source

pub fn stage_external_tool_filter( &mut self, filter: ToolFilter, ) -> Result<ToolScopeRevision, ToolScopeStageError>

Stage an external tool visibility filter update for subsequent turns.

Source

pub fn set_flow_tool_overlay( &mut self, overlay: Option<TurnToolOverlay>, ) -> Result<(), ToolScopeStageError>

Set or clear a per-turn flow tool overlay.

Source

pub fn set_mob_authority_handle( &mut self, handle: Arc<RwLock<MobToolAuthorityContext>>, )

Set the shared mob authority handle for session-effect application.

The agent updates this handle after merging SessionEffects from tool dispatch. Mob tools read from it for authorization checks.

Source

pub fn replace_client(&mut self, client: Arc<C>)

Replace the LLM client for subsequent turns.

Enables hot-swapping the model/provider on a live session without rebuilding the agent. The new client takes effect on the next run() / run_with_events() call.

Source§

impl<C, T, S> Agent<C, T, S>
where C: AgentLlmClient + ?Sized + 'static, T: AgentToolDispatcher + ?Sized + 'static, S: AgentSessionStore + ?Sized + 'static,

Source

pub fn builder() -> AgentBuilder

Create a new agent builder

Source

pub fn session(&self) -> &Session

Get the current session

Source

pub fn session_mut(&mut self) -> &mut Session

Get mutable access to the session (for setting metadata)

Source

pub fn budget(&self) -> &Budget

Get the current budget

Source

pub fn state(&self) -> &LoopState

Get the current state

Source

pub fn retry_policy(&self) -> &RetryPolicy

Get the retry policy

Source

pub fn depth(&self) -> u32

Get the current nesting depth

Source

pub fn event_tap(&self) -> &EventTap

Get the event tap for interaction-scoped streaming.

Source

pub fn tool_scope(&self) -> &ToolScope

Access the live tool-scope projection bridge.

Source

pub fn system_context_state(&self) -> Arc<Mutex<SessionSystemContextState>>

Get shared runtime system-context control state.

Source

pub fn session_with_system_context_state(&self) -> Session

Clone the current session with the latest shared system-context state merged into metadata.

Source

pub async fn run( &mut self, user_input: ContentInput, ) -> Result<RunResult, AgentError>

Run the agent with a user message.

Source

pub async fn run_with_events( &mut self, user_input: ContentInput, event_tx: Sender<AgentEvent>, ) -> Result<RunResult, AgentError>

Run the agent with events streamed to the provided channel.

Source

pub async fn run_pending(&mut self) -> Result<RunResult, AgentError>

Run the agent using the pending continuation boundary already in the session.

This is useful when the session has been pre-populated with a continuation boundary (for example a deferred first-turn user message or staged callback tool results). Unlike run(), this method does NOT add a new user message; it runs directly from the session’s current state.

Returns an error if the session doesn’t end at a resumable continuation boundary (User or ToolResults).

Source

pub async fn run_pending_with_events( &mut self, event_tx: Sender<AgentEvent>, ) -> Result<RunResult, AgentError>

Run the agent using the pending continuation boundary, with event streaming.

Like run_pending(), but emits events to the provided channel.

Source

pub fn cancel(&mut self)

Cancel the current run

Auto Trait Implementations§

§

impl<C, T, S> !Freeze for Agent<C, T, S>

§

impl<C, T, S> !RefUnwindSafe for Agent<C, T, S>

§

impl<C, T, S> Send for Agent<C, T, S>
where C: ?Sized, T: ?Sized, S: ?Sized,

§

impl<C, T, S> Sync for Agent<C, T, S>
where C: ?Sized, T: ?Sized, S: ?Sized,

§

impl<C, T, S> Unpin for Agent<C, T, S>
where C: ?Sized, T: ?Sized, S: ?Sized,

§

impl<C, T, S> UnsafeUnpin for Agent<C, T, S>
where C: ?Sized, T: ?Sized, S: ?Sized,

§

impl<C, T, S> !UnwindSafe for Agent<C, T, S>

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> 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, 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