Skip to content

codex: session-history mirror tests fail on pristine main on macOS (blocks local scripts/pr gates) #99857

Closed

Description

@steipete

What happened?

extensions/codex/src/app-server/session-history.test.ts fails 3 of 4 tests on a pristine origin/main checkout on macOS, while main CI (Linux) is green. This makes the scripts/pr local prepare-gates lane (full pnpm test) unpassable on affected machines for any PR, regardless of its diff.

Failing tests (readCodexMirroredSessionHistoryMessages):

  • replays only the branch selected by a leaf control
  • keeps visible history when continuation rows use a disjoint append cursor
  • keeps visible history when a continuation references the leaf marker

Assertion shape: the reader returns assistant content as structured parts where the test expects a plain string:

- "content": "active answer",
+ "content": [ { "text": "active answer", "type": "text" } ],

Reproduction / environment matrix

node scripts/run-vitest.mjs extensions/codex/src/app-server/session-history.test.ts on detached origin/main @ cafbd745c1b (2026-07-04), macOS 15 (arm64):

  • Node 25.8.1 → 3 failed
  • Node 24.16.0 → 3 failed
  • Node 24.16.0 with scratch HOME → 3 failed (not user-state leakage)

Same failures appeared inside a fresh scripts/pr prep worktree during a PR landing attempt, so it is not checkout-specific either. git log shows the test and reader last changed in #89518 (plugin transcript mirrors migration, 2026-06-23); no changes since, so this looks like a mac-vs-CI divergence (dependency resolution or platform-dependent path in the mirrored-history reader) rather than a fresh main regression.

What did you expect?

The extension-codex-app-server-support suite passes on a clean checkout of main on macOS, so local full-suite gates (scripts/pr prepare-gates) can go green.

Impact

