API Reference
prepareRequestMessages
function prepareRequestMessages(messages): Message[];Defined in: primitives/loop.ts:447
Prepare working history for sending: drop both reasoning representations
(reasoning and reasoning_details) from assistant turns that did NOT call
tools.
Parameters
| Parameter | Type | Description |
|---|---|---|
messages | Message[] | The working history to prepare. Never mutated. |
Returns
Message[]
A fresh array with reasoning stripped from non-tool-call turns.
Remarks
Reasoning is resent only on tool-call turns — thinking-mode models (e.g. DeepSeek V4) require it there for tool-call continuity and reject the request otherwise, while on plain turns the model ignores it. The flat string and the verbatim structured blocks follow the same rule (see Message.reasoning).
See
- Message.reasoning
- Message.reasoning_details