Skip to content

fix(codex): stabilize prompts and expose real cache regressions - #115238

Merged
steipete merged 6 commits into
mainfrom
codex/codex-harness-cache-stability-20260728
Jul 28, 2026
Merged

steipete merged 6 commits into
mainfrom
codex/codex-harness-cache-stability-20260728

Conversation

@steipete

@steipete steipete commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Related: #114574
Related: #115089

What Problem This Solves

Fixes misleading native-Codex performance comparisons when cached input dominates total token counts, a warm native thread loses its prompt cache, or provider cache counters are partial or internally inconsistent. Plugin discovery order could also unnecessarily change the model-visible Codex prompt.

Why This Change Was Made

Canonicalize only the searchable Codex dynamic-tool surface; preserve direct-tool ordering, namespace visibility, and sandbox boundaries. Capture actual assistant-turn usage from canonical SQLite transcripts, recognize post-warm zero-read cache misses including cache rewrites, and compare genuinely processed uncached input, cache writes, and output. Fail closed on missing, partial, or incoherent telemetry. Refresh all generated Codex prompt snapshots.

Directly verified the upstream Codex turn-scoped client, app-server dynamic-tool ordering, exact-request/prompt-prefix reuse, websocket lifecycle, and provider cache usage contracts. No unsupported cross-turn client reuse or invented cache counters.

User Impact

Deterministic searchable Codex prompts; honest runtime timing and processed-token comparisons; observable turn-specific upstream cache losses; native apply_patch and sandbox rejection verified on both runtimes.

Evidence

  • Exact independently reviewed PR head: 501bf55.
  • Genuine OpenAI live-frontier gpt-5.6-sol; credential obtained inside tmux through 1Password; no mock-provider timings.
  • Final matched 20-turn runtime pair: OpenClaw 71,120 ms; native Codex 67,681 ms; both passed.
  • Genuine processed work: OpenClaw 19,998 tokens; Codex 50,572 tokens (+152.9%).
  • OpenClaw: zero post-warm cache misses. Codex: a verified turn-5 cache miss reprocessing 24,579 input tokens.
  • Runtime parity: pass. Token-efficiency gate: correctly fails the 15% threshold on the genuine upstream Codex cache regression.
  • Exact-head native apply_patch: OpenClaw and Codex both pass successful workspace patching and out-of-workspace sandbox rejection.
  • 176 exact-head focused QA regression tests pass.
  • 13 prompt-snapshot owner tests and 115 Codex dynamic-tool tests pass.
  • All seven generated Codex prompt snapshots pass the canonical generator check.
  • Exact-head full changed-code gate passes: snapshots, formatting, package/dependency/SDK boundaries, production and test extension type-checks, extension and tooling lint, storage/sidecar guards, and zero runtime import cycles.
  • Blacksmith remained queued for more than eight minutes, so the full exact-head gate used the repository-approved trusted-source local fallback.
  • Prior whole-plugin remote validation: 2,896 Codex tests and 1,861 QA tests passed.
  • Fresh exact-head independent Codex autoreview: clean, no accepted or actionable findings.
  • Unsupported generic bash and fs.read fixtures remain explicitly skipped; they are not presented as passing behavior.
  • The official merge workflow is ready and will not bypass the externally queued required GitHub preflight.

AI-assisted; upstream contracts, exact-head tests, generated fixtures, and actual live-provider behavior were reviewed.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 28, 2026
@clawsweeper

clawsweeper Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 28, 2026, 11:05 AM ET / 15:05 UTC.

ClawSweeper review

What this changes

The PR canonicalizes searchable Codex dynamic-tool ordering and extends QA runtime-parity/token-efficiency reports to identify post-warm cache misses, cache rewrites, and incomplete telemetry.

Merge readiness

⚠️ Needs maintainer review before merge - 4 items remain

Keep this PR open for protected maintainer review. The branch targets the right Codex/QA boundaries and includes concrete live-run evidence, but it is behind current main and changes the model-visible tool prompt plus cache-regression accounting; those contracts need an owner’s exact-head review before landing.

