pub enum LoopInterrupt {
ApprovalRequest(PendingApproval),
AuthRequest(PendingAuth),
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::AuthRequest(pending)) => {
println!("Auth required from provider: {}", pending.request.provider);
pending.cancel(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.
AuthRequest(PendingAuth)
A tool call requires authentication credentials.
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 call
LoopDriver::submit_input to interject user messages before the
next model turn, then call 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 and auth requests 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 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more