Skip to main content

Module interrupts

Module interrupts 

Source
Expand description

The human-in-the-loop round trip.

A run does not only succeed or fail. It can pause: the agent finishes with an interrupt outcome, listing what it needs a human to decide, and the conversation continues when the client sends the answers back in RunAgentInput::resume.

That round trip is the whole reason RUN_FINISHED carries an outcome, and this module is the client half of it. With a Session it is two calls:

let mut session = Session::<_>::new(transport, "thread-1");
let mut pending = Vec::new();

let mut run = session.send("delete the staging database");
while let Some(update) = run.next().await {
    if let Update::Interrupt(interrupt) = update {
        pending.push(interrupt);
    }
}
drop(run);

// Ask the human, then answer the agent.
let mut resumed = session.resume(&pending[0], serde_json::json!({ "approved": true }));
while resumed.next().await.is_some() {}

Without one — a proxy, or anything driving crate::client::RemoteAgent directly — interrupts_of finds the interrupts on the event and resume_run builds the next request.

Structs§

ResumeBuilder
Answering interrupts, one call per decision.

Traits§

InterruptExt
Answering one interrupt, on the interrupt itself.

Functions§

interrupts_of
The interrupts a RUN_FINISHED paused on, or an empty slice for any other event.
resume_run
Builds the request that resumes a paused run.