pub struct RunHandle {
pub provider: ProviderKind,
pub config: AgentRunConfig,
pub prompt: String,
pub messages: Vec<ProviderMessage>,
pub expects_write: bool,
pub steering: Option<Receiver<String>>,
pub cancel: CancelToken,
pub permission_hook: Option<ToolPermissionHook>,
pub execution_hook: Option<ToolExecutionHook>,
}Expand description
Handle for a single agent run: provider kind, config, prompt, and cancel.
Fields§
§provider: ProviderKind§config: AgentRunConfig§prompt: String§messages: Vec<ProviderMessage>§expects_write: bool§steering: Option<Receiver<String>>§cancel: CancelToken§permission_hook: Option<ToolPermissionHook>§execution_hook: Option<ToolExecutionHook>Implementations§
Source§impl RunHandle
impl RunHandle
Sourcepub fn spawn(self) -> Receiver<AgentEvent>
pub fn spawn(self) -> Receiver<AgentEvent>
Spawn the unified agent loop on a background thread and return the receiver.
The thread closes its sender when done, so the receiver’s try_recv will
return Err(Disconnected) once the run completes.
If the receiver is dropped early (e.g. the user cancels), the thread exits
on the next failed send. The CancelToken inside the handle can also be
signalled for cooperative cancellation.
Sourcepub fn fake(config: AgentRunConfig, prompt: String) -> Self
pub fn fake(config: AgentRunConfig, prompt: String) -> Self
Create a fake-provider run handle.
Sourcepub fn provider_with_steering(
config: AgentRunConfig,
messages: Vec<ProviderMessage>,
expects_write: bool,
steering: Receiver<String>,
) -> Self
pub fn provider_with_steering( config: AgentRunConfig, messages: Vec<ProviderMessage>, expects_write: bool, steering: Receiver<String>, ) -> Self
Create a provider run handle with a steering-message receiver.
Sourcepub fn with_permission_hook(self, hook: ToolPermissionHook) -> Self
pub fn with_permission_hook(self, hook: ToolPermissionHook) -> Self
Attach a permission hook for sensitive tool calls.
Sourcepub fn with_execution_hook(self, hook: ToolExecutionHook) -> Self
pub fn with_execution_hook(self, hook: ToolExecutionHook) -> Self
Attach an execution hook for front-end-specific tool handling.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for RunHandle
impl !Sync for RunHandle
impl !UnwindSafe for RunHandle
impl Freeze for RunHandle
impl Send for RunHandle
impl Unpin for RunHandle
impl UnsafeUnpin for RunHandle
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoMaybeUndefined<T> for T
impl<T> IntoMaybeUndefined<T> for T
Source§fn into_maybe_undefined(self) -> MaybeUndefined<T>
fn into_maybe_undefined(self) -> MaybeUndefined<T>
Converts this value into a three-state builder argument.
Source§impl<T> IntoOption<T> for T
impl<T> IntoOption<T> for T
Source§fn into_option(self) -> Option<T>
fn into_option(self) -> Option<T>
Converts this value into an optional builder argument.