pub struct Turn {Show 15 fields
pub id: String,
pub parent_id: Option<String>,
pub group_id: Option<String>,
pub role: Role,
pub timestamp: String,
pub text: String,
pub thinking: Option<String>,
pub tool_uses: Vec<ToolInvocation>,
pub model: Option<String>,
pub stop_reason: Option<String>,
pub token_usage: Option<TokenUsage>,
pub attributed_token_usage: Option<TokenUsage>,
pub environment: Option<EnvironmentSnapshot>,
pub delegations: Vec<DelegatedWork>,
pub file_mutations: Vec<FileMutation>,
}Expand description
A single turn in a conversation, from any provider.
Fields§
§id: StringUnique identifier within the conversation.
parent_id: Option<String>Parent turn ID (for branching conversations).
group_id: Option<String>Identifier of the source accounting unit this turn belongs to —
a message for Claude (message.id), a round for Codex (turn_id).
A grouping key, not a turn identifier: when a provider derives
several turns from one unit (Claude writes one JSONL line per
content block; a Codex round emits several turns), every sibling
turn carries the same value, and group-level accounting
(token_usage) belongs to the group once (on its final turn).
role: RoleWho produced this turn.
timestamp: StringWhen this turn occurred (ISO 8601).
text: StringThe visible text content (already collapsed from provider-specific formats).
thinking: Option<String>Internal reasoning (chain-of-thought, thinking blocks).
tool_uses: Vec<ToolInvocation>Tool invocations in this turn.
model: Option<String>Model identifier (e.g. “claude-opus-4-6”, “gpt-4o”).
stop_reason: Option<String>Why the turn ended (e.g. “end_turn”, “tool_use”, “max_tokens”).
token_usage: Option<TokenUsage>Token usage for this turn. When this turn belongs to a group_id
group, this is the whole message’s total, carried on the
group’s final turn only (it always means “the total for a
message”; summing over turns yields session totals).
attributed_token_usage: Option<TokenUsage>This turn’s own attributed spend, when the source provides
step-aligned data — the output tokens generated for this turn,
distinct from Turn::token_usage (the whole message’s total).
Populated where a provider streams per-step counts (Claude’s
per-content-block cumulative usage, Codex’s per-step
token_count deltas); absent where it can’t be attributed.
Within a group_id group, Σ attributed_token_usage is the
group’s attributed output; the unattributed remainder
(prompt-side input/cache, inherently per-message) stays in
token_usage on the group’s final turn. A separate field from
token_usage precisely so the session-total sum is unaffected.
environment: Option<EnvironmentSnapshot>Environment at time of this turn.
delegations: Vec<DelegatedWork>Sub-agent work delegated from this turn.
file_mutations: Vec<FileMutation>File mutations produced by this turn, with diffs pre-resolved by
the provider’s to_view. Each entry projects to a sibling
file.write artifact change in the derived step. When the
mutation is attributable to a specific tool call, tool_id on
the entry links back to that ToolInvocation::id.