pub struct Agent {
pub model: Model,
pub thinking_level: String,
pub tools: Vec<Arc<dyn AgentTool>>,
pub messages: Vec<AgentMessage>,
pub session_id: Option<String>,
pub error_message: Option<String>,
pub before_tool_call: Option<BeforeToolCall>,
/* private fields */
}Expand description
Agent: owns the transcript and tools, runs prompts through the loop, and keeps state from the events.
Fields§
§model: Model§thinking_level: String§tools: Vec<Arc<dyn AgentTool>>§messages: Vec<AgentMessage>§session_id: Option<String>§error_message: Option<String>§before_tool_call: Option<BeforeToolCall>Implementations§
Source§impl Agent
impl Agent
pub fn new(options: AgentOptions, stream_fn: Box<dyn StreamFn>) -> Self
pub fn control(&self) -> AgentControl
pub fn subscribe(&mut self, listener: impl FnMut(&AgentEvent) + Send + 'static)
pub async fn prompt_text(&mut self, text: &str, images: Vec<ImageContent>)
Sourcepub fn final_text(&self) -> Result<String, String>
pub fn final_text(&self) -> Result<String, String>
The run’s reply: the text of the transcript’s last assistant message; Err when that message failed or was
aborted (its error), or there is none.
Sourcepub async fn prompt(&mut self, messages: Vec<AgentMessage>)
pub async fn prompt(&mut self, messages: Vec<AgentMessage>)
Run the loop over messages; returns when the run ends (agent_end).
Auto Trait Implementations§
impl !RefUnwindSafe for Agent
impl !Sync for Agent
impl !UnwindSafe for Agent
impl Forget for Agent
impl Freeze for Agent
impl Move for Agent
impl Send 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
Mutably borrows from an owned value. Read more