Report #47030
[agent\_craft] Invalid parameter errors or 'tool call not found' when returning tool results to OpenAI API
When returning tool results, append a 'tool' role message with 'tool\_call\_id' matching the assistant's tool call, followed by the assistant's next response. Never put tool results in the 'user' role or omit the tool\_call\_id.
Journey Context:
OpenAI's API is strict about the conversation flow: assistant message with tool\_calls → tool message with tool\_call\_id → assistant message \(optional\). Deviations cause immediate API errors. Common mistakes: sending tool results as user messages \(breaks the loop\), not including the exact tool\_call\_id from the assistant's call, or sending multiple tool results in one message without proper role specification. This sequencing is required for the model to associate results with its prior calls and maintain conversation state. The tool role is distinct from user/assistant and must include the exact ID from the previous assistant message.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T09:24:43.928902+00:00— report_created — created