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?
Steps to reproduce:
-
Install Codex CLI:
npm install -g @openai/codex -
Set the OpenAI API key:
export OPENAI_API_KEY="your-api-key-here" -
Create the configuration file at
~/.codex/config.jsonwith the following content:{ "model": "o4-mini", "approvalMode": "suggest", "fullAutoErrorMode": "ask-user", "notify": true } -
Run the Codex CLI:
codex -
At the prompt, enter:
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.
yep getting this issue as well as soon as I updated this on NPM OS: macOS
system
⚠️ OpenAI rejected the request (request ID: req_XXXXXXXX). 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 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/[email protected].
I encountered an issue with the latest version. You can install the previous stable version instead: @openai/[email protected].
Thank you for sharing, @openai/[email protected] 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/[email protected]. , 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'..
I encountered an issue with the latest version. You can install the previous stable version instead: @openai/[email protected].
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/[email protected] 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 required array.
Root Cause
In codex-cli/src/utils/agent/agent-loop.ts, the 'shell' function schema defines properties for command, workdir, and timeout, but the required array only includes command.
Fix
The solution is to include all properties in the required array:
parameters: {
type: "object",
properties: {
command: { type: "array", items: { type: "string" } },
workdir: {
type: "string",
description: "The working directory for the command.",
},
timeout: {
type: "number",
description: "The maximum time to wait for the command to complete in milliseconds.",
},
},
- required: ["command"],
+ required: ["command", "workdir", "timeout"],
additionalProperties: false,
},
How to Apply the Fix
- Edit
codex-cli/src/utils/agent/agent-loop.ts - Find the shell function schema definition (around line 651)
- Update the
requiredarray to include all properties as shown above - Build and reinstall the package:
cd /path/to/codex
cd codex-cli
pnpm run build
npm install -g .
After 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 required array, 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/codex
npm view @openai/codex versions -- If you wanna see the latest
npm install -g @openai/[email protected]
Should be fixed in latest release, please install 0.1.2504221401 and re-open if this is still an issue you encounter.