pub enum LoopInterrupt {
ApprovalRequest(PendingApproval),
AwaitingInput(InputRequest),
AfterToolResult(ToolRoundInfo),
}Expand description
An interrupt that pauses the agent loop until the host resolves it.
The loop returns an interrupt inside LoopStep::Interrupt whenever it
cannot proceed autonomously. Each variant carries a handle with
resolution methods so callers can resolve the interrupt directly.
§Example
use agentkit_loop::{LoopInterrupt, LoopStep};
match driver.next().await? {
LoopStep::Interrupt(LoopInterrupt::ApprovalRequest(pending)) => {
println!("Tool {} needs approval: {}", pending.request.request_kind, pending.request.summary);
pending.approve(driver)?;
}
LoopStep::Interrupt(LoopInterrupt::AwaitingInput(pending)) => {
println!("Waiting for input: {}", pending.reason);
// ... call pending.submit(driver, items)
}
LoopStep::Interrupt(LoopInterrupt::AfterToolResult(info)) => {
// Cooperative yield between tool rounds. Optionally call
// driver.submit_input(...) to interject a user message, then
// call driver.next() to resume the turn.
let _ = info;
}
LoopStep::Finished(result) => {
println!("Turn finished: {:?}", result.finish_reason);
}
}Variants§
ApprovalRequest(PendingApproval)
A tool call requires explicit approval before it can execute.
AwaitingInput(InputRequest)
The driver has no pending input and needs the host to supply some.
AfterToolResult(ToolRoundInfo)
A tool round finished: all tool calls from the previous assistant
message now have results in the transcript, and the driver is about to
invoke the model again. The host may interject user messages via the
ToolRoundInfo::submit handle before calling LoopDriver::next
to resume.
This is a non-blocking interrupt: callers that do not care about
mid-turn interjection can treat it as a no-op (_ => continue) and
the next next() call resumes the turn.
Implementations§
Source§impl LoopInterrupt
impl LoopInterrupt
Sourcepub fn is_blocking(&self) -> bool
pub fn is_blocking(&self) -> bool
Returns true if the interrupt must be explicitly resolved before
the loop can make progress. Approvals are blocking;
AwaitingInput and
AfterToolResult are cooperative
and can be ignored by calling LoopDriver::next again.
Trait Implementations§
Source§impl Clone for LoopInterrupt
impl Clone for LoopInterrupt
Source§fn clone(&self) -> LoopInterrupt
fn clone(&self) -> LoopInterrupt
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LoopInterrupt
impl Debug for LoopInterrupt
Source§impl<'de> Deserialize<'de> for LoopInterrupt
impl<'de> Deserialize<'de> for LoopInterrupt
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for LoopInterrupt
impl PartialEq for LoopInterrupt
Source§fn eq(&self, other: &LoopInterrupt) -> bool
fn eq(&self, other: &LoopInterrupt) -> bool
self and other values to be equal, and is used by ==.