pub struct Agent { /* private fields */ }Implementations§
Source§impl Agent
impl Agent
Sourcepub fn new(model: &str, max_turns: u32) -> Self
pub fn new(model: &str, max_turns: u32) -> Self
Create a new agent with model name and max turns
Sourcepub fn with_event_callback<F>(model: &str, max_turns: u32, on_event: F) -> Self
pub fn with_event_callback<F>(model: &str, max_turns: u32, on_event: F) -> Self
Create a new agent with model, max turns, and event callback for streaming
Sourcepub fn create(options: AgentOptions) -> Self
pub fn create(options: AgentOptions) -> Self
Create agent from AgentOptions
pub fn get_model(&self) -> &str
pub fn get_session_id(&self) -> &str
Sourcepub fn get_messages(&self) -> &[Message]
pub fn get_messages(&self) -> &[Message]
Get all messages in the conversation history
Sourcepub fn get_tools(&self) -> &[ToolDefinition]
pub fn get_tools(&self) -> &[ToolDefinition]
Get all tools available to the agent
Sourcepub fn set_system_prompt(&mut self, prompt: &str)
pub fn set_system_prompt(&mut self, prompt: &str)
Set system prompt for the agent
Sourcepub fn set_event_callback<F>(&mut self, callback: F)
pub fn set_event_callback<F>(&mut self, callback: F)
Set the event callback for agent events (tool start/complete/error, thinking, done) Note: This must be called BEFORE query() - it sets the callback on the engine
Sourcepub async fn execute_tool(
&mut self,
name: &str,
input: Value,
) -> Result<ToolResult, AgentError>
pub async fn execute_tool( &mut self, name: &str, input: Value, ) -> Result<ToolResult, AgentError>
Execute a tool directly (for testing/demo purposes)
Sourcepub async fn prompt(&mut self, prompt: &str) -> Result<QueryResult, AgentError>
pub async fn prompt(&mut self, prompt: &str) -> Result<QueryResult, AgentError>
Simple blocking prompt method - sends a prompt and returns the result. This matches the TypeScript SDK’s agent.prompt() API.
pub async fn query(&mut self, prompt: &str) -> Result<QueryResult, AgentError>
Trait Implementations§
Source§impl From<AgentOptions> for Agent
impl From<AgentOptions> for Agent
Source§fn from(options: AgentOptions) -> Self
fn from(options: AgentOptions) -> Self
Converts to this type from the input type.
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> 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
Mutably borrows from an owned value. Read more