pub struct CompletionCall {
pub call_index: usize,
pub usage: Usage,
pub message_id: Option<String>,
pub response_id: Option<String>,
pub provider_request_id: Option<String>,
pub finish_reason: Option<FinishReason>,
pub raw: Value,
}Expand description
Details for one successfully completed completion request made by an agent run.
Fields§
§call_index: usizeZero-based index of the completion request within this agent run.
usage: UsageToken usage reported for this completion request.
Zero-valued usage is Usage’s documented sentinel for missing
provider usage metrics; rig does not distinguish “reported all zeros”
from “unreported”.
message_id: Option<String>Provider-assigned assistant message ID for this call, when reported.
response_id: Option<String>Provider-assigned response-scoped ID for this call, when reported.
provider_request_id: Option<String>The provider’s transport request id for this call (HTTP response
header, e.g. Anthropic request-id) — the id provider support asks
for. None means the provider did not report one, never an error.
finish_reason: Option<FinishReason>Why the model stopped generating on this call, when the provider
reported it. None means the provider reported no reason.
Recorded per call rather than once per run: a multi-turn run makes N completion requests, each with its own terminal reason, and collapsing them to a single run-level value would lose exactly the information that makes a truncated turn diagnosable — which turn hit the limit. A caller that wants the run’s last reason reads it off the final entry.
This is the field whose absence hid rig#2322: the provider layer carried
FinishReason::Length on the stream’s terminal record, but the agent
assembler dropped it, so a turn truncated at the output-token limit was
indistinguishable from a turn that simply had nothing to say.
raw: ValueThe provider’s own response for this call — see
CompletionResponse::raw for the exact meaning of the payload. Every
provider seam populates it; Value::Null only when the call’s response
was built without a provider behind it (a hand-constructed model, a
record persisted before the field, or a hand-driven AgentRun that
recorded a streamed call with no terminal record — the runner itself
rejects such a stream as truncated before recording anything).
Recorded per call, like Self::finish_reason: on a multi-turn
run each entry carries its own attempt’s response, never a previous
attempt’s, and on a retried turn the recorded call carries the retried
attempt’s own.
Implementations§
Source§impl CompletionCall
impl CompletionCall
Sourcepub fn new(call_index: usize, usage: Usage) -> Self
pub fn new(call_index: usize, usage: Usage) -> Self
Create details for one completion request in an agent run; identity
metadata starts unset and is attached with Self::with_identity.
Sourcepub fn with_raw(self, raw: Value) -> Self
pub fn with_raw(self, raw: Value) -> Self
Attach the provider’s own response this call’s attempt produced.
Sourcepub fn with_identity(self, identity: ResponseIdentity) -> Self
pub fn with_identity(self, identity: ResponseIdentity) -> Self
Attach the response identity metadata this call’s attempt reported.
Sourcepub fn with_finish_reason(self, finish_reason: Option<FinishReason>) -> Self
pub fn with_finish_reason(self, finish_reason: Option<FinishReason>) -> Self
Attach the terminal finish reason this call’s attempt reported.
Kept separate from Self::with_identity because a finish reason is
not identity: ResponseIdentity answers “which response was this”,
while this answers “why did it stop”.
Sourcepub fn identity(&self) -> ResponseIdentity
pub fn identity(&self) -> ResponseIdentity
This call’s identity metadata as one ResponseIdentity carrier.
Trait Implementations§
Source§impl Clone for CompletionCall
impl Clone for CompletionCall
Source§fn clone(&self) -> CompletionCall
fn clone(&self) -> CompletionCall
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more