Skip to content

ChatMessage

type ChatMessage =
| {
content: string;
role: "system";
}
| {
content: string | ContentPart[];
role: "user";
}
| {
content: string;
reasoning?: string;
reasoningDetails?: unknown[];
reasoningItems?: ReasoningItems;
role: "assistant";
toolCalls?: ToolCall[];
}
| {
content: string;
images?: ImagePart[];
name: string;
role: "tool";
toolCallId: string;
};

Defined in: core/src/types.ts:87

{
content: string;
role: "system";
}

{
content: string | ContentPart[];
role: "user";
}

{
content: string;
reasoning?: string;
reasoningDetails?: unknown[];
reasoningItems?: ReasoningItems;
role: "assistant";
toolCalls?: ToolCall[];
}
content: string;
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.

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.

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";
optional toolCalls?: ToolCall[];

{
content: string;
images?: ImagePart[];
name: string;
role: "tool";
toolCallId: string;
}
content: string;
optional images?: ImagePart[];

Images a tool hands back (a screenshot, a rendered chart).

name: string;
role: "tool";
toolCallId: string;