openai / openai/codex

bug: BadRequestError (string_above_max_length) when running /compact command

Open
#44,414 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug CLI context
Dominant language
Rust
Stars
125k
Forks
19.4k
PR merge metrics
PR metrics pending

Description

What version of Codex CLI is running?

0.154.0

What subscription do you have?

Pro

Which model were you using?

gpt-5.6-sol high

What platform is your computer?

Ubuntu x86_64 x86_64 x86_64 GNU/Linux

What terminal emulator and version are you using (if applicable)?

vscode terminal

Codex doctor report
└ {
      "schemaVersion": 1,
      "generatedAt": "1789014949s since unix epoch",
      "overallStatus": "ok",
      "codexVersion": "0.154.0",
      "checks": {
        "app_server.status": {
          "id": "app_server.status",
          "category": "app-server",
          "status": "ok",
          "summary": "background server is not running",
          "details": {
            "control socket": "/mnt/nas/neil/.codex/app-server-control/app-server-control.sock",
            "daemon state dir": "/mnt/nas/neil/.codex/app-server-daemon",
            "mode": "ephemeral",
            "pid file": "/mnt/nas/neil/.codex/app-server-daemon/app-server.pid (missing)",
            "settings": "/mnt/nas/neil/.codex/app-server-daemon/settings.json (missing)",
            "status": "not running",
            "update-loop pid file": "/mnt/nas/neil/.codex/app-server-daemon/app-server-updater.pid (missing)"
          },
          "remediation": null,
          "durationMs": 3
        },
        "auth.credentials": {
    … +308 lines (ctrl + t to view transcript)
          },
          "remediation": null,
          "durationMs": 0
        },
        "updates.status": {
          "id": "updates.status",
          "category": "updates",
          "status": "ok",
          "summary": "update configuration is locally consistent",
          "details": {
            "cached latest version": "0.154.0",
            "check for update on startup": "true",
            "dismissed version": "0.149.0",
            "last checked at": "2026-09-10T02:06:22.938049465Z",
            "latest version": "0.154.0",
            "latest version status": "current version is not older",
            "npm update target": "not inspected (PATH helpers are not executed)",
            "update action": "npm install -g @openai/codex",
            "version cache": "/mnt/nas/neil/.codex/version.json"
          },
          "remediation": null,
          "durationMs": 1118
        }
      }
    }
What issue are you seeing?

■ {"error":{"message":"{"error":{"message":"***.BadRequestError: OpenAIException - {\"error\":{\"code\":\"string_above_max_length\",\"message\":\"Invalid
'input[430].id': string too long. Expected a string with maximum length 64, but got a string with length 227 instead.\",\"param\":\"input[430].id\",\"type\":\
"invalid_request_error\"}}. Received Model Group=gpt-5.6-sol\nAvailable Model Group Fallbacks=None","type":"invalid_request_error","param":"","code":
"400"}}","type":"invalid_request_error","code":null}}

What steps can reproduce the bug?
Describe the Bug

When using the /compact command in Codex CLI to compress or summarize the current context, the tool crashes and throws a 400 BadRequestError from the OpenAI/upstream API.

The error indicates that an internal parameter input[430].id generated or forwarded by the CLI has a length of 227 characters, which violates OpenAI's maximum limit of 64 characters for the id field.

To Reproduce
  1. Open Codex CLI and have a relatively long session (or process long terminal commands/file paths).
  2. Type and execute the command: /compact
  3. See the error message below.
Error Stack / Log Output
{ 
  "error": { 
    "message": { 
      "error": { 
        "message": "***.BadRequestError: OpenAIException - {\\\"error\\\":{\\\"code\\\":\\\"string_above_max_length\\\",\\\"message\\\":\\\"Invalid input[430].id: string too long. Expected a string with maximum length 64, but got a string with length 227 instead.\\\",\\\"param\\\":\\\"input[430].id\\\",\\\"type\\\":\\\"invalid_request_error\\\"}}. Received Model Group=gpt-5.6-sol\\nAvailable Model Group Fallbacks=None", 
        "type": "invalid_request_error", 
        "param": "", 
        "code": "400" 
      }
    }, 
    "type": "invalid_request_error", 
    "code": null
  }
}
What is the expected behavior?
Expected Behavior

The /compact command should successfully compress the conversation context. Any internally generated or tracked id (such as tool call IDs or message IDs) forwarded to the OpenAI API should be validated, truncated, or hashed to stay within the strict 64-character limit imposed by OpenAI.

Additional information
Expected Behavior

The /compact command should successfully compress the conversation context. Any internally generated or tracked id (such as tool call IDs or message IDs) forwarded to the OpenAI API should be validated, truncated, or hashed to stay within the strict 64-character limit imposed by OpenAI.

Suggested Fix

In the backend logic handling the /compact command or the API request payload builder, please ensure that all id fields in the input / messages array are truncated or safe-guarded:

# Pseudo-code example for payload validation
if len(str(item.get("id", ""))) > 64:
    item["id"] = str(item["id"])[:64]

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Codex CLI /compact command and trace how it builds the upstream request payload, focusing on the input[430].id value reported in the error. Reproduce with a long session and verify that compaction succeeds without any forwarded ID exceeding 64 characters.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.