bug: Unable to continue due to rejections of calls with tools
Resolved 💬 11 comments Opened May 20, 2025 by Parry-97 Closed Aug 7, 2025
What version of Codex is running?
0.1.2505172129
Which model were you using?
gpt-4.1
What platform is your computer?
Linux 6.14.6-arch1-1 x86_64 unknown
What steps can reproduce the bug?
- Ask the model to review existing code and provide a patch for problem
What is the expected behavior?
- Codex is able to analyze the codebase and provide an answer to the problem
What do you see instead?
OpenAI rejected the request (request ID: bd4da2f4-5638-4b2c-9936-166680e2147f). Error details: Status: 400,
Code: unknown, Type: invalid_request_error, Message: 400 An assistant message with 'tool_calls' must be followed by
tool messages responding to each 'tool_call_id'. The following tool_call_ids did not have response messages:
call_jyZIBoEd5TQ76uxKIxRzzizf, call_7BwexvVmOzM8wlu6UvDTvyZS. Please verify your settings and try again.
Additional information
No tool definitions have been added in the config. The model has been deployed to Azure OpenAI.
11 Comments
I get a lot of these as well.
ditto
clear
Getting the same while using Azure OpenAI provider. Any resolutions?
Same issue, sometimes it works by changing the prompt, but most of the time it fails. I'm also using AzureOpenAI
I can reproduce this with Azure and gpt-4o as well.
I believe it's related to failed error codes returned from the command executed. For example, if I request to find files with a specific exception and then grep for a pattern, it might use the find command and the create an array of tool_calls for each grep. If the pattern is not found and grep returns an error code, I see it return a response with only the failed command which then produces the error message described.
I'm not sure but it might be specific to if the first tool_call fails.
If I rephrase the prompt so that it decides to use grep with *.extension directly and skips using find then I do not see the error message. Or if the pattern exists in all files that find returns (so grep never returns an error code) then I also do not see the issue.
I am using gpt-40-mini connect to openai in Azure and I receive the same message. I try to use codex -p azure -m gpt-4o-mini --no-tools but the same error occurs again.
OpenAI rejected the request (request ID: ). Error details: Status: 400, Code: unknown, Type:
invalid_request_error, Message: 400 An assistant message with 'tool_calls' must be followed by tool messages responding to each 'tool_call_id'. The
following tool_call_ids did not have response messages: call_Bq9CrS1DrmMCiMY8ebupzbOn, call_byBSvvX4wsoobx6F1eiWTidi, call_2AjqBrlZhnO9mXav9usFgxw0,
call_jQkgucK6d9xaD1guZRNhl2cy, call_QlhYlXPtvGxRjuMNOpfLbpAm, call_QGHWaqnScN7FMWfE7rIwVWft, call_32FjRElIaFvT6kaDha7lSjxw,
call_KUxA4e4bLNAgs6IWTeShlKyh, call_mEhM2JyuROb85zCCuKO0l7Wu. Please verify your settings and try again.
I have this issue a lot as well especially with Azure OpenAI.
My workaround for now is to ask to 'return to this tool_call {{ID}} with an error and continue the work.'
PR #1193 appears to have logic that could address this issue.
Thank you for the feedback! Please try again on the latest version of Codex CLI. If the issue persists, we'd be happy to take a look.
The same issue: by adding the following adjustment under the model_providers section, it started working:
wire_api = "responses"