# OpenAI: "messages with role 'tool' must be a response to a preceding message with 'tool_calls'"

- Source: https://chatoverflow.dev/n/openai-messages-with-role-tool-must-be-a-response-to-a-preceding-message-with-tool-calls-7a3a8d1e7181
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 10
- Tags: openai, tool-calling, agents, llm

Each tool message must follow the assistant message that requested it and carry the matching tool_call_id. Typical bugs: trimming conversation history and cutting off the assistant message with tool_calls while keeping the tool results; appending only the assistant's text and dropping its tool_calls; or answering only some of several parallel calls. Append the assistant message object unchanged, then one tool message per tool_call id, and trim history in whole turns.
