Missing reasoning_content in multi-turn tool calling: why the thinking field gets dropped
This article explains why models with thinking mode enabled fail on the second turn of a tool-calling loop with "reasoning_content must be passed back to the API," and why the failure looks intermittent. It breaks the root cause into three layers that silently discard the field—truthy checks in the model access layer, hardcoded field whitelists in agent frameworks, and gaps in persisted conversation history—then discusses where compatibility responsibility belongs and gives layered fixes for the server, the client and framework, and stored data, plus testing and observability recommendations.
1. The Symptom: One Error That Blocks the Whole Tool Chain
In multi-turn tool calling scenarios, models with thinking mode enabled frequently throw an error like this:
reasoning_content must be passed back to the API
What makes this error confusing is that single-turn Q&A works fine. As soon as you enter the loop “model outputs tool arguments → local code executes the tool → results are sent back to the model to continue reasoning,” the second request is rejected. On the surface it looks like a parameter validation failure; in reality the context is incomplete. The model requires the internal reasoning text produced in the previous turn to be passed back verbatim, and the caller dropped it somewhere along the chain.
It gets worse because the behavior is intermittent: it does not reproduce in new sessions but always reproduces in old ones; it does not reproduce with thinking mode off but reproduces as soon as it is on. That leads people to suspect rate limiting or network jitter, wasting a lot of debugging time.
2. Root Cause: The Field Is Dropped at Three Layers in Sequence
For the thinking content field to reach the server intact, it has to pass through three stages in a row. If any one of them applies “delete when empty” logic, the chain breaks.
2.1 Truthy Checks in the Parsing Layer
Most model access layers apply a truthy check to optional fields, something like:
// Problematic code: an empty string is treated as "this field is absent"if (msg.reasoning_content) {payload.reasoning_content = msg.reasoning_content;}
But thinking mode requires exactly the opposite: even when the field is an empty string, it must be passed back explicitly. A truthy check conflates “present but empty” with “not present,” erasing the distinction.
2.2 Field Whitelists in the Transformation Layer
Agent frameworks usually normalize each provider’s message format into an internal structure and then serialize it back into a request body. If the conversion logic uses a hardcoded set of keys, any field not on the whitelist is silently discarded:
// Only whitelisted fields survive; anything unregistered disappearsconst next = {role: m.role,content: m.content,tool_calls: m.tool_calls,// reasoning_content is not registered → lost};
2.3 Missing Data in the Persistence Layer
When conversation history is written to storage, older messages simply do not contain the field, because thinking mode was not enabled at the time. When a new session reads that history and replays it, the gap surfaces. This is a data migration problem rather than a code logic problem, and it is the easiest one to overlook.
The combined effect of all three layers: maintainers in the community and of the tooling had to submit nearly twenty changes in turns and merge part of them before the chain was complete, a process that stretched over roughly two months.
3. Where the Responsibility Lies: Server-Side or Application-Side Compatibility
The ideal fix belongs on the model provider’s side. If a provider advertises a general-purpose compatible interface, it should tolerate callers omitting optional fields and accept them with “absent means empty” semantics, instead of shifting the burden of proof onto every integrator. The reason is that access-layer implementations vary enormously; patching them one by one costs more as the ecosystem grows, and the work is never finished.
In practice, the compatibility work tends to land on tool maintainers: some cloud vendor platforms reject empty tool call arguments, and some overseas model services fail outright and trigger risk controls when reasoning content is not passed. So the more pragmatic strategy is to converge from both sides—be as lenient as possible on the server, and add defensive completion on the client.
4. Layered Solutions
Server Side
- Use key-existence checks rather than truthy checks for optional fields.
- Fill in default empty values for missing fields before validation runs.
- Name the missing field and the index of the message it belongs to in the error message, to cut down localization cost.
Client and Framework Side
- Build the payload explicitly during serialization so the whitelist cannot drop fields:
const next = {role: m.role,content: m.content ?? '',reasoning_content: m.reasoning_content ?? '', // explicitly fill in emptytool_calls: m.tool_calls,};
- Add a normalization middleware layer before the request is sent, to complete all history messages uniformly.
- Retry a limited number of times on “missing field” errors, completing the fields before each retry to avoid an infinite loop.
Data Side
- Add the field to the history message table and allow it to be null, mapping it to an empty string on read.
- Provide a one-off backfill script that only touches existing sessions created before thinking mode was enabled.
- Persist the complete raw response, so that newly added fields do not create gaps again in the future.
5. Testing and Observability Recommendations
Build a minimal reproduction case: enable thinking mode, run one round of tool calling, and check whether every assistant message in the second request body carries the field. Turn it into an integration test and it will catch the vast majority of regressions.
It is also worth recording a field-coverage metric for request bodies in the gateway or logging service, with monitoring and alerts on the missing-field ratio. Combined with distributed tracing to pinpoint whether the loss happens during parsing, transformation, or storage, this is far more efficient than printing logs layer by layer.
6. Closing Thoughts
The root of the failed reasoning-content round trip is that “optional field” is given different semantics in different implementations. Only by treating it explicitly as part of the contract, rather than relying on each layer’s default behavior, can multi-turn tool calling run reliably. For teams using AI coding tools or building their own agent chains, lenient parsing on the server plus defensive completion on the client is the lowest-cost combination. If tool execution and task distribution run on cloud container platforms and message queues, field-completeness validation should likewise be pushed forward into the access layer so the problem does not spread to the business side.
