Automatic context compaction fails with unsupported `context_compaction` item type
Summary
Automatic context compaction can fail because Codex appears to send an input item with type: "context_compaction", but the current API schema rejects that value.
Error
[ItemParam] [input[4]] [invalid_enum_value] Invalid value: 'context_compaction'. Supported values are: 'additional_tools', 'apply_patch_call', 'apply_patch_call_output', 'code_interpreter_call', 'compaction', 'compaction_trigger', 'computer_call', 'computer_call_output', 'custom_tool_call', 'custom_tool_call_output', 'file_search_call', 'function_call', 'function_call_output', 'image_generation_call', 'item_reference', 'local_shell_call', 'local_shell_call_output', 'mcp_approval_request', 'mcp_approval_response', 'mcp_call', 'mcp_list_tools', 'message', 'reasoning', 'shell_call', 'shell_call_output', 'tool_search_call', 'tool_search_output', and 'web_search_call'.
Environment
- Codex CLI:
codex-cli 0.130.0 - Platform: Linux
- Trigger: a long-running Codex session when automatic context compaction was attempted
Investigation
I checked the project workspace and did not find context_compaction in the repository code.
The installed Codex binary at ~/.local/bin/codex contains context_compaction as an item type, including strings related to remote compaction v2, for example:
remote compaction v2 expected exactly one context_compaction output item
remote compaction v2 returned context_compaction without encrypted_content
ResponseItem ... compaction context_compaction other
The same binary did not appear to contain compaction_trigger, while the API error says compaction_trigger is supported and context_compaction is not.
Expected behavior
Automatic context compaction should complete successfully, or Codex should normalize any internal compaction item type to an API-supported item type before sending the next request.
Actual behavior
The next request fails schema validation before model execution because context_compaction is present in the request input.
Workaround
Starting a new thread and manually carrying over the relevant summary avoids the bad history item, but the original long-running thread remains blocked once the invalid item is present.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