pub struct Agent { /* private fields */ }Expand description
Main Agent orchestrator
The Agent coordinates model calls, memory, tools, and sub-agents. It matches the structure from go-agent’s Agent struct.
Implementations§
Source§impl Agent
impl Agent
Sourcepub fn new(
model: Arc<dyn LLM>,
memory: Arc<SessionMemory>,
options: AgentOptions,
) -> Self
pub fn new( model: Arc<dyn LLM>, memory: Arc<SessionMemory>, options: AgentOptions, ) -> Self
Creates a new Agent with the given configuration
Sourcepub fn with_system_prompt(self, prompt: impl Into<String>) -> Self
pub fn with_system_prompt(self, prompt: impl Into<String>) -> Self
Sets the system prompt
Sourcepub fn with_tools(self, catalog: Arc<ToolCatalog>) -> Self
pub fn with_tools(self, catalog: Arc<ToolCatalog>) -> Self
Sets the tool catalog
Sourcepub fn with_codemode(self, engine: Arc<CodeModeUtcp>) -> Self
pub fn with_codemode(self, engine: Arc<CodeModeUtcp>) -> Self
Enables CodeMode execution as a first-class tool (codemode.run_code).
Sourcepub fn with_codemode_orchestrator(
self,
engine: Arc<CodeModeUtcp>,
orchestrator_model: Option<Arc<dyn LLM>>,
) -> Self
pub fn with_codemode_orchestrator( self, engine: Arc<CodeModeUtcp>, orchestrator_model: Option<Arc<dyn LLM>>, ) -> Self
Enables CodeMode plus the Codemode orchestrator for automatic tool routing.
If orchestrator_model is None, the primary agent model is reused.
Sourcepub async fn register_utcp_provider(
&self,
client: Arc<dyn UtcpClientInterface>,
provider: Arc<dyn UtcpProvider>,
) -> Result<Vec<UtcpTool>>
pub async fn register_utcp_provider( &self, client: Arc<dyn UtcpClientInterface>, provider: Arc<dyn UtcpProvider>, ) -> Result<Vec<UtcpTool>>
Registers a UTCP provider and loads its tools into the agent’s catalog.
Sourcepub async fn register_utcp_provider_with_tools(
&self,
client: Arc<dyn UtcpClientInterface>,
provider: Arc<dyn UtcpProvider>,
tools: Vec<UtcpTool>,
) -> Result<Vec<UtcpTool>>
pub async fn register_utcp_provider_with_tools( &self, client: Arc<dyn UtcpClientInterface>, provider: Arc<dyn UtcpProvider>, tools: Vec<UtcpTool>, ) -> Result<Vec<UtcpTool>>
Registers a UTCP provider using a predefined set of tools and adds them to the catalog.
Sourcepub fn register_utcp_tools(
&self,
client: Arc<dyn UtcpClientInterface>,
tools: Vec<UtcpTool>,
) -> Result<()>
pub fn register_utcp_tools( &self, client: Arc<dyn UtcpClientInterface>, tools: Vec<UtcpTool>, ) -> Result<()>
Registers UTCP tools into the agent’s catalog without re-registering the provider.
Sourcepub fn as_utcp_tool(
&self,
name: impl Into<String>,
description: impl Into<String>,
) -> UtcpTool
pub fn as_utcp_tool( &self, name: impl Into<String>, description: impl Into<String>, ) -> UtcpTool
Returns a UTCP tool specification representing this agent as an in-process tool.
Sourcepub async fn register_as_utcp_provider(
self: Arc<Self>,
utcp_client: &dyn UtcpClientInterface,
name: impl Into<String>,
description: impl Into<String>,
) -> Result<()>
pub async fn register_as_utcp_provider( self: Arc<Self>, utcp_client: &dyn UtcpClientInterface, name: impl Into<String>, description: impl Into<String>, ) -> Result<()>
Registers this agent as a UTCP provider using an in-process CLI shim.
Sourcepub async fn generate(
&self,
session_id: impl Into<String>,
user_input: impl Into<String>,
) -> Result<String>
pub async fn generate( &self, session_id: impl Into<String>, user_input: impl Into<String>, ) -> Result<String>
Generates a response for the given user input, encoded as TOON
Sourcepub async fn generate_with_files(
&self,
session_id: impl Into<String>,
user_input: impl Into<String>,
files: Vec<File>,
) -> Result<String>
pub async fn generate_with_files( &self, session_id: impl Into<String>, user_input: impl Into<String>, files: Vec<File>, ) -> Result<String>
Generates a response with file attachments
Sourcepub async fn generate_stream(
&self,
session_id: impl Into<String>,
user_input: impl Into<String>,
) -> Result<BoxStream<'static, Result<GenerationChunk>>>
pub async fn generate_stream( &self, session_id: impl Into<String>, user_input: impl Into<String>, ) -> Result<BoxStream<'static, Result<GenerationChunk>>>
Generates a streaming response
Sourcepub async fn invoke_tool(
&self,
session_id: impl Into<String>,
tool_name: &str,
arguments: HashMap<String, Value>,
) -> Result<String>
pub async fn invoke_tool( &self, session_id: impl Into<String>, tool_name: &str, arguments: HashMap<String, Value>, ) -> Result<String>
Invokes a tool by name
Sourcepub fn tools(&self) -> Arc<ToolCatalog>
pub fn tools(&self) -> Arc<ToolCatalog>
Returns the tool catalog
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<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> 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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request