Skip to main content

OwnedToolLoopHandle

Struct OwnedToolLoopHandle 

Source
pub struct OwnedToolLoopHandle<Ctx: LoopDepth + Send + Sync + 'static> { /* private fields */ }
Expand description

Arc-owned resumable tool loop.

Identical in behavior to ToolLoopHandle but owns provider and registry via Arc, making it Send + 'static.

§Lifecycle

Same as ToolLoopHandle:

  1. Create with new()
  2. Call next_turn()
  3. If Yielded, consume via resume() / continue_loop() / etc.
  4. Repeat until Completed or Error
  5. Optionally call into_result()

Implementations§

Source§

impl<Ctx: LoopDepth + Send + Sync + 'static> OwnedToolLoopHandle<Ctx>

Source

pub fn new( provider: Arc<dyn DynProvider>, registry: Arc<ToolRegistry<Ctx>>, params: ChatParams, config: ToolLoopConfig, ctx: &Ctx, ) -> Self

Create a new owned resumable tool loop.

Takes Arc-wrapped provider and registry so the handle can be moved into tokio::spawn.

Source

pub async fn next_turn(&mut self) -> OwnedTurnResult<'_, Ctx>

Advance the loop and return the result of this turn.

Identical semantics to ToolLoopHandle::next_turn().

Source

pub fn resume(&mut self, command: LoopCommand)

Tell the loop how to proceed before the next next_turn() call.

Source

pub fn messages(&self) -> &[ChatMessage]

Get a snapshot of the current conversation messages.

Source

pub fn messages_mut(&mut self) -> &mut Vec<ChatMessage>

Get a mutable reference to the conversation messages.

Source

pub fn total_usage(&self) -> &Usage

Get the accumulated usage across all iterations so far.

Source

pub fn iterations(&self) -> u32

Get the current iteration count.

Source

pub fn is_finished(&self) -> bool

Whether the loop has finished (returned Completed or Error).

Source

pub fn drain_events(&mut self) -> Vec<LoopEvent>

Drain any remaining buffered LoopEvents.

See ToolLoopHandle::drain_events for full documentation.

Source

pub fn into_result(self) -> ToolLoopResult

Consume the handle and return a ToolLoopResult.

Trait Implementations§

Source§

impl<Ctx: LoopDepth + Send + Sync + 'static> Debug for OwnedToolLoopHandle<Ctx>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Ctx> Freeze for OwnedToolLoopHandle<Ctx>
where Ctx: Freeze,

§

impl<Ctx> !RefUnwindSafe for OwnedToolLoopHandle<Ctx>

§

impl<Ctx> Send for OwnedToolLoopHandle<Ctx>

§

impl<Ctx> Sync for OwnedToolLoopHandle<Ctx>

§

impl<Ctx> Unpin for OwnedToolLoopHandle<Ctx>
where Ctx: Unpin,

§

impl<Ctx> !UnwindSafe for OwnedToolLoopHandle<Ctx>

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<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: 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: 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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