Fresh install of openai/codex only gives error

Resolved 💬 4 comments Opened Apr 22, 2025 by jarlehildrum Closed Apr 22, 2025

What version of Codex is running?

0.1.2504220136

Which model were you using?

o4-mini

What platform is your computer?

darwin | arm64 | 24.4.0

What steps can reproduce the bug?

  • ```

explain code to me
```

  • 0 reasoning | 0 tool

What is the expected behavior?

The code explained.

What do you see instead?

system
⚠️ OpenAI rejected the request (request ID: req_d2e8619e6762aa639b20f95f9f704125). 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.

Additional information

It did have the context of the workdir, so this was a bit suprising:

│ ● OpenAI Codex (research preview) v0.1.2504220136 │
╰──────────────────────────────────────────────────────────────╯
╭──────────────────────────────────────────────────────────────╮
│ localhost session: 9f8500b755264a16a7f5790993e3ae7f │
│ ↳ workdir: ~/repos/test/2025/3-mars/ragapp │
│ ↳ model: o4-mini │
│ ↳ provider: openai │
│ ↳ approval: suggest │
╰──────────────────────────────────────────────────────────────╯
user
explain code to me

View original on GitHub ↗

4 Comments

notekpl · 1 year ago

I have this same error from freshly installed Codex v0.1.2504220136 with ChatGPT assistance.
Darwin 24.1.0 ARM64
No further suggestion except install year old version.

kaavee315 · 1 year ago

Same here, I am also getting this error.

The-Obstacle-Is-The-Way · 1 year ago

For all users -- here is the solution that works for me:

## 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:

```diff
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

  1. Edit codex-cli/src/utils/agent/agent-loop.ts
  2. Find the shell function schema definition (around line 651)
  3. Update the required array to include all properties as shown above
  4. 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.


Or roll back versioning as it was introduced in the latest commit. 
jarlehildrum · 1 year ago

Seems like this has been fixed in the code repo just now. I did a
npm update -g @openai/codex
...and it was working.

Thanks!