Skip to content

fix(codex): retain recent answers after tool-heavy thread rotation - #155127

Merged
VACInc merged 2 commits into
mainfrom
openclaw/fix-codex-bounded-history-continuity-retry
Sep 21, 2026
Merged

VACInc merged 2 commits into
mainfrom
openclaw/fix-codex-bounded-history-continuity-retry

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes: Codex forgets its recent answer when a tool-heavy conversation leaves only assistant/tool history in the bounded window and a new native thread starts.

User Impact

Follow-up requests such as “give me the TLDR” retain the recent explanation after native thread rotation. Existing history limits, tool-payload omission, provenance boundaries, and resumed-thread deduplication stay unchanged. No migration or configuration change is required.

Why This Change Was Made

A fresh thread now recognizes nonblank assistant text as useful continuity even when the earlier user turn has fallen outside the retained window. The existing bounded, quoted-context projection still owns rendering. Empty, whitespace-only, and tool-only histories do not activate this new path.

Evidence

  • Real SQLite bounded-history regression asserts actual turn/start text. Fresh and tool-schema-rotated cases failed before the production fix; fresh, rotated, resumed, empty, and tool-only/whitespace cases now pass. Synthetic fixtures only.
  • Fixed all three source-relevant failures from the initial hosted run: hook/diagnostic assertions now match the actual quoted request while public diagnostics remain payload-free; prompt-hook coverage verifies the existing one-build/empty and two-build/continuity paths without duplicating the current request or plugin decorations; the new SQLite suite is registered with its existing database-worker owner. No discovery assertions were weakened or skipped.
  • 681 tests passed across seven complete files: 191 run-attempt, 16 hooks, 7 bounded-continuity, 43 context-engine, 4 durable-context, 64 context-projection, and 356 test-discovery/routing cases. This includes the unchanged exact-once normal full-suite discovery assertion and the existing stable developer-instruction checks.
  • Full current-source check:changed passed for all five PR paths: production/test types, formatting, full extension lint (10,335 files), script lint (1,123 files), all dead-export scans, plugin boundaries, and applicable source guards. git diff --check passed.
  • CI-repair autoreview: scoped-clean through P2, no actionable findings. The original production-review proposal to exclude all assistant messages carrying tool calls remains rejected: nonblank text can be legitimate quoted history, unlike textless tool traffic; tool payload omission is unchanged.
  • Hosted CI passed on exact head 4c52c43627ac638b5726faea71298ddeae1b1724, including the CI workflow’s aggregate gate job. The formerly failing named jobs—changed-extensions-config-19, changed-extensions-config-20, and compact-small-1—all completed successfully.
Test cost and lifecycle rationale

Measured with pnpm test <file> --maxWorkers=1: bounded-continuity 50.11 s wall (including 18.86 s shared worker preparation), hooks 11.93 s, and the existing 191-case run-attempt suite 104.88 s. The combined seven-file proof took 247.81 s. The bounded regression needs the real SQLite selector and native request boundary; a projection-helper-only test did not cover the skipped continuity gate. The changed hook case was moved out of the oversized main suite and extended with the empty-history sibling rather than growing that file. Existing fixtures own startup/cleanup; no sleeps, retry wrappers, or new polling loops were added.

Hosted timing receipts: the two Codex groups completed 291 tests in 321.46 s and 216 tests in 150.55 s of Vitest wall time; their full jobs took 374 s and 264 s, respectively. The compact-small-1 job completed in 560 s. These are grouped-job timings, not per-file CI timings.

The canonical pipeline builds developer instructions before native thread startup, then rebuilds turn input if the actual startup action requires continuity. The repair does not add another hook lifecycle: assistant-only histories now use that existing path. Both builds retain the raw currentUserMessage; llm_input, private model diagnostics, and failure snapshots match the submitted model-bound prompt.

This is current-source harness/request proof, not a live provider rerun of the original conversation. The original thread-rotation trigger was not retained; the regression exercises a deterministic tool-schema rotation.

Worked on by

Work sessions


View the OpenClaw team session

@clawsweeper

clawsweeper Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

Co-authored-by: VACInc <[email protected]>

OpenClaw-Publication: 6a376f24-3093-4f06-b426-d3411eff955b
@roboclaw-bot
roboclaw-bot force-pushed the openclaw/fix-codex-bounded-history-continuity-retry branch from 8abb1d9 to 11206bf Compare September 21, 2026 19:42
@roboclaw-bot
roboclaw-bot marked this pull request as ready for review September 21, 2026 19:43
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 21, 2026
@clawsweeper

clawsweeper Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 21, 2026, 4:45 PM ET / 20:45 UTC (Revision 3).

ClawSweeper review

What this changes

The Codex plugin retains recent assistant answers when starting a fresh native thread and adds regression coverage for bounded history, prompt hooks, and test discovery.

Merge readiness

✅ Ready for maintainer review

The fix remains necessary: current main and the latest release still skip assistant-only continuity. No actionable defect was found in the introduced changes.

