Skip to main content

Agent

Struct Agent 

pub struct Agent { /* private fields */ }

Implementations§

Source§

impl Agent

Source

pub fn builder() -> AgentBuilder

Source

pub fn set_channel_name(&mut self, name: String)

Source

pub fn history(&self) -> &[ConversationMessage]

Source

pub fn channel_handles(&self) -> &AgentChannelHandles

Source

pub fn populate_channels( &self, channel_map: &HashMap<String, Arc<dyn Channel>>, ) -> Vec<String>

Source

pub fn attribution_fields(&self) -> (String, String, String)

Attribution fields for opening a turn span at external call sites (ACP, gateway WS) so every record inside a streamed turn carries the same agent_alias/model_provider/model the RPC dispatch path sets. Returns (agent_alias, model_provider, model).

Source

pub fn clear_history(&mut self)

Source

pub fn set_memory_session_id(&mut self, session_id: Option<String>)

Source

pub fn set_temperature(&mut self, temperature: Option<f64>)

Source

pub fn refresh_memory_embedder( &self, model_provider: &str, api_key: Option<&str>, model: &str, dimensions: usize, )

Source

pub fn set_model_name(&mut self, model_name: String)

Source

pub fn set_model_provider(&mut self, model_provider: Box<dyn ModelProvider>)

Source

pub fn set_model_provider_name(&mut self, model_provider_name: String)

Source

pub fn set_tool_dispatcher(&mut self, tool_dispatcher: Box<dyn ToolDispatcher>)

Source

pub fn seed_history(&mut self, messages: &[ChatMessage])

Source

pub fn seed_history_with_event( &mut self, messages: &[ChatMessage], ) -> Option<TurnEvent>

Hydrate prior chat messages and return a transport event when restoring the history enforces the structured message cap.

Source

pub fn seed_conversation_history(&mut self, messages: Vec<ConversationMessage>)

Hydrate the agent with a full ConversationMessage history (e.g. restored from an ACP session store). Preserves all variants including AssistantToolCalls and ToolResults — use this for ACP restore; use seed_history for flat channel session hydration.

Source

pub fn seed_conversation_history_with_event( &mut self, messages: Vec<ConversationMessage>, ) -> Option<TurnEvent>

Hydrate structured conversation history and return a transport event when restoring the history enforces the structured message cap.

Source

pub async fn from_config( config: &Config, agent_alias: &str, ) -> Result<Agent, Error>

Source

pub async fn from_config_with_session_cwd( config: &Config, agent_alias: &str, session_cwd: Option<&Path>, ) -> Result<Agent, Error>

Source

pub async fn from_config_with_session_cwd_and_mcp( config: &Config, agent_alias: &str, session_cwd: Option<&Path>, initialize_mcp: bool, ) -> Result<Agent, Error>

Source

pub async fn from_config_with_session_cwd_and_mcp_backchannel( config: &Config, agent_alias: &str, session_cwd: Option<&Path>, initialize_mcp: bool, exclude_memory: bool, sop_engine: Option<Arc<Mutex<SopEngine>>>, sop_audit: Option<Arc<SopAuditLogger>>, canvas_store: Option<CanvasStore>, ) -> Result<Agent, Error>

Source

pub async fn from_live_config_with_session_cwd_and_mcp_backchannel( live_config: Arc<RwLock<RawRwLock, Config>>, agent_alias: &str, session_cwd: Option<&Path>, initialize_mcp: bool, exclude_memory: bool, sop_engine: Option<Arc<Mutex<SopEngine>>>, sop_audit: Option<Arc<SopAuditLogger>>, canvas_store: Option<CanvasStore>, ) -> Result<Agent, Error>

Build a daemon-backed ACP/WS Agent whose structured-history cap follows the shared config after reloads.

Source

pub async fn from_config_with_tui_env( config: &Config, agent_alias: &str, session_cwd: Option<&Path>, initialize_mcp: bool, exclude_memory: bool, tui_env: Option<HashMap<String, String>>, sop_engine: Option<Arc<Mutex<SopEngine>>>, sop_audit: Option<Arc<SopAuditLogger>>, ) -> Result<Agent, Error>

Like Self::from_config_with_session_cwd_and_mcp_backchannel but also injects the TUI’s captured shell environment so that tools like ShellTool inherit the user’s real PATH, SSH_AUTH_SOCK, etc. rather than the daemon’s stripped-down process environment.

Source

pub async fn from_live_config_with_tui_env( live_config: Arc<RwLock<RawRwLock, Config>>, agent_alias: &str, session_cwd: Option<&Path>, initialize_mcp: bool, exclude_memory: bool, tui_env: Option<HashMap<String, String>>, sop_engine: Option<Arc<Mutex<SopEngine>>>, sop_audit: Option<Arc<SopAuditLogger>>, ) -> Result<Agent, Error>

Build a daemon-backed TUI Agent whose structured-history cap follows the shared config after reloads.

Source

pub async fn turn(&mut self, user_message: &str) -> Result<String, Error>

Source

pub async fn turn_streamed( &mut self, user_message: &str, event_tx: Sender<TurnEvent>, cancel_token: Option<CancellationToken>, ) -> Result<(String, Vec<ConversationMessage>), Error>

Source

pub async fn turn_streamed_with_steering_state( &mut self, user_message: &str, event_tx: Sender<TurnEvent>, cancel_token: Option<CancellationToken>, steering_rx: Option<&mut Receiver<String>>, ) -> Result<StreamedTurnSuccess, StreamedTurnError>

Source

pub async fn run_single(&mut self, message: &str) -> Result<String, Error>

Source

pub async fn run_interactive(&mut self) -> Result<(), Error>

Trait Implementations§

Source§

impl Drop for Agent

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl Freeze for Agent

§

impl !RefUnwindSafe for Agent

§

impl Send for Agent

§

impl Sync for Agent

§

impl Unpin for Agent

§

impl UnsafeUnpin for Agent

§

impl !UnwindSafe for Agent

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.

§

impl<T> Instrument for T

§

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

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

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

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

§

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
§

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> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,