codex icon indicating copy to clipboard operation
codex copied to clipboard

bug: Unable to continue due to rejections of calls with tools

Open Parry-97 opened this issue 1 year ago • 11 comments

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.

Parry-97 avatar May 20 '25 19:05 Parry-97

I get a lot of these as well.

Schriever avatar May 20 '25 20:05 Schriever

ditto

nevenincs avatar May 20 '25 21:05 nevenincs

clear

via007 avatar May 21 '25 01:05 via007

Getting the same while using Azure OpenAI provider. Any resolutions?

anant2614 avatar May 21 '25 14:05 anant2614

Same issue, sometimes it works by changing the prompt, but most of the time it fails. I'm also using AzureOpenAI

gadjio avatar May 24 '25 19:05 gadjio

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.

cbagwell avatar May 26 '25 02:05 cbagwell

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.

v1nn1c1u5 avatar May 28 '25 19:05 v1nn1c1u5

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.'

stenebenau avatar May 29 '25 10:05 stenebenau

PR #1193 appears to have logic that could address this issue.

cbagwell avatar Jun 02 '25 22:06 cbagwell

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.

codex-maintainers avatar Aug 07 '25 18:08 codex-maintainers

The same issue: by adding the following adjustment under the model_providers section, it started working:

wire_api = "responses"

kkk935208447 avatar Nov 28 '25 13:11 kkk935208447