Priority: P2
Reviewed head: 4c52c43627ac638b5726faea71298ddeae1b1724

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with meaningful boundary regression coverage, verified hosted CI, and no blocking findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The bot-authored PR is exempt from the external-contributor proof gate. Its SQLite-to-turn/start regression covers the changed admission path with simulated native responses; the body accurately states that no live-provider replay was performed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The bot-authored PR is exempt from the external-contributor proof gate. Its SQLite-to-turn/start regression covers the changed admission path with simulated native responses; the body accurately states that no live-provider replay was performed.
Evidence reviewed 10 items Introduced change: Inspected the pinned merge-base-to-head diff. The production change admits nonblank assistant text only for started threads; existing context-engine, resumed-thread, and inactive-binding guards remain intact. The stale test merge was not used to infer removals.
Still needed on main and in the latest release: Read the continuity predicate on fetched main and at the supplied latest-release commit for v2026.9.5. Both accept user messages, durable notes, and summaries but omit assistant-only history; neither contains this repair.
Latest-release source check: The GitHub contents API confirmed the old continuity predicate at v2026.9.5 after the corresponding local release blob was unavailable.
Findings None None.
Security None None.

How this fits together

OpenClaw’s Codex plugin reads retained conversation history and prepares requests for the Codex app-server. When a native thread starts fresh, the plugin supplies bounded, quoted history so follow-up requests retain context.

flowchart TD
  A[Saved conversation] --> B[Bounded history reader]
  B --> C{Fresh native thread?}
  C -->|Yes, useful history| D[Quoted context projection]
  E[Current user request] --> D
  D --> F[Codex turn input]
  C -->|Resumed| F
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +4, Tests +217. Total +221 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 1 6 2 +4
Tests 4 301 84 +217
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 307 86 +221

Review metrics

None.

Technical review

Best possible solution:

Use the existing bounded projection to carry substantive assistant history into fresh threads while preserving native resume deduplication.

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

Yes, source establishes the failure: a bounded assistant/tool-only suffix fails the old continuity predicate when a fresh thread starts. The added SQLite/request regression covers that path; this review did not run it.

Is this the best way to solve the issue?

Yes. Extending the existing continuity predicate is a narrow repair that reuses established rendering and lifecycle behavior without adding another history owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 267bb9d27fa1.

Labels

Label justifications:

  • P2: Repairs a bounded conversation-continuity failure after fresh-thread startup without changing configuration or storage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The bot-authored PR is exempt from the external-contributor proof gate. Its SQLite-to-turn/start regression covers the changed admission path with simulated native responses; the body accurately states that no live-provider replay was performed.

Evidence

What I checked:

  • Introduced change: Inspected the pinned merge-base-to-head diff. The production change admits nonblank assistant text only for started threads; existing context-engine, resumed-thread, and inactive-binding guards remain intact. The stale test merge was not used to infer removals. (extensions/codex/src/app-server/run-attempt-prompt.ts:535, 4c52c43627ac)
  • Still needed on main and in the latest release: Read the continuity predicate on fetched main and at the supplied latest-release commit for v2026.9.5. Both accept user messages, durable notes, and summaries but omit assistant-only history; neither contains this repair. (extensions/codex/src/app-server/run-attempt-prompt.ts, 267bb9d27fa1)
  • Latest-release source check: The GitHub contents API confirmed the old continuity predicate at v2026.9.5 after the corresponding local release blob was unavailable. (extensions/codex/src/app-server/run-attempt-prompt.ts, ec9c1a13db89)
  • Existing projection owns safeguards: The complete production owner and projection module preserve quoted-reference framing, explicit-mention neutralization, character budgets, current-request separation, and existing tool-payload policy. Startup applies continuity after the actual thread lifecycle action is known. (extensions/codex/src/app-server/context-engine-projection.ts:116, 4c52c43627ac)
  • Dependency contract applies: The changed prompt feeds Codex app-server turn/start after native thread startup; docs/plugins/codex-harness.md identifies Codex as the native session owner. This is an affirmative dependency signal, and the sibling Codex implementation was inspected directly. (extensions/codex/src/app-server/run-attempt-start.ts:220, 4c52c43627ac)
  • Native request implementation: Verified repository ownership through the sibling checkout’s backing cache origin. At the recorded dependency revision, thread startup selects InitialHistory::New, while turn_start_inner converts submitted input into TurnInput::UserInput and submits it to the thread. This supports supplying continuity in the turn input without changing native protocol fields. (codex-rs/app-server/src/request_processors/turn_processor.rs:514, 6b9826e3aa83)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • 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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-21T19:52:01.273Z sha 11206bf :: needs maintainer review before merge. :: none
  • reviewed 2026-09-21T20:15:46.835Z sha 4c52c43 :: needs maintainer review before merge. :: none

@VACInc
VACInc merged commit fbac0f7 into main Sep 21, 2026
171 checks passed
@VACInc
VACInc deleted the openclaw/fix-codex-bounded-history-continuity-retry branch September 21, 2026 21:44
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 22, 2026
…penclaw#155127)

* fix(codex): retain recent answers after tool-heavy thread rotation

Co-authored-by: VACInc <[email protected]>

OpenClaw-Publication: 6a376f24-3093-4f06-b426-d3411eff955b

* test(codex): cover projected continuity hooks and full-suite routing

Co-authored-by: VACInc <[email protected]>

---------

Co-authored-by: roboclaw-bot <[email protected]>
Co-authored-by: VACInc <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: codex maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants