Encrypt Online
Theme

Data Formats & Debugging

How to Fix Missing Tool Results in OpenAI and Claude

Match missing tool results to their original call IDs in OpenAI and Claude. Compare the three API formats and recover after a partial reply, timeout, or retry.

Encrypt Online Editorial Team5 min read

To fix a missing tool result, return one reply for each client tool call, using the original call ID. Two calls to the same function need two replies. A function can finish successfully and still be missing from the conversation if your app drops its reply.

Inspect the outgoing request that the API rejected. A log that ends when the assistant asks to run a tool may simply show a call still in progress. For OpenAI Chat Completions or Claude Messages, paste the rejected request into the AI Tool Call Debugger to find the first broken exchange. For OpenAI Responses, use the middle row below.

Missing tool results. A path between JSON braces represents the link from a result to its call.

Which ID goes on the result?

API ID on the call Where the same ID goes on the result
OpenAI Chat Completions tool_calls[].id on the assistant message tool_call_id on a separate role: "tool" message for each call
OpenAI Responses call_id on the function_call output item call_id on a function_call_output input item
Claude Messages id on the assistant's tool_use block tool_use_id on a tool_result block in the next user message

In OpenAI Responses, a function call can have both an item id and a call_id. Copy the call_id. For example, if the item has "id": "fc_17" and "call_id": "call_42", use the following result item.

JSON
{"type": "function_call_output", "call_id": "call_42", "output": "In stock"}

In OpenAI Responses, call_id identifies the tool call. previous_response_id identifies the response you're continuing. For an immediate reply, continue from the response that issued the call. If an asynchronous call finishes after later turns, continue from the latest response in that chain and keep the original call_id. OpenAI async tool calling

If your app sends the history itself, include the model's function call along with its output. For reasoning models that return reasoning items with the call, pass those items back too. OpenAI function calling

OpenAI says a tool call has no response

Suppose a customer asks about two books. The assistant calls stock twice. Both lookups run, but the app stores replies by function name. The second reply overwrites the first. The next Chat Completions request then contains this message history.

JSON
[
  {"role":"user","content":"Are books A and B in stock?"},
  {"role":"assistant","tool_calls":[
    {"id":"call_A","type":"function","function":{"name":"stock","arguments":"{\"book\":\"A\"}"}},
    {"id":"call_B","type":"function","function":{"name":"stock","arguments":"{\"book\":\"B\"}"}}
  ]},
  {"role":"tool","tool_call_id":"call_B","content":"In stock"}
]

The assistant requested call_A and call_B. Only call_B has a reply. If the saved result for book A was “Sold out,” append this message to the array before continuing.

JSON
{"role":"tool","tool_call_id":"call_A","content":"Sold out"}

The two replies can finish in either order. Store each result under the ID from its call so the faster lookup can't take the other book's place. If a lookup failed, return its actual error against that call's ID. “Sold out” and “Lookup timed out” tell the model different things. OpenAI Chat Completions function calling

If the IDs match but the function rejects its arguments, take the decoded arguments object, such as {"book":"A"}, and check it against the function's input schema in the JSON Schema Validator.

Claude says tool_use has no tool_result

Find the assistant's tool_use blocks. Put a corresponding tool_result for each ID in one user message immediately afterward. Put those blocks before any ordinary text. Splitting two parallel results across two user messages can leave the first message looking incomplete. Claude parallel tool use

Here the first lookup succeeds and the second times out. Both calls have an answer, so Claude can report what it learned about book A and explain why book B is still unknown.

JSON
[
  {"role":"user","content":"Are books A and B in stock?"},
  {"role":"assistant","content":[
    {"type":"tool_use","id":"toolu_A","name":"stock","input":{"book":"A"}},
    {"type":"tool_use","id":"toolu_B","name":"stock","input":{"book":"B"}}
  ]},
  {"role":"user","content":[
    {"type":"tool_result","tool_use_id":"toolu_A","content":"In stock"},
    {"type":"tool_result","tool_use_id":"toolu_B","is_error":true,"content":"Inventory lookup timed out"}
  ]}
]

To reproduce the missing-result error, remove the second result block and check the shortened array. The unanswered ID is toolu_B. To reproduce unexpected tool_use_id, keep both results but change the second result's ID to toolu_C. This time there is a result pointing to a call the assistant never made. The first fix restores a reply. The second fixes its ID. Claude tool use troubleshooting

Recover after a timeout, retry, or history trim

If the same request fails on every retry, compare the messages saved before the interruption with the messages your app sent after it resumed. Put the two message arrays in Text Compare and look for a call that disappeared or a reply that moved. A Claude Code issue reports a surviving result that referred to a call missing from the shortened history. Claude Code issue #13964

What the outgoing history shows What to recover
The call is present. Its result is missing. Look up the execution record by call ID. If it finished, restore the recorded result. If it failed, return the recorded failure.
The result is present. Its call disappeared after a history trim. Restore the assistant turn that issued the call and its replies. When trimming older completed history, keep or remove the whole exchange together.
A retry added a second result for the same call. Keep the recorded reply for that execution once. Check where both the retry handler and normal completion append to history.
The process stopped after starting an action, and its outcome is unknown. Check the system that performed the action. For example, look for the ticket it may already have created before attempting to create another one.

Tip: Keep one test where the same function runs twice with different arguments and the second call finishes first. Check both the IDs and the returned values. Swapping two stock answers can satisfy the API's pairing rules while giving the customer the wrong answer.