Priority: P2
Reviewed head: 501bf55245cdce4880d63f56fb3e4ebd9dcca73f
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The PR has unusually concrete real-run evidence, but its broad prompt and telemetry contract change still needs a rebased owner review before it is merge-ready.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body supplies exact-head, after-fix live-provider results for a matched 20-turn runtime pair, observed cache-loss behavior, and native workspace/sandbox outcomes; redact any private endpoints, credentials, or identifiers if logs are later attached.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body supplies exact-head, after-fix live-provider results for a matched 20-turn runtime pair, observed cache-loss behavior, and native workspace/sandbox outcomes; redact any private endpoints, credentials, or identifiers if logs are later attached.
Evidence reviewed 4 items Dynamic prompt determinism: The proposed change sorts only non-direct dynamic-tool entries before generating the Codex tool specifications, with a regression test that reverses discovery order and expects the same model-visible specifications.
Measured cache diagnostics: The branch derives cache diagnostics from assistant records captured for each parity cell, including zero-read cache rewrites and explicitly unmeasured post-warm turns.
Related feature provenance: The recently merged live-thread reuse work is the direct predecessor for the cache behavior this PR observes; it merged as commit 92b4af2 after adding warm Codex thread reuse and cache-focused parity evidence.
Findings None None.
Security None None.

How this fits together

The Codex plugin turns OpenClaw’s discovered tools into a dynamic surface for the native Codex app-server. QA Lab reads assistant-turn usage from canonical SQLite transcripts, diagnoses cache behavior, and renders parity and token-efficiency reports for runtime comparisons.

flowchart LR
  A[Plugin discovery] --> B[Codex dynamic tool surface]
  B --> C[Native Codex app-server]
  C --> D[Assistant transcript usage]
  D --> E[QA cache diagnostics]
  E --> F[Parity and token reports]
Loading

Decision needed

Question Recommendation
Should the Codex/QA owner accept this prompt-ordering and cache-accounting contract after a current-main rebase and exact-head verification? Rebase and verify the contract: Refresh against current main, then confirm the native Codex direct/searchable tool-ordering contract and run the focused prompt and cache-report proofs.

Why: The change deliberately affects model-visible prompt ordering and the interpretation of live provider cache telemetry; repository policy treats Codex dependency behavior and prompt-cache determinism as contracts that require direct owner-level confirmation.

Before merge

  • Resolve merge risk (P1) - The branch is behind current main; rebase and refresh the exact-head prompt snapshots and runtime-parity checks before merge so the generated prompt baseline and new telemetry logic are evaluated against the actual merge result.
  • Resolve merge risk (P1) - Sorting a model-visible dynamic-tool surface is compatibility-sensitive because it deliberately changes prompt bytes and cache keys; an owner should confirm that all direct-mode ordering and namespace invariants remain preserved under the current native Codex contract.
  • Complete next step (P2) - The protected maintainer label and model-visible Codex contract change require owner review rather than an automated repair lane.
Agent review details

Security

None.

PR surface

Source +293, Tests +821. Total +1114 across 17 files.

View PR surface stats
Area Files Added Removed Net
Source 7 326 33 +293
Tests 10 1617 796 +821
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 17 1943 829 +1114

Review metrics

None.

Stored data model

Persistent data-model change detected: persistent cache schema: extensions/qa-lab/src/agentic-parity-report.cache.test.ts, persistent cache schema: extensions/qa-lab/src/agentic-parity-runtime-markdown.ts, persistent cache schema: extensions/qa-lab/src/agentic-parity-runtime-report-contract.ts, persistent cache schema: extensions/qa-lab/src/runtime-parity-cache-diagnostics.test.ts, persistent cache schema: extensions/qa-lab/src/runtime-parity.ts, persistent cache schema: extensions/qa-lab/src/token-efficiency-report.test.ts, and 4 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Rebase with contract proof (recommended)
    Refresh the branch on current main and retain the ordering change only after direct native-Codex contract review and regenerated prompt/cache evidence confirm direct-mode compatibility.
  2. Separate telemetry from prompt ordering
    Keep the cache diagnostics in a narrower PR and defer the model-visible ordering change until its compatibility decision is explicit.
  3. Pause the combined change
    Pause this branch if the direct/searchable ordering boundary cannot be confirmed against the current native Codex app-server contract.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Rebase onto current main, regenerate the Codex prompt snapshots, run focused dynamic-tool and runtime-parity cache tests, and attach redacted exact-head results.

