Skip to content

Fix Codex resume fork detection rejecting same-cwd rollout with prompt lineage but no shared item ids #193

Description

@Juliusolsson05

Problem

A resumed Codex pane can show transcript unavailable even while the conversation mostly continues rendering.

Bundle:

/Users/juliusolsson/.config/agent-code/debug-bundles/2026-05-17T12-04-00-107-b6c85d86

Error in state snapshot:

Codex resume: ignoring same-cwd rollout /Users/juliusolsson/.codex/sessions/2026/05/17/rollout-2026-05-17T13-45-54-019e35c1-cff4-79e1-aff8-e96a7d43b61b.jsonl — only 0/3 item ids shared with resumed file /Users/juliusolsson/.codex/sessions/2026/05/16/rollout-2026-05-16T19-51-18-019e31e9-fa43-7bc1-af2b-3c65c96d39cf.jsonl; treating it as an unrelated session.

Observed effect:

  • state-snapshot.json has transcriptStatus: "error" and the above transcriptError.
  • The UI still renders some of the conversation, but user prompts can be missing because the committed transcript channel is no longer confidently attached to the correct rollout file.
  • The rejected candidate has the same cwd and contains the same user-visible conversation lineage, but the item-id overlap guard sees 0/3 shared opaque ids.

Why this happens

packages/codex-headless/src/CodexHeadless.ts accepts a newly-created same-cwd rollout during resume only when it shares enough opaque rollout ids with the original resumed file. That is too strict for resumed/reconstructed/compacted Codex rollouts: Codex can preserve the user-visible conversation while minting new response/item ids, so opaque-id overlap can be zero even for the correct successor file.

Likely fix

Extend resume fork detection beyond opaque item ids:

  • keep cwd + freshness checks
  • keep item-id overlap as the strongest signal
  • add a secondary user-visible prompt lineage signal from rollout response_item user messages / event_msg:user_message
  • accept a same-cwd candidate when recent prompt overlap is strong enough, even if opaque item-id overlap is zero
  • keep diagnostics explicit so sibling-agent rejection remains debuggable

This probably belongs in codex-headless first, then an Agent Code submodule bump.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions