pub struct Agent { /* private fields */ }Expand description
Runs turns on a Session.
Implementations§
Source§impl Agent
impl Agent
Sourcepub async fn prompt(
&self,
text: impl Into<String>,
) -> Result<AgentStream, AgentError>
pub async fn prompt( &self, text: impl Into<String>, ) -> Result<AgentStream, AgentError>
Run a text prompt and return a streaming iterator of AgentEvents.
The stream ends after a Done or Error event.
Sourcepub async fn prompt_message(
&self,
message: UserMessage,
) -> Result<AgentStream, AgentError>
pub async fn prompt_message( &self, message: UserMessage, ) -> Result<AgentStream, AgentError>
Run a prompt built from content blocks (text, images, …).
Dropping the stream before its Done/Error cancels the prompt:
still queued, it is withdrawn; running, its turn is interrupted.
Drain the stream to let the turn finish.
Sourcepub fn watch(&self) -> AgentStream
pub fn watch(&self) -> AgentStream
Every event of every turn from now on — prompted turns and the turns
the CLI starts itself (TurnResult::origin set), each ending with
Done or Error. Ends when the session closes. Dropping it cancels
nothing. Lossless like Session::subscribe: events buffer until
polled, so poll it or drop it.
Auto Trait Implementations§
impl !RefUnwindSafe for Agent
impl !UnwindSafe for Agent
impl Forget for Agent
impl Freeze 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
Mutably borrows from an owned value. Read more