Expand description
Async tool execution: lets long-running tools return a pending placeholder and run their actual work in a background task.
A tool that wants to run asynchronously (decided at runtime inside its
execute) calls AsyncTaskRunner::submit with the real work as a future
and returns a ToolResult::pending(..) placeholder. The runner spawns the
work as an independent tokio task; when it finishes (or is cancelled) the
result is sent back to the Agent via the done channel, which reinjects it
into the conversation history and wakes the LLM.
Cancellation is cooperative: each task owns a CancellationToken. When the
Agent cancels a task (user /cancel, session expiry, or Agent shutdown),
the spawned select! favors the cancellation branch and the work future is
dropped (HTTP requests etc. are cancellation-safe).
Structs§
- Async
Task Done - Message delivered to the Agent when a background task finishes (success, failure, or cancellation).
- Async
Task Runner - Handle used by tools to submit background work.
Type Aliases§
- Async
Task Work - A future produced by an async tool representing its background work.