Maintainer landing lane: local prepare-gates cannot pass on affected macOS hosts; PRs must fall back to hosted CI evidence (documented in #99830 (comment)).

Additional information

Root-causing needs the Codex dependency gate (inspect the mirrored transcript writer/reader contract against ../codex), which is why this is filed rather than patched alongside the unrelated PR that surfaced it.

Activity

  1. added
    bug
    on Jul 4, 2026
  2. added
    maintainer
    on Jul 4, 2026
  3. clawsweeper commented on Jul 4, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed July 4, 2026, 2:46 AM ET / 06:46 UTC.

    Summary
    Keep open: this is a protected maintainer-labeled bug with live issue evidence and current-main source still matching the reported Codex mirrored-history assertion mismatch; no merged fix or canonical replacement issue owns it yet.

    Reproducibility: yes. source-level. The reporter supplied a concrete macOS command, and current-main source still has tests expecting string assistant content while session ingest normalizes those assistant strings into structured text parts.

    Next step
    Protected maintainer label and the need for macOS/Codex-contract confirmation make this a human-handled issue, not an automated cleanup close or repair dispatch.

    Review details

    Best possible solution:

    Align the Codex mirrored-history test/runtime expectation with canonical structured assistant content, then prove the focused suite on macOS Node 24/25 and Linux without weakening branch-selection coverage.

    Do we have a high-confidence way to reproduce the issue?

    Yes, source-level. The reporter supplied a concrete macOS command, and current-main source still has tests expecting string assistant content while session ingest normalizes those assistant strings into structured text parts.

    Is this the best way to solve the issue?

    Unclear at final code-shape level. The likely fix is narrow, but it should be chosen after confirming whether tests should expect structured content or the reader should intentionally post-process only a Codex-facing projection.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • I did not run the macOS repro in this read-only Linux review, so the exact mac-vs-Linux divergence still needs direct macOS validation even though source inspection explains the reported assertion shape.

    Codex review notes: model internal, reasoning high; reviewed against 03fafe236494.

    Label changes

    Label changes:

    • add P2: The issue blocks a maintainer local gate on affected macOS machines but has a hosted-CI fallback and a bounded Codex session-history surface.
    • add impact:session-state: The affected surface is Codex mirrored session-history replay and transcript content normalization.
    • add issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.
    • add clawsweeper:source-repro: Current issue advisory state selects this label.

    Label justifications:

    • P2: The issue blocks a maintainer local gate on affected macOS machines but has a hosted-CI fallback and a bounded Codex session-history surface.
    • impact:session-state: The affected surface is Codex mirrored session-history replay and transcript content normalization.
    Evidence reviewed

    What I checked:

    • Repository policy read and applied: Root policy and scoped extensions policy were read; the protected maintainer label and Codex dependency-inspection rule apply to this review. (AGENTS.md:1, 03fafe236494)
    • Live issue state: GitHub shows this issue is open with bug and protected maintainer labels, one ClawSweeper status comment, and no closing pull request references.
    • Current main reads and builds mirrored history: On current main, readCodexMirroredSessionHistoryMessages parses the session file, migrates entries, then returns buildSessionContext(sessionEntries).messages, so parser normalization affects the test output shape. (extensions/codex/src/app-server/session-history.ts:27, 03fafe236494)
    • Current tests still expect assistant strings: The three reported tests still assert assistant content as a plain string rather than the structured text block array shown in the issue body. (extensions/codex/src/app-server/session-history.test.ts:86, 03fafe236494)
    • Current parser normalizes legacy assistant strings: Session entry ingest converts assistant or tool-result string content to [{ type: "text", text: ... }], which explains the reported mismatch without needing to infer from logs alone. (src/agents/sessions/session-manager.ts:956, 03fafe236494)
    • OpenClaw message contract uses structured assistant content: The current AssistantMessage type requires assistant content to be an array of text/thinking/tool-call parts, while user content may still be string or content blocks. (packages/llm-core/src/types.ts:279, 03fafe236494)

    Likely related people:

    • jalehman: Authored the merged plugin transcript mirror migration that last changed the Codex session-history reader and tests implicated by the issue. (role: recent feature contributor; confidence: high; commits: 258b83c4386c; files: extensions/codex/src/app-server/session-history.ts, extensions/codex/src/app-server/session-history.test.ts)
    • obviyus: Recent history for session-manager.ts shows the assistant string normalization was folded into transcript ingest, the behavior that makes the current tests return structured parts. (role: recent adjacent contributor; confidence: high; commits: a5bf55d690e7, e095dc840933; files: src/agents/sessions/session-manager.ts)
    • vincentkoc: Recent path history touches transcript-tree cleanup and earlier string assistant handling around the same session transcript normalization surface. (role: adjacent session-state contributor; confidence: medium; commits: 5b030418c1fb, c70b9849d9f9; files: src/config/sessions/transcript-tree.ts, src/agents/sessions/session-manager.ts)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
  4. added
    P2
    impact:session-state
    issue-rating: 🦞 diamond lobster
    clawsweeper:source-repro
    on Jul 4, 2026
  5. steipete commented on Jul 4, 2026

    @steipete
    ContributorAuthor

    Fixed on main in 55d0d037bfdd6cf10b56a83f6b7e77c743f0dea1 (test-only, +6/−3 in extensions/codex/src/app-server/session-history.test.ts).

    Root cause

    The tests were stale, not the reader or the mirror writer. #98908 (a5bf55d690e, 2026-07-01) folded assistant string normalization into session-transcript ingest: parseSessionEntries → normalizeLoadedFileEntry (src/agents/sessions/session-manager.ts:956) now rewrites legacy assistant string content into [{ type: "text", text }] blocks at load time, matching the canonical AssistantMessage block-array contract (packages/llm-core/src/types.ts). That PR updated the core analog test (src/agents/cli-runner/session-history.test.ts) but missed this extension file — the only other consumer of that ingest path (verified by sweep). The Codex mirror writer already emits block arrays (createAssistantMessage in extensions/codex/src/app-server/event-projector.ts), so string fixtures only exist as legacy ingest input; the fix updates the three assistant expectations to the canonical block shape, exactly mirroring the #98908 core-test update, and keeps the string fixtures to preserve legacy-ingest coverage.

    Codex dependency gate

    Inspected sibling openai/codex @ db887d03e1 before the verdict:

    • codex-rs/app-server-protocol/src/protocol/v2/thread.rs:324 — ThreadResumeParams resumes by thread_id from codex-side rollout persistence; the history param is marked [UNSTABLE] FOR CODEX CLOUD - DO NOT USE, and path points at codex's own rollout JSONL.
    • codex-rs/app-server-protocol/src/protocol/thread_history.rs — build_turns_from_rollout_items rebuilds resumed thread history from codex-persisted RolloutItems.

    So the mirrored OpenClaw session file never crosses the app-server protocol boundary (extensions/codex/src/app-server/run-attempt.ts keeps codexModelInputHistoryMessages empty by design — codex threads own conversation continuity; the mirror feeds OpenClaw harness hooks and prompt projections only). The mirror's message shape is therefore governed by OpenClaw's canonical session contract, which is the block-array form.

    Why Linux CI stayed green (it is not a platform difference)

    • scripts/lib/ci-node-test-plan.mjs excludes test/vitest/vitest.full-extensions.config.ts from the ci.yml Linux node-test shards (EXCLUDED_FULL_SUITE_SHARDS).
    • Extension unit tests only run in .github/workflows/plugin-prerelease.yml, which is workflow_dispatch-only.
    • Local full pnpm test (what scripts/pr prepare-gates runs) includes the extensions shard, so any full local run failed on any OS while push/PR CI never executed the file.
    • Live Linux proof: on a Crabbox AWS box (cbx_38693d0e2fa8, run run_1825965cd014, c7a.8xlarge), the pre-fix file fails identically — 3 failed / 1 passed with the same [{ "text": ..., "type": "text" }] vs string assertion diffs — and the fixed file passes 4/4. No dependency-resolution or platform path is involved.

    Proof

    • macOS (arm64, Node 25.8.1), pre-fix @ cccc856b82f: node scripts/run-vitest.mjs extensions/codex/src/app-server/session-history.test.ts → 3 failed / 1 passed (matches this report).
    • macOS post-fix: same command → 4 passed (4).
    • Linux (Crabbox cbx_38693d0e2fa8): pre-fix 3 failed / 1 passed, post-fix 4 passed, command_phases=postfix-expect-green:8.6s,prefix-expect-red:6.5s.
    • Formatting via repo oxfmt clean; structured autoreview (Codex, gpt-5.5) clean — "no accepted/actionable findings".

    scripts/pr local prepare-gates on macOS should pass this suite again from 55d0d037bfd. Closing as completed.

  6. locked as resolved and limited conversation to collaborators on Jul 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2bugclawsweeper:source-reproimpact:session-stateissue-rating: 🦞 diamond lobstermaintainer

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions