#[non_exhaustive]pub struct ResultMessage {Show 19 fields
pub subtype: String,
pub is_error: bool,
pub result: Option<String>,
pub errors: Option<Vec<Value>>,
pub session_id: Option<String>,
pub total_cost_usd: Option<f64>,
pub ttft_ms: Option<u64>,
pub duration_ms: Option<u64>,
pub usage: Option<UsageSummary>,
pub stop_reason: Option<String>,
pub duration_api_ms: Option<u64>,
pub num_turns: Option<u64>,
pub terminal_reason: Option<String>,
pub structured_output: Option<Value>,
pub permission_denials: Vec<Value>,
pub model_usage: Option<Value>,
pub user_message_uuids: Vec<String>,
pub origin: Option<Value>,
pub extra: HashMap<String, Value>,
}Expand description
Turn complete. Source: chunk-20bv8pca.js:14425–14913
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.subtype: String“success” | “error_*”. A failed API call still comes as “success”
with is_error: true and the message in result.
is_error: boolThe turn failed; a failed API call sets this on a success result.
result: Option<String>Final text of the turn, or the error message when is_error.
errors: Option<Vec<Value>>Error details of error_* subtypes.
session_id: Option<String>Session the turn ran in.
total_cost_usd: Option<f64>Estimated cost in USD, cumulative across the session’s turns.
ttft_ms: Option<u64>Time to first token, in ms.
duration_ms: Option<u64>Wall-clock duration, in ms.
usage: Option<UsageSummary>Token usage.
stop_reason: Option<String>Why the model stopped, e.g. "end_turn".
duration_api_ms: Option<u64>Time spent in API calls, in ms.
num_turns: Option<u64>Number of agent-loop turns.
terminal_reason: Option<String>Why the loop ended (“completed”, …).
structured_output: Option<Value>Output matching Initialize::json_schema.
permission_denials: Vec<Value>Tool calls the permission system denied during the turn.
model_usage: Option<Value>Per-model token and cost breakdown.
user_message_uuids: Vec<String>The prompts (UserMessage::uuid) this turn answered.
origin: Option<Value>Set when the CLI started the turn itself (e.g. {"kind":"task-notification"}
after a background task finished); absent for turns the host prompted.
extra: HashMap<String, Value>Fields not named above.
Implementations§
Source§impl ResultMessage
impl ResultMessage
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
success subtype without is_error.
Sourcepub fn answers(&self, uuid: &str) -> bool
pub fn answers(&self, uuid: &str) -> bool
Whether this turn answered the prompt uuid. A prompt the CLI
refuses up front (e.g. budget spent) gets a result but no echo.
Sourcepub fn error_kind(&self) -> TurnErrorKind
pub fn error_kind(&self) -> TurnErrorKind
Category of a failed turn.
Sourcepub fn error_message(&self) -> String
pub fn error_message(&self) -> String
Why the turn failed: for is_error the CLI’s message; for
error_* subtypes the subtype, then its errors details.