Repository navigation
Description
What version of the Codex App are you using (From “About Codex” dialog)?
26.721.81911
What subscription do you have?
plus
What platform is your computer?
No response
What issue are you seeing?
Bug: Codex session resume fails with Invalid 'input[x].content': array too long due to incompatible reasoning items in rollout JSONL
Description
When resuming an existing Codex session, Codex fails with the following error:
Invalid 'input[7].content': array too long.
Expected an array with maximum length 0, but got an array with length 1 instead.
This is not caused by exceeding the context window or token limit.
The issue appears to be caused by incompatible reasoning items written into the local session history (rollout-*.jsonl) by a third-party Responses API compatible provider.
After switching back to the official OpenAI API endpoint, Codex reloads the existing session history and sends the persisted items for replay. The official Responses API rejects the stored reasoning.content format because reasoning items should not contain a content array.
Environment
- Codex CLI version:
<version> - OS:
<OS> - API provider:
- Created session with: third-party OpenAI-compatible Responses API provider
- Resumed session with: official OpenAI API
Steps to reproduce
- Configure Codex to use a third-party OpenAI-compatible API provider.
- Start a Codex session.
- Generate responses that contain reasoning items.
- Allow Codex to save the session locally.
- Switch the configuration back to the official OpenAI API endpoint.
- Resume the previous session.
Expected:
- Codex should either migrate incompatible history entries or skip unsupported fields.
Actual:
Codex fails while replaying the stored history:
Invalid 'input[7].content': array too long.
Expected an array with maximum length 0, but got an array with length 1 instead.
Root cause
The affected rollout-*.jsonl contains entries like:
{
"type": "response_item",
"payload": {
"type": "reasoning",
"content": [
{
"type": "reasoning_text",
"text": "..."
}
]
}
}The third-party provider writes reasoning.content as an array.
However, when the official Responses API validates the replayed history, reasoning items do not accept content arrays:
Expected:
{
"type": "response_item",
"payload": {
"type": "reasoning",
"content": null
}
}Received:
{
"type": "response_item",
"payload": {
"type": "reasoning",
"content": [...]
}
}The API validation fails because:
Expected an array with maximum length 0
Got an array with length 1
Temporary workaround
Manually edit the affected session file:
~/.codex/sessions/**/rollout-*.jsonl
First create a backup.
Then only modify entries where:
type == "response_item"
AND
payload.type == "reasoning"
AND
payload.content is an arrayChange:
{
"type": "response_item",
"payload": {
"type": "reasoning",
"content": [...]
}
}to:
{
"type": "response_item",
"payload": {
"type": "reasoning",
"content": null
}
}After this change, the session can resume normally.
Expected behavior
Codex should handle incompatible persisted session records more gracefully.
Possible solutions:
- Ignore invalid
reasoning.contentfields when loading old sessions. - Sanitize/migrate rollout JSONL before sending history to the Responses API.
- Detect incompatible provider-generated session records and show a clear migration error.
- Avoid persisting provider-specific fields that are not compatible with the official Responses API schema.
Additional notes
This issue is easy to confuse with context length problems because it happens during session resume.
However, this is a schema validation error:
- Not related to token count.
- Not related to context window size.
- Not related to prompt length.
The failure occurs because persisted local session data contains a reasoning.content structure that is rejected by the official Responses API.
What steps can reproduce the bug?
Steps to reproduce
-
Configure Codex CLI to use a third-party OpenAI-compatible Responses API provider.
-
Start a new Codex session and have a normal conversation. The provider writes response items into the local Codex session history.
-
Check the generated session file:
~/.codex/sessions/<session-id>/rollout-*.jsonl
The file contains entries similar to:
{
"type": "response_item",
"payload": {
"type": "reasoning",
"content": [
{
"type": "reasoning_text",
"text": "..."
}
]
}
}-
Switch Codex configuration back to the official OpenAI API endpoint.
-
Resume the previous session using the same session id.
-
Codex attempts to replay the stored history and fails with:
Invalid 'input[7].content': array too long.
Expected an array with maximum length 0, but got an array with length 1 instead.
Session information
Session id:
<insert affected session id here>
Rollout file:
~/.codex/sessions/<session-id>/rollout-<timestamp>.jsonl
Context/token information
This issue is not related to context length.
At the time of failure:
- Context window usage: not exceeded
- Token limit: not exceeded
- Failure occurs during session history validation before model execution
The error is caused by invalid persisted history format, specifically:
payload.type = "reasoning"
payload.content = [...]
which is rejected by the official Responses API schema.
Minimal reproduction
A minimal corrupted rollout entry is:
{
"type": "response_item",
"payload": {
"type": "reasoning",
"content": [
{
"type": "reasoning_text",
"text": "example"
}
]
}
}When this entry is loaded and replayed through the official Responses API, it produces:
Invalid 'input[x].content':
array too long.
Expected an array with maximum length 0, but got an array with length 1 instead.
Changing:
"content": [...]to:
"content": nullallows the session to resume normally.
What is the expected behavior?
No response
Additional information
No response
Activity
feat(detectors): SL305 provider-incompatible record shape (T-05)
thom-at-redhat commentedon Oct 9, 2026
Additional confirmation on Linux with Codex CLI 0.162.0, observed on 2026-10-09.
The affected thread began with a third-party Responses-compatible provider (EnMaas), model
rits/zai-org/glm-5-3. After an unrelated provider authentication failure, its model/provider settings were changed togpt-6.1-solon the official OpenAI API through a named CLI profile. Persistedthread_settings_appliedevents confirm that the provider change took effect, while the thread ID remained the same.The next two continuation attempts failed at 20:13:39 UTC and 20:15:04 UTC with:
A read-only structural inspection found 62 retained reasoning items, each with an empty
summary, onereasoning_textcontent entry, andencrypted_content: null. The following is an illustrative shape; the text is synthetic:{ "type": "reasoning", "summary": [], "content": [{"type": "reasoning_text", "text": "synthetic example"}], "encrypted_content": null }This corroborates the reported cross-provider replay incompatibility on CLI 0.162.0. The actual outgoing request was not captured, so the exact mapping from
input[7]to a stored item remains unverified. No isolated reproduction or history-editing workaround was tested, and the original rollout was left unchanged.This report contains metadata and a synthetic item shape only; no private prompts, reasoning text, credentials, internal hostnames, paths, or session identifiers are included. Graceful handling of incompatible provider history, or a clear compatibility message before continuation, would make this failure easier to recover from.
telemetrya2018-dotcom commentedon Oct 20, 2026
Windows follow-up observed2026-10-20 through an OpenMausBot app-server integration (related report: milind-soni/OpenMausBot#3148). An already-existing native session resumed and then failed before tools with HTTP400 invalid_request_error, array_above_max_length, param input[102].content, maximum0 versus length1. This is not the earlier max_output_tokens failure in that conversation.
Read-only structure inspection of the exact rollout returned by thread/resume found85 reasoning records, including2 with nonempty reasoning_text content, empty summary, and no encrypted_content. The original session metadata records CLI0.163.0, while a separate present-day shell command resolution returns0.150.1; neither is being presented as proof of the failed app-server executable version. That version/route provenance remains part of the investigation.
The exact outbound HTTP item102 has not been captured, so the stored shapes corroborate a compatibility hypothesis but do not conclusively identify that rejected item. No original rollout was edited, no history dropped, no model or credentials changed, and the failed assignment was not resubmitted. Is there a supported request-time compatibility/repair path which preserves the original session history?
No user prompts, private reasoning text, credentials, native session IDs or local paths included. Marker: OMB-installed0453-resume-shape.
CieveMe commentedon Oct 22, 2026
Additional affected case on Windows, observed October 23, 2026 (UTC+8).
Desktop logs identify client version
26.1016.51333; the model manager reports client version0.163.0(these are different version fields).An existing chat contains turns previously generated with
deepseek-flash. Continuing withgpt-6.1-solfails twice, at 00:26:42 and 00:26:57 UTC+8, with HTTP 400,invalid_request_error, codearray_above_max_length:Read-only reconstruction from the latest local replacement history plus subsequent response items yields 541 items. Zero-based item 422 is a reasoning item with one
reasoning_textcontent entry and a non-nullencrypted_contentfield. There are 36 reasoning items with nonempty content in that reconstructed history. Their original turn contexts identifydeepseek-flash. No reasoning text or encrypted payload is included here.This is evidence from an affected chat, not an independent reproduction in a fresh chat. The full outbound request was not captured, so the matching local index is diagnostic evidence rather than proof of the exact wire payload. The third-party integration details and responsible conversion layer remain unverified. No session/database/configuration was edited and no repair was tested.
Is there a supported way to resume an affected chat while preserving user/assistant messages, and should incompatible foreign reasoning items be handled during replay or reported with an actionable recovery path?
Disclosure: AI assistance was used to prepare this comment; the reported metadata was checked against local files and logs.
billy-enrizky commentedon Nov 5, 2026
Confirmed on Codex CLI 0.166.0 (macOS) with a wire-level reproduction and a proposed fix.
Environment
deepseek-ai/DeepSeek-V4.1-Flash-1017through a Responses-compatible LiteLLM gateway.gpt-6-luna, also through the gateway./compactboth fail with HTTP 400,array_above_max_length.Exact item and index, proven
The thread has 236
response_itementries of typereasoning, all withsummary: [],content: [{"type":"reasoning_text", ...}], andencrypted_content: null.gpt-6-lunahasuse_responses_lite: true, sobuild_responses_requestprepends anadditional_toolsinput item. The normal turn request is:Replaying exactly those first five items to the same endpoint:
Invalid 'input[4].content': array too long. Expected an array with maximum length 0, but got an array with length 1 instead.contentset tonull: HTTP 200/compactfails one index earlier, atinput[3].content, because the compaction prompt has no tools and therefore noadditional_toolsprefix. This confirms the rejected item is the stored reasoning item, not a token or context-length problem.Model matrix for the same item at index 4:
content: [reasoning_text]content: nullarray_above_max_lengtharray_above_max_lengtharray_above_max_lengthDropping inline reasoning text on replay is therefore safe for the OpenAI models and the two third-party models tested.
Why compaction does not recover the thread
run_inline_auto_compact_taskbuildsturn_inputfromhistory.clone().for_prompt(...)and sends it throughbuild_responses_request. The validator rejects the history before a summary can be produced, so compaction cannot repair the thread.Code path
codex-rs/protocol/src/models.rs,should_serialize_reasoning_content: keepsReasoningItemContent::ReasoningTextin the serializedreasoningitem, socontentis sent as a non-empty array.codex-rs/core/src/client.rs,build_responses_request: copiesprompt.get_formatted_input_for_request(model_info)intoinputand does not clear foreignreasoning.content. The!is_openaibranch clears metadata and encrypted content, but not reasoning content.Proposed fix
Request-time only, persisted history unchanged:
Optional cleanup so the field is omitted instead of sent as null:
If keeping inline reasoning for models that accept it matters, gate the clear behind a new
ModelInfocapability (default false) and opt in DeepSeek/GLM. An unconditional clear is simpler and matched every model tested.Workaround verified today
With a full backup, rewrite every
response_itemwherepayload.type == "reasoning"andpayload.contentis a non-empty array, settingpayload.content = null. Keep the reasoning items themselves, includingsummaryandencrypted_content. After clearing 236 items, the first five request items replayed with HTTP 200 and the thread became resumable. Compaction then passes the same validator, because the rejected item no longer carries content.Related: #56155 (GLM, compaction), #36704 (stale encrypted reasoning).