Skip to content

fix(codex): ignore empty mirrored session history - #99567

Closed
litang9 wants to merge 1 commit into
openclaw:mainfrom
litang9:codex/codex-history-race-warning
Closed

litang9 wants to merge 1 commit into
openclaw:mainfrom
litang9:codex/codex-history-race-warning

Conversation

@litang9

@litang9 litang9 commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Codex app-server attempts can log failed to read mirrored session history for codex harness hooks when harness hooks read mirrored session history during a new-session startup race.

Two transient states should be treated as empty history instead of failed history reads: the mirrored session file has not been created yet, or it exists but contains only whitespace before the session header has been written.

Why This Change Was Made

Missing or empty mirrored history means there is nothing to replay yet. That is not the same as a malformed transcript, and warning for it creates noisy gateway logs during otherwise healthy cron/session startup.

This change returns [] for missing and empty mirrored session files, while preserving undefined for malformed non-empty files so the existing warning path still catches real transcript corruption.

User Impact

Operators should stop seeing repeated Codex embedded-runtime warning bursts for healthy new sessions whose mirrored history artifact is created or populated shortly after the harness hook runs.

Malformed non-empty session history still surfaces as a warning, so real transcript issues remain diagnosable.

Evidence

  • Local gateway log evidence from /tmp/openclaw/openclaw-2026-07-03.log: failed to read mirrored session history for codex harness hooks appeared for yuantai cron sessions before the corresponding JSONL file's first record timestamp; after the run completed, those files parsed successfully.
  • node scripts/run-vitest.mjs extensions/codex/src/app-server/session-history.test.ts passed with 7 tests.
  • git diff --check passed.
  • pnpm install --frozen-lockfile completed in the rebased worktree before running the test wrapper.

Real behavior proof

Behavior addressed: Codex harness hook history reads should not warn when a mirrored session file is missing or empty during a new-session startup race.

Real environment tested: local OpenClaw gateway logs from 2026-07-03 under the user's active ~/.openclaw state, plus the current source checkout rebased onto upstream/main at 0420aefb1d.

Exact post-patch command/steps:

pnpm install --frozen-lockfile
node scripts/run-vitest.mjs extensions/codex/src/app-server/session-history.test.ts
git diff --check

Evidence after fix: the new tests verify missing session.jsonl and whitespace-only session.jsonl return []; a malformed non-empty JSONL row still returns undefined, preserving the existing warning path for real corruption.

Observed result: the targeted test file passed with 7 tests.

What was not tested: a full live gateway run with a patched local OpenClaw install was not performed; the behavior is covered at the reader boundary that controls whether the harness warning is emitted.

@clawsweeper

clawsweeper Bot commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the context here. I did a careful shell check against current main, and this is already implemented.

Current main already treats empty or whitespace-only Codex mirrored session history as empty history, and that behavior has shipped; the PR head is based on the older bare-session-file reader and no longer carries a mergeable unique fix.

Root-cause cluster
Relationship: superseded
Canonical: #89518
Summary: The merged transcript mirror refactor already added the current parsed-empty history behavior and scoped reader API that make this PR unnecessary.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

So I’m closing this as already implemented rather than keeping a duplicate issue open.

Review details

Best possible solution:

Keep the shipped scoped-session implementation from the transcript mirror refactor; if maintainers want explicit whitespace-only regression coverage, open a fresh test-only PR against the current scoped target API.

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

Yes, at source level for the old reader: whitespace-only content parses to zero entries and the old code would continue to the malformed-header path, while current main returns []. I did not run tests because this review was required to keep the checkout read-only.

Is this the best way to solve the issue?

Yes, current main is the better solution because it treats all parsed-empty history as empty after parser normalization and preserves the scoped transcript target API. The PR's raw trim guard is now an obsolete narrower patch against an older reader signature.

Security review:

Security review cleared: The PR only changes Codex session-history reader behavior and colocated tests; no dependency, workflow, secret, permission, or code-execution surface is changed.

AGENTS.md: found and applied where relevant.

What I checked:

Likely related people:

  • jalehman: Authored and merged the scoped transcript mirror/history refactor that added the current empty parsed-history return in the same Codex session-history path. (role: current implementation owner; confidence: high; commits: 258b83c4386c; files: extensions/codex/src/app-server/session-history.ts, extensions/codex/src/app-server/session-history.test.ts)
  • steipete: Recent same-file history and broader Codex app-server/runtime commits show repeated work on Codex replay, session-history sanitization, and agent-runtime boundaries around this path. (role: adjacent area contributor; confidence: medium; commits: 71b79f008d1d, e72447de408a, bb46b79d3c14; files: extensions/codex/src/app-server/session-history.ts, extensions/codex/src/app-server/image-payload-sanitizer.ts)

Codex review notes: model internal, reasoning high; reviewed against f188c664c0e7; fix evidence: release v2026.6.11-beta.1, commit 258b83c4386c.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Jul 3, 2026
@clawsweeper

clawsweeper Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: codex P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant