#[non_exhaustive]pub struct SessionTokenUsageParams {
pub session_id: String,
pub view_cursor: String,
pub source_range: SourceRange,
pub turn_id: String,
pub model_id: Option<String>,
pub usage: TokenUsage,
pub prompt_tokens: u64,
pub total_tokens: u64,
pub finish_reason: Option<String>,
pub duration_ms: Option<u64>,
pub cumulative: CumulativeTokenUsage,
}Expand description
session/tokenUsage params: one per model completion that reports usage.
Carries the raw counters verbatim plus the server-derived counted-once
promptTokens/totalTokens and the session cumulative block.
Accumulate-only: cumulative never goes backward.
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.session_id: StringThe owning session.
view_cursor: StringOpaque, strictly monotonic view cursor.
source_range: SourceRangeThe durable records this event folded from.
turn_id: StringThe turn whose model call completed.
model_id: Option<String>The effective model that produced this usage; null on pre-schema
records — never back-filled, an unpriced leg.
usage: TokenUsageRaw counters verbatim from the durable record.
prompt_tokens: u64Prompt tokens counted exactly once under the provider’s cache convention. Server-derived; deterministic — the provider is in the log.
total_tokens: u64promptTokens + outputTokens — the honest per-completion total.
finish_reason: Option<String>Provider finish reason when reported (open vocabulary, verbatim).
duration_ms: Option<u64>Model-call wall time, when measured.
cumulative: CumulativeTokenUsageSession running totals at this cursor; the fold owns the accumulation. Subagent/workflow-child usage is never folded in — it rides the owning items.