Technical review

Best possible solution:

Rebase onto current main, preserve direct-mode ordering while canonicalizing only the searchable surface, and land only after an owner verifies the refreshed prompt snapshots plus measured cache diagnostics on the merged head.

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

No high-confidence independent reproduction was completed in this read-only review; the branch supplies a concrete 20-turn live-provider scenario and source-level capture path, so the reported regression is source-reproducible with medium confidence.

Is this the best way to solve the issue?

Unclear. The proposed narrow split between searchable-surface canonicalization and direct-mode ordering is plausible, but the exact native Codex ordering/cache contract should be rechecked on the rebased head before treating it as the best permanent fix.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 206f989069fb.

Labels

Label changes:

  • add P2: This is a bounded runtime correctness and QA-reporting improvement with a limited but real Codex-user blast radius.
  • add merge-risk: 🚨 compatibility: The PR intentionally changes model-visible dynamic-tool ordering, which can alter native Codex prompt bytes, cache reuse, and behavior for existing sessions.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies exact-head, after-fix live-provider results for a matched 20-turn runtime pair, observed cache-loss behavior, and native workspace/sandbox outcomes; redact any private endpoints, credentials, or identifiers if logs are later attached.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body supplies exact-head, after-fix live-provider results for a matched 20-turn runtime pair, observed cache-loss behavior, and native workspace/sandbox outcomes; redact any private endpoints, credentials, or identifiers if logs are later attached.

Label justifications:

  • P2: This is a bounded runtime correctness and QA-reporting improvement with a limited but real Codex-user blast radius.
  • merge-risk: 🚨 compatibility: The PR intentionally changes model-visible dynamic-tool ordering, which can alter native Codex prompt bytes, cache reuse, and behavior for existing sessions.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body supplies exact-head, after-fix live-provider results for a matched 20-turn runtime pair, observed cache-loss behavior, and native workspace/sandbox outcomes; redact any private endpoints, credentials, or identifiers if logs are later attached.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies exact-head, after-fix live-provider results for a matched 20-turn runtime pair, observed cache-loss behavior, and native workspace/sandbox outcomes; redact any private endpoints, credentials, or identifiers if logs are later attached.

Evidence

What I checked:

  • Dynamic prompt determinism: The proposed change sorts only non-direct dynamic-tool entries before generating the Codex tool specifications, with a regression test that reverses discovery order and expects the same model-visible specifications. (extensions/codex/src/app-server/dynamic-tools.ts:963, 501bf55245cd)
  • Measured cache diagnostics: The branch derives cache diagnostics from assistant records captured for each parity cell, including zero-read cache rewrites and explicitly unmeasured post-warm turns. (extensions/qa-lab/src/runtime-parity.ts:1476, 501bf55245cd)
  • Related feature provenance: The recently merged live-thread reuse work is the direct predecessor for the cache behavior this PR observes; it merged as commit 92b4af2 after adding warm Codex thread reuse and cache-focused parity evidence. (extensions/codex/src/app-server/thread-lifecycle-warm.ts, 92b4af2dc840)
  • Provided real behavior evidence: The PR body reports an exact-head live 20-turn OpenClaw/native-Codex comparison, a verified post-warm native cache miss, native patch containment checks, and focused regression coverage; the GitHub context also records successful Real behavior proof checks. (501bf55245cd)

