Skip to main content

starweaver_runtime/
run.rs

1//! Runtime run result types and compatibility exports for checkpointable state.
2
3use serde::{Deserialize, Serialize};
4
5/// Checkpointable state shared with durability layers.
6pub use starweaver_context::AgentRunState;
7/// Shared lifecycle status for an admitted runtime execution.
8pub use starweaver_core::RunLifecycle as RunStatus;
9
10/// Result returned when an agent run completes.
11#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
12pub struct AgentRunResult {
13    /// Final output text.
14    pub output: String,
15    /// Final checkpointable state.
16    pub state: AgentRunState,
17}
18
19impl AgentRunResult {
20    /// Return true when the final state is waiting for HITL input.
21    #[must_use]
22    pub const fn has_pending_hitl(&self) -> bool {
23        self.state.has_pending_hitl()
24    }
25
26    /// Return pending approval-required tool returns.
27    #[must_use]
28    pub fn pending_approvals(&self) -> &[starweaver_model::ToolReturnPart] {
29        self.state.pending_approvals()
30    }
31
32    /// Return pending deferred tool returns.
33    #[must_use]
34    pub fn pending_deferred_tools(&self) -> &[starweaver_model::ToolReturnPart] {
35        self.state.pending_deferred_tools()
36    }
37}