pub struct Agent { /* private fields */ }Expand description
An agent: a harness and its conversation. Each Agent::run is one turn
that continues the conversation.
Implementations§
Source§impl Agent
impl Agent
pub fn builder() -> AgentBuilder
Sourcepub async fn run(
&mut self,
turn: impl Into<Turn>,
) -> Result<RunResult, RunError>
pub async fn run( &mut self, turn: impl Into<Turn>, ) -> Result<RunResult, RunError>
Run one turn: a goal, or a Turn.
Sourcepub async fn run_with_events(
&mut self,
turn: impl Into<Turn>,
on_event: impl FnMut(TurnEvent<'_>),
) -> Result<RunResult, RunError>
pub async fn run_with_events( &mut self, turn: impl Into<Turn>, on_event: impl FnMut(TurnEvent<'_>), ) -> Result<RunResult, RunError>
Agent::run, reporting each TurnEvent (text, reasoning, tool calls
and their results, usage) as it happens.
Sourcepub fn cancel_handle(&self) -> CancelToken
pub fn cancel_handle(&self) -> CancelToken
A handle that stops the running turn at its next safe point (before a model call, while streaming, or between tool calls), from any thread.
Sourcepub fn conversation(&self) -> &Conversation
pub fn conversation(&self) -> &Conversation
The conversation so far, to read or to save with Conversation::to_json.
Sourcepub fn with_conversation(self, conversation: Conversation) -> Self
pub fn with_conversation(self, conversation: Conversation) -> Self
Continue an earlier conversation instead of starting a new one.
Sourcepub fn session_id(&self) -> &str
pub fn session_id(&self) -> &str
The session’s id, under which AgentBuilder::memory saves it.
Sourcepub fn secret_names(&self) -> Vec<String>
pub fn secret_names(&self) -> Vec<String>
The names of the secrets held, never their values.
Sourcepub fn notes(&self) -> Vec<String>
pub fn notes(&self) -> Vec<String>
What is worth telling the user, oldest first: specialist files that were skipped, what the MCP servers reported (a server that dropped, reconnected, or changed its tools), and why spans could not be exported.
Sourcepub fn skills(&self) -> Vec<String>
pub fn skills(&self) -> Vec<String>
The skills Turn::skill can run, in precedence order.
Sourcepub fn specialists(&self) -> Vec<String>
pub fn specialists(&self) -> Vec<String>
The specialists Turn::specialist and delegate can run.
Sourcepub fn tool_names(&self) -> Vec<String>
pub fn tool_names(&self) -> Vec<String>
The names of the tools the model is offered.
Auto Trait Implementations§
impl !Freeze for Agent
impl !RefUnwindSafe for Agent
impl !UnwindSafe for Agent
impl Forget for Agent
impl Move 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
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