Turn
Defined in: core/src/turn.ts:24
One drained turn: the message a loop appends, whose toolCalls are the
calls it runs, and what the turn cost.
Properties
Section titled “Properties”finishReason
Section titled “finishReason”finishReason: FinishReason | null;Defined in: core/src/turn.ts:31
As the provider stated it, and null when it stated none.
message
Section titled “message”message: object;Defined in: core/src/turn.ts:27
Ready to append to history as it is. toolCalls holds the calls to run,
in the order the provider indexed them, and is absent when there are none.
content
Section titled “content”content: string;reasoning?
Section titled “reasoning?”optional reasoning?: string;The model’s chain-of-thought. Thinking-mode providers require it
replayed on a turn that made a tool call (DeepSeek 400s without it).
OpenAI-shape serializes it as reasoning_content; Anthropic-shape
drops it, since its thinking blocks carry signatures we never capture.
A turn that disables thinking must not carry it. Mixing the two is
unsupported. stripReasoning below is that rule, once.
reasoningDetails?
Section titled “reasoningDetails?”optional reasoningDetails?: unknown[];OpenRouter’s normalized reasoning payload, arriving on the stream and riding back UNMODIFIED on the next turn’s assistant message.
Opaque on purpose, with the same contract as Gemini’s thoughtSignature,
and for the same reason: it is the provider’s own record of how it got
here, and reading, reshaping or dropping it costs the model its
continuity across a tool round. Absent on every other dialect.
reasoningItems?
Section titled “reasoningItems?”optional reasoningItems?: ReasoningItems;The ChatGPT backend’s own reasoning items, encrypted, riding back
UNMODIFIED on the next turn so the model keeps its chain of thought.
Tagged with the provider that made them: only that provider replays
them, because another vendor (after a fallback) would reject them.
Opaque, like reasoningDetails.
role: "assistant";toolCalls?
Section titled “toolCalls?”optional toolCalls?: ToolCall[];source?
Section titled “source?”optional source?: object;Defined in: core/src/turn.ts:33
The endpoint and model that answered, when a fallback provider says.
model: string;provider
Section titled “provider”provider: string;usage: TokenUsage;Defined in: core/src/turn.ts:29
The last usage the stream reported, or zeros when it reported none.