pub struct Agent { /* private fields */ }Implementations§
Source§impl Agent
impl Agent
pub fn new( transport: Arc<dyn ProviderTransport>, tools: Arc<ToolRegistry>, memory: Arc<dyn MemoryStore>, config: Arc<AgentConfig>, ) -> Self
pub fn with_session_db(self, db: Arc<SessionDb>) -> Self
pub fn with_hooks(self, hooks: impl AgentHooks) -> Self
pub fn tools(&self) -> &ToolRegistry
pub fn has_tool(&self, name: &str) -> bool
pub fn tool_count(&self) -> usize
pub fn tool_names(&self) -> Vec<String>
pub fn tool_names_by_toolset(&self) -> BTreeMap<String, Vec<String>>
pub fn spawn_child(&self) -> Self
Sourcepub fn clear_session(&self, session_key: &str)
pub fn clear_session(&self, session_key: &str)
Clear the stored conversation history for a platform session (e.g. on /new or /clear). Removes both the in-memory cache and the on-disk file, and clears any active goal.
pub async fn set_goal(&self, session_key: &str, goal: &str) -> Result<()>
pub async fn get_goal(&self, session_key: &str) -> Option<String>
pub async fn clear_goal(&self, session_key: &str)
Sourcepub fn history_pairs(&self, session_key: &str) -> Vec<(String, String)>
pub fn history_pairs(&self, session_key: &str) -> Vec<(String, String)>
Prior (user, assistant) conversation pairs for a session — warm cache first, disk fallback on miss. Lets an embedding app (e.g. the desktop) repopulate the chat view on launch from the same store the agent uses.
Sourcepub fn inject_history(
&self,
session_key: &str,
user_msg: &str,
assistant_msg: &str,
)
pub fn inject_history( &self, session_key: &str, user_msg: &str, assistant_msg: &str, )
Inject a (user, assistant) pair directly into conversation history without running the agent. Used by GatewayHandler to silently store image descriptions.
Sourcepub fn update_last_history(&self, session_key: &str, new_assistant: &str)
pub fn update_last_history(&self, session_key: &str, new_assistant: &str)
Update the assistant content of the most recently injected history pair. Used to replace a placeholder description with the actual view_image result after the (potentially slow) tool call completes.
Sourcepub async fn run_tool(&self, name: &str, args: Value) -> String
pub async fn run_tool(&self, name: &str, args: Value) -> String
Call a single registered tool by name and return its output as a plain string. Intended for server-side preprocessing (e.g. gateway image pipeline) where the result must be available before the agent loop runs. Returns the tool’s content on success, or an error description on failure.
Sourcepub async fn run_tool_scoped(
&self,
name: &str,
args: Value,
conv_key: &str,
) -> String
pub async fn run_tool_scoped( &self, name: &str, args: Value, conv_key: &str, ) -> String
Like run_tool but sets conv_key so storage-scoped tools (e.g.
doc_ingest, doc_search) operate on the correct conversation bucket.
pub async fn run( &self, task: &str, approver: Arc<dyn CommandApprover>, platform: &str, hint: Option<&str>, session_key: Option<&str>, ) -> Result<AgentResult, AgentError>
pub async fn run_for_user( &self, task: &str, approver: Arc<dyn CommandApprover>, platform: &str, hint: Option<&str>, session_key: Option<&str>, user_id: &str, ) -> Result<AgentResult, AgentError>
pub async fn run_streaming( &self, task: &str, approver: Arc<dyn CommandApprover>, platform: &str, chunk_tx: UnboundedSender<String>, tool_tx: Option<UnboundedSender<String>>, hint: Option<&str>, session_key: Option<&str>, ) -> Result<AgentResult, AgentError>
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Agent
impl !UnwindSafe for Agent
impl Freeze for Agent
impl Send for Agent
impl Sync for Agent
impl Unpin for Agent
impl UnsafeUnpin for Agent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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