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:
- Create with
new() - Call
next_turn() - If
Yielded, consume viaresume()/continue_loop()/ etc. - Repeat until
CompletedorError - Optionally call
into_result()
Implementations§
Source§impl<Ctx: LoopDepth + Send + Sync + 'static> OwnedToolLoopHandle<Ctx>
impl<Ctx: LoopDepth + Send + Sync + 'static> OwnedToolLoopHandle<Ctx>
Sourcepub fn new(
provider: Arc<dyn DynProvider>,
registry: Arc<ToolRegistry<Ctx>>,
params: ChatParams,
config: ToolLoopConfig,
ctx: &Ctx,
) -> Self
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.
Sourcepub async fn next_turn(&mut self) -> OwnedTurnResult<'_, Ctx>
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().
Sourcepub fn resume(&mut self, command: LoopCommand)
pub fn resume(&mut self, command: LoopCommand)
Tell the loop how to proceed before the next next_turn() call.
Sourcepub fn messages(&self) -> &[ChatMessage]
pub fn messages(&self) -> &[ChatMessage]
Get a snapshot of the current conversation messages.
Sourcepub fn messages_mut(&mut self) -> &mut Vec<ChatMessage>
pub fn messages_mut(&mut self) -> &mut Vec<ChatMessage>
Get a mutable reference to the conversation messages.
Sourcepub fn total_usage(&self) -> &Usage
pub fn total_usage(&self) -> &Usage
Get the accumulated usage across all iterations so far.
Sourcepub fn iterations(&self) -> u32
pub fn iterations(&self) -> u32
Get the current iteration count.
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Whether the loop has finished (returned Completed or Error).
Sourcepub fn drain_events(&mut self) -> Vec<LoopEvent>
pub fn drain_events(&mut self) -> Vec<LoopEvent>
Drain any remaining buffered LoopEvents.
See ToolLoopHandle::drain_events
for full documentation.
Sourcepub fn into_result(self) -> ToolLoopResult
pub fn into_result(self) -> ToolLoopResult
Consume the handle and return a ToolLoopResult.