Likely related people:

  • steipete: Authored the two immediately preceding merged Codex runtime and live-thread reuse changes that established the cache and parity paths this PR extends. (role: recent feature owner; confidence: high; commits: 37cf0c606400, 92b4af2dc840; files: extensions/codex/src/app-server/thread-lifecycle-warm.ts, extensions/qa-lab/src/runtime-parity.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Rebase onto current main and refresh generated Codex prompt snapshots.
  • Attach or preserve redacted exact-head output for the focused dynamic-tool and cache-diagnostic checks.
  • Have the Codex/QA owner confirm direct-mode ordering against the current native app-server contract.

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.

@steipete steipete self-assigned this Jul 28, 2026
@steipete
steipete force-pushed the codex/codex-harness-cache-stability-20260728 branch from 501bf55 to 90fb7b0 Compare July 28, 2026 17:04
@steipete
steipete merged commit 5de0366 into main Jul 28, 2026
119 checks passed
@steipete
steipete deleted the codex/codex-harness-cache-stability-20260728 branch July 28, 2026 17:26
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Jul 28, 2026
…224005-host

* origin/main: (72 commits)
  fix: macOS-only Parallels smoke harness regression (#75293)
  fix(ios): use configured speech language for system voice (#113372)
  refactor: centralize isolated agent test ownership (#115340)
  test(ui): stabilize browser route readiness (#115320)
  fix(cron): clear automation after failed scheduler shutdown (#115316)
  fix: keep isolated gateway workspaces and skills inside state dir (#114487)
  docs: document local TTS on macOS, Linux, and Windows (#110230)
  fix(tasks): clone only the requested task page (#114277)
  fix(agents): prevent Code Mode resume loss and unbounded preparation (#115314)
  fix(process): preserve the first process cancellation reason (#115317)
  fix(nostr): report unavailable ingress when queue open fails (#115313)
  fix: prevent Slack and Feishu ingress startup leaks (#115295)
  fix(slack): avoid unsafe emphasis boundaries (#111575)
  fix: prevent changed checks from expanding into full lint (#115322)
  fix(codex): stabilize prompts and expose real cache regressions (#115238)
  refactor(ui): derive page route specs from the route table (#115214)
  fix(compaction): plan cut points in trigger units (#111886) (#115309)
  fix: prevent cron and gateway stress-run timeouts (#115241)
  fix(ci): validate frozen Matrix QA targets (#115298)
  test(macos): block real process fallthrough (#113337)
  ...

# Conflicts:
#	CHANGELOG.md
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 29, 2026
…claw#115238)

* fix(codex): stabilize prompt caching and measure uncached work

* test(codex): refresh stable dynamic-tool prompt snapshots

* fix(qa): account for cache rewrites and incomplete telemetry

* fix(qa): reject inconsistent measured cache totals

* fix(qa): preserve live profile eligibility and parity topology

* fix(qa): extract acyclic runtime parity usage contract
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 29, 2026
…afea23-host

* origin/main: (72 commits)
  fix: macOS-only Parallels smoke harness regression (openclaw#75293)
  fix(ios): use configured speech language for system voice (openclaw#113372)
  refactor: centralize isolated agent test ownership (openclaw#115340)
  test(ui): stabilize browser route readiness (openclaw#115320)
  fix(cron): clear automation after failed scheduler shutdown (openclaw#115316)
  fix: keep isolated gateway workspaces and skills inside state dir (openclaw#114487)
  docs: document local TTS on macOS, Linux, and Windows (openclaw#110230)
  fix(tasks): clone only the requested task page (openclaw#114277)
  fix(agents): prevent Code Mode resume loss and unbounded preparation (openclaw#115314)
  fix(process): preserve the first process cancellation reason (openclaw#115317)
  fix(nostr): report unavailable ingress when queue open fails (openclaw#115313)
  fix: prevent Slack and Feishu ingress startup leaks (openclaw#115295)
  fix(slack): avoid unsafe emphasis boundaries (openclaw#111575)
  fix: prevent changed checks from expanding into full lint (openclaw#115322)
  fix(codex): stabilize prompts and expose real cache regressions (openclaw#115238)
  refactor(ui): derive page route specs from the route table (openclaw#115214)
  fix(compaction): plan cut points in trigger units (openclaw#111886) (openclaw#115309)
  fix: prevent cron and gateway stress-run timeouts (openclaw#115241)
  fix(ci): validate frozen Matrix QA targets (openclaw#115298)
  test(macos): block real process fallthrough (openclaw#113337)
  ...

# Conflicts:
#	CHANGELOG.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: codex extensions: qa-lab maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL 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.

1 participant