Invalid schema error: Missing 'workdir' in function 'shell'
What version of Codex is running?
0.1.2504220136
Which model were you using?
o4-mini
What platform is your computer?
Darwin 24.4.0 arm64 arm
What steps can reproduce the bug?
<img width="912" alt="Image" src="https://github.com/user-attachments/assets/fc042e30-4c82-480d-a995-f173803fab1d" />
Steps to reproduce:
- Install Codex CLI:
``bash``
npm install -g @openai/codex
- Set the OpenAI API key:
``bash``
export OPENAI_API_KEY="your-api-key-here"
- Create the configuration file at
~/.codex/config.jsonwith the following content:
``json``
{
"model": "o4-mini",
"approvalMode": "suggest",
"fullAutoErrorMode": "ask-user",
"notify": true
}
- Run the Codex CLI:
``bash``
codex
- At the prompt, enter:
``bash``
hello
What is the expected behavior?
Expected behavior:
The CLI should process the input and provide a response without errors.
What do you see instead?
Actual behavior:
The CLI returns a 400 error indicating a missing 'workdir' in the function schema.
Additional information
The configuration file is correctly set up, and the API key is exported. Despite this, the error persists.
Describe the bug:
When running the Codex CLI, I encounter the following error:
⚠️ OpenAI rejected the request (request ID: req_XXXXXXXXXXXX). Error details:
Status: 400, Code: invalid_function_parameters, Type: invalid_request_error, Message: 400 Invalid schema for function 'shell': In context=(), 'required' is required to be supplied and to be an array including every key in properties. Missing 'workdir'.. Please verify your settings and try again.
14 Comments
yep getting this issue as well as soon as I updated this on NPM
OS: macOS
same here, looks broken currently. Was just trying it out. Also mac.
I encountered an issue with the latest version. You can install the previous stable version instead: @openai/codex@0.1.2504211509.
Thank you for sharing, @openai/codex@0.1.2504211509 versions works
Same thing here in Windows
"OpenAI rejected the request (request ID: req_d4468dd0095cea7e29a4ffbe9f7314a2). Error details: Status: 400, Code:
invalid_function_parameters, Type: invalid_request_error, Message: 400 Invalid schema for function 'shell': In context=(),
'required' is required to be supplied and to be an array including every key in properties. Missing 'workdir'.. Please
verify your settings and try again."
Same thing here in Windows 11, also using @openai/codex@0.1.2504211509. , error persist
I'm using WSL Debian under Windows 11
OpenAI rejected the request (request ID: req_xxxxxxx). Error details: Status: 400,
Code: invalid_function_parameters, Type: invalid_request_error, Message: 400 Invalid schema for function 'shell': In
context=(), 'required' is required to be supplied and to be an array including every key in properties. Missing
'workdir'..
ahahaha yeah, i spent ages, thought i might be able to inject the payload directly through terminal but to no avail. going back to the earlier as mentioned worked for me.
Same issue for me. Reverting to old version until this is fixed.
@openai/codex@0.1.2504211509 version works fine in Windows 11
Same in ubuntu
For all users -- Here's what works for me, or roll back versioning:
Bug Found & Fixed: Invalid Schema for Function 'shell'
After investigating this issue, I found that the OpenAI API has changed its validation requirements for function schemas. The API now requires that all properties defined in a schema must be included in the
requiredarray.Root Cause
In
codex-cli/src/utils/agent/agent-loop.ts, the 'shell' function schema defines properties forcommand,workdir, andtimeout, but therequiredarray only includescommand.Fix
The solution is to include all properties in the
requiredarray:How to Apply the Fix
codex-cli/src/utils/agent/agent-loop.tsrequiredarray to include all properties as shown aboveAfter applying this fix, the tool should work correctly. The error occurs because the OpenAI API now enforces stricter schema validation, requiring all defined properties to be listed in the
requiredarray, even if they should be optional in practice.did anyone made any pr with this change?
Back to the previous available that was working
npm uninstall -g @openai/codexnpm view @openai/codex versions-- If you wanna see the latestnpm install -g @openai/codex@0.1.2504211509Should be fixed in latest release, please install 0.1.2504221401 and re-open if this is still an issue you encounter.