pub struct RunFinishedEvent {
pub base: BaseEvent,
pub thread_id: ThreadId,
pub run_id: RunId,
pub outcome: Option<RunFinishedOutcome>,
pub result: Option<JsonValue>,
pub interrupt: Option<InterruptInfo>,
}Expand description
Event indicating that a run has finished.
This event is sent when an agent run completes, either successfully or with an interrupt requiring human input.
§Interrupt Flow
When outcome == Interrupt, the agent indicates that on the next run,
a value needs to be provided via RunAgentInput.resume to continue.
§Example
use ag_ui_core::{RunFinishedEvent, RunFinishedOutcome, InterruptInfo, ThreadId, RunId};
// Success case
let success = RunFinishedEvent::new(ThreadId::random(), RunId::random())
.with_result(serde_json::json!({"status": "done"}));
// Interrupt case
let interrupt = RunFinishedEvent::new(ThreadId::random(), RunId::random())
.with_interrupt(
InterruptInfo::new()
.with_reason("human_approval")
.with_payload(serde_json::json!({"action": "send_email"}))
);Fields§
§base: BaseEventCommon event fields (timestamp, rawEvent).
thread_id: ThreadIdThe thread ID this run belongs to.
run_id: RunIdThe run ID that finished.
outcome: Option<RunFinishedOutcome>Outcome of the run. Optional for backward compatibility. When omitted, outcome is inferred: if interrupt is present, it’s Interrupt; otherwise Success.
result: Option<JsonValue>Optional result value from the run. Present when outcome is Success (or omitted with no interrupt).
interrupt: Option<InterruptInfo>Optional interrupt information. Present when outcome is Interrupt (or omitted with interrupt present).
Implementations§
Source§impl RunFinishedEvent
impl RunFinishedEvent
Sourcepub fn new(thread_id: impl Into<ThreadId>, run_id: impl Into<RunId>) -> Self
pub fn new(thread_id: impl Into<ThreadId>, run_id: impl Into<RunId>) -> Self
Creates a new RunFinishedEvent with Success outcome.
Sourcepub fn with_outcome(self, outcome: RunFinishedOutcome) -> Self
pub fn with_outcome(self, outcome: RunFinishedOutcome) -> Self
Sets the outcome explicitly.
Sourcepub fn with_result(self, result: JsonValue) -> Self
pub fn with_result(self, result: JsonValue) -> Self
Sets the result for this event (implies Success outcome).
Sourcepub fn with_interrupt(self, interrupt: InterruptInfo) -> Self
pub fn with_interrupt(self, interrupt: InterruptInfo) -> Self
Sets the interrupt info (implies Interrupt outcome).
Sourcepub fn with_timestamp(self, timestamp: f64) -> Self
pub fn with_timestamp(self, timestamp: f64) -> Self
Sets the timestamp for this event.
Sourcepub fn effective_outcome(&self) -> RunFinishedOutcome
pub fn effective_outcome(&self) -> RunFinishedOutcome
Returns the effective outcome of this event.
If outcome is explicitly set, returns that. Otherwise:
- If interrupt is present, returns Interrupt
- Otherwise, returns Success
Trait Implementations§
Source§impl Clone for RunFinishedEvent
impl Clone for RunFinishedEvent
Source§fn clone(&self) -> RunFinishedEvent
fn clone(&self) -> RunFinishedEvent
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more