Claude Code session imports ignore compaction and exceed the Responses input item limit
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 68/100
Research direction
Start with codex-rs/external-agent-migration/src/sessions/records.rs and export.rs to trace how Claude user and assistant records become rollout items and token usage. Then inspect the existing resume reconstruction for RolloutItem::Compacted and replacement_history. Done means isCompactSummary records create a bounded compaction checkpoint, preserve older imported history, and avoid replaying the full transcript on follow-up.
Written by the indexing model from the issue text.
Description
What issue are you seeing?
External-agent session import treats Claude Code compaction summaries as ordinary user messages. The imported rollout therefore contains every pre- and post-compaction message as model-visible ResponseItems instead of using the source summary as a replacement-history checkpoint.
On the first follow-up to a large imported task, Codex attempts automatic compaction with the entire flattened history. The Responses API rejects the request before it can compact:
Invalid 'input': array too long. Expected an array with maximum length 16384, but got an array with length 76298 instead
The UI then reports automatic compaction, reconnects twice, and ends with:
stream disconnected before completion: websocket closed by server before response.completed
The websocket failure is downstream of the invalid oversized request.
What steps can reproduce the bug?
- Create or use a Claude Code project session JSONL with enough ordinary
user/assistantrecords to exceed 16,384 model input items. - Include a normal Claude compaction pair in the source history:
- a
systemrecord withsubtype: "compact_boundary"; - the following
userrecord withisCompactSummary: trueand the replacement summary inmessage.content.
- a
- Import Claude Code sessions through Codex Desktop's external-agent migration.
- Resume the imported task and send a follow-up message.
In one sanitized reproduction, the imported rollout persisted 76,295 user/assistant ResponseItems. Runtime context added three more items, producing the exact rejected array length of 76,298. A second imported session persisted 17,589 response messages and was already over the API limit before runtime items were added.
What is the expected behavior?
Claude's isCompactSummary record should become a native Codex RolloutItem::Compacted checkpoint with bounded replacement_history. Older records should remain available as visible imported history, while model reconstruction should start from the latest source summary and replay only the post-compaction tail.
Following up on an imported compacted session should not trigger re-compaction of the entire flattened source transcript or exceed the Responses API item limit.
Additional information
Current main still has the flattening behavior in:
codex-rs/external-agent-migration/src/sessions/records.rs, which recognizes user/assistant records but does not classifyisCompactSummary;codex-rs/external-agent-migration/src/sessions/export.rs, which emits one model-visibleResponseItemper parsed message and accumulates token usage across the full import.
Codex resume reconstruction already supports the needed representation: the newest RolloutItem::Compacted with replacement_history becomes the model-history base while older rollout events remain persisted for thread history.
- Dominant language
- Rust
- Stars
- 125k
- Forks
- 19.5k
- Avg merge
- 1m
- Merged PRs (30d)
- 1k
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from openai/codex
-
enhancement remote
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
bug CLI windows-os
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
macOS sandbox blocks hw.optional.arm64 sysctl, causing Flutter to misdetect Apple Silicon as x64 Openbug CLI sandbox
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug CLI TUI
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
CLI config enhancement skills
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
kwakseongjae/auto-hwp#319 ·
-
area:cli bug filter-quality good first issue priority:medium
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
bevyengine/bevy#25861 ·
-
comp-datalake
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/ClickHouse#121222 ·
-
A-linter
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
oxc-project/oxc#26863 ·