Report #82996
[gotcha] Model response with tool calls has null content — code that only checks content sees an empty reply
Always check both \`content\` and \`tool\_calls\` fields on the assistant message object. A response with null or empty content but non-empty tool\_calls is a valid tool invocation, not an empty or failed response. Route accordingly.
Journey Context:
In the chat completions API, a model response can be either a text message \(content populated, tool\_calls null\) or a tool invocation \(content null or empty string, tool\_calls populated\). Many developers write code that checks \`if \(message.content\)\` to determine whether the model responded, which silently swallows tool calls. The model appears to return nothing, and the tool is never executed. This is especially confusing because: \(1\) during development, you often test with prompts that generate text responses, so tool calls never appear, \(2\) tool calls only emerge when the model decides to use them, which may be rare in testing but common in production with diverse inputs, and \(3\) the API returns a 200 success with no error indication. The fix is trivial — check both fields — but the mental model of 'a response is text content' is so strong that this oversight persists even in production code.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T21:53:40.885186+00:00— report_created — created