Skip to main content

AgentCall

Struct AgentCall 

Source
pub struct AgentCall<O> {
    pub input: AgentInput,
    pub options: O,
    pub cancellation: CancellationToken,
    pub timeout: Option<Timeout>,
    pub hooks: Hooks,
    pub sandbox: Option<Arc<dyn Sandbox>>,
}
Expand description

Parameters of one agent call.

Fields§

§input: AgentInput

The input.

§options: O

Per-call options.

§cancellation: CancellationToken

Cancels the call.

§timeout: Option<Timeout>

Overrides the agent’s timeouts when set.

§hooks: Hooks

Hooks invoked after the agent’s own hooks, then awaited concurrently.

§sandbox: Option<Arc<dyn Sandbox>>

Sandbox passed to tools.

Implementations§

Source§

impl AgentCall<()>

Source

pub fn new(input: impl Into<AgentInput>) -> Self

A call without options.

Source

pub fn prompt(text: impl Into<String>) -> Self

A call with a single user prompt.

Source

pub fn messages(messages: impl IntoIterator<Item = Message>) -> Self

A call with a conversation.

Source§

impl<O> AgentCall<O>

Source

pub fn options<P>(self, options: P) -> AgentCall<P>

Sets the per-call options.

Source

pub fn cancellation(self, token: CancellationToken) -> Self

Sets the cancellation token.

Source

pub fn timeout(self, timeout: impl Into<Timeout>) -> Self

Overrides the agent’s timeouts.

Source

pub fn hooks(self, hooks: Hooks) -> Self

Adds hooks (invoked after the agent’s hooks, awaited concurrently).

Source

pub fn on_step_end(self, f: impl HookFn<StepResult>) -> Self

Adds a step-end hook.

Source

pub fn on_end(self, f: impl HookFn<EndEvent>) -> Self

Adds an end hook.

Source

pub fn sandbox(self, sandbox: Arc<dyn Sandbox>) -> Self

Sets the sandbox passed to tools.

Source

pub fn streaming(self) -> AgentStreamCall<O>

Converts into a streaming call.

Trait Implementations§

Source§

impl<O: Debug> Debug for AgentCall<O>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<O> From<AgentCall<O>> for AgentStreamCall<O>

Source§

fn from(call: AgentCall<O>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<O> !RefUnwindSafe for AgentCall<O>

§

impl<O> !UnwindSafe for AgentCall<O>

§

impl<O> Freeze for AgentCall<O>
where O: Freeze,

§

impl<O> Send for AgentCall<O>
where O: Send,

§

impl<O> Sync for AgentCall<O>
where O: Sync,

§

impl<O> Unpin for AgentCall<O>
where O: Unpin,

§

impl<O> UnsafeUnpin for AgentCall<O>
where O: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more