#[non_exhaustive]pub struct Outcome {
pub agent: Agent,
pub session: Option<String>,
pub text: String,
pub usage: Usage,
pub stop: Stop,
pub rate_limit: Option<RateLimit>,
pub exit_code: i32,
pub stderr: String,
pub unparsed: usize,
pub first_unparsed: Option<String>,
pub structured: Option<Value>,
}Expand description
The result of one completed run.
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.agent: AgentWhich agent produced it.
session: Option<String>The native session id, when the run had or produced one. This is the handle a later turn resumes with.
text: StringThe assistant’s final text.
usage: UsageToken and cost accounting.
stop: StopWhy it stopped.
rate_limit: Option<RateLimit>The last quota signal seen, if any.
exit_code: i32The process exit code.
stderr: StringRaw stderr, kept for diagnostics and capped at
crate::MAX_CAPTURE.
unparsed: usizeHow many output lines could not be parsed, with the first as a sample.
Agents interleave banners with their JSON, so a non-zero count is not
automatically a fault. It becomes one when paired with an empty Self::text,
which is what a vendor changing its output shape looks like from here.
See Outcome::looks_like_a_format_change.
first_unparsed: Option<String>The first line that failed to parse.
structured: Option<Value>The answer parsed against the schema given to crate::Request::schema.
None when no schema was asked for, or when the agent’s answer did not
parse as JSON. Never a re-interpretation of prose: this is only set from
a value the agent produced under a schema.
Implementations§
Source§impl Outcome
impl Outcome
Sourcepub fn looks_like_a_format_change(&self) -> bool
pub fn looks_like_a_format_change(&self) -> bool
Whether this run looks like the agent changed its output format.
The signature is a process that exited successfully while every line it printed was unreadable: the CLI is healthy and this crate’s parser is not. Worth logging loudly, because the alternative symptom is a successful run that mysteriously returns nothing.