Repository navigation
fix(codex): stop using stale instructions after prompt-hook changes - #135577
Conversation
Preserve full replacement and explicit withdrawal across persistent resumes, and refuse changed incognito policy without discarding its live conversation. Keep policy preflight failures out of provider retries and normal private diagnostic disclosure. Refs #135338.
Keep direct preflight diagnostics out of provider error classification after the retry-controller integration. Preserve contention and native-overload coverage, and table-drive existing status cases without dropping assertions. Related: #135338
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed September 1, 2026, 7:12 PM ET / 23:12 UTC. ClawSweeper reviewWhat this changesThe branch safely applies changed Codex session policy on resumed conversations and refuses unsafe retained-session reuse before inference. Merge readinessThe PR provides a coherent repair for stale Codex generic policy, with its new refusal path explicitly accepted in maintainer discussion. Priority: P1 Review scores
Verification
How this fits togetherThe Codex plugin combines hook-provided generic instructions with a native Codex app-server conversation. It either confirms safe reuse and injects current policy, or rejects the turn before a model request. flowchart LR
A[Prompt hook policy] --> B[Codex session lifecycle]
C[Retained native client] --> B
B --> D{Policy changed?}
D -->|No| E[Reuse session]
D -->|Persistent and confirmed| F[Resume and inject policy]
D -->|Unsafe or incognito| G[Preflight refusal]
E --> H[Native model request]
F --> H
Before merge
Agent review detailsSecurityNone. PR surfaceSource +171, Tests +1588, Docs +58. Total +1817 across 40 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Merge with the recorded safe-resume boundary: reuse only sessions whose policy ownership is confirmed, otherwise require a safe new-session path. Do we have a high-confidence way to reproduce the issue? Yes—high-confidence source and native-contract evidence identifies why subscribed or active native sessions can retain prior configuration; supplied exact-head native evidence exercises the affected transitions. Is this the best way to solve the issue? Yes—the branch repairs policy at the lifecycle owner, confirms native ownership before injection, and refuses inference rather than silently preserving stale instructions. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against d9d19fefb4bb. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
Maintainer compatibility decisionRecording the explicit owner decisions already made for this repair: accept guarded persistent refresh and changed-live-incognito refusal. An ordinary persistent turn must stop before inference when exclusive native configuration ownership or unload cannot be established; it must preserve the conversation rather than silently use stale instructions. A retained incognito conversation keeps its creation-time policy and existing lifetime. Changed or explicitly empty policy stops before inference; restoring the original policy continues the same native conversation. There is no new persistence, expiry, silent conversation rotation, setting, or native patch. The +171 production LOC is accepted for these concrete owner-boundary obligations: prove ordinary native-process/configuration ownership, preserve creation policy on the existing volatile live-thread owner, revalidate exact warm claims across awaited work, and carry deliberate refusals through existing failover/privacy/settlement owners without auth rotation or retries. The implementation removes the ordinary resume bypass and separate incognito reuse path and reuses the existing full-policy carrier, generation claim, SDK preflight error, and reply formatting. Injection alone would leave compaction and child configuration stale; configuration alone does not replace inherited generic history in stock Codex. Neither is a sound net-neutral substitute. This addresses the compatibility decision and LOC item in the ClawSweeper review. Exact-head PR CI is now green at Final observed proofAll twelve stock-native scenarios passed: warm/cold full replacement and empty withdrawal, unchanged warm/incognito continuation, contention refusal without writes and subsequent recovery, changed/empty incognito refusal with original-policy same-thread recovery, warm/cold compaction, and Commands run in the isolated exact-head checkout: pnpm install --frozen-lockfilepnpm buildpnpm checknode .claude/ordinary-instruction-proof/repro/launch.mjs composition-final.mtsnode .claude/ordinary-instruction-proof/repro/launch.mjs composition-warm-policy-compact.mtsThe temporary probes use real OpenClaw hook/admission/lifecycle composition and stock native stdio with synthetic loopback HTTP/SSE responses. Source aliases were relocated for Linux; probe assertions and production source were unchanged. This proves native model-input composition, not external model inference/compliance. The local Mac rerun was blocked before startup by the interrupted dependency install; it is not claimed as passing. The earlier shallow-history check failure was resolved by restoring history, not relaxing the ratchet. Additional proof: 2,457 owner/sibling tests across 60 files, 78 final owner tests plus exact-head build, and clean isolated Codex full-candidate/final-delta autoreviews at P0/P1. Complete test commands and source-contract links remain in the PR body. No full-repository test suite, live remote-worker run, or native-child live spawn is claimed. Both ClawSweeper Rank-up moves are addressed: explicit compatibility acceptance above and inspected exact-head native/Testbox proof. Native review artifacts are complete; proceeding through the required |
|
Merged via squash.
|
…penclaw#135577) * fix(codex): refresh stale generic policy after prompt-hook replacement Preserve full replacement and explicit withdrawal across persistent resumes, and refuse changed incognito policy without discarding its live conversation. Keep policy preflight failures out of provider retries and normal private diagnostic disclosure. Refs openclaw#135338. * fix(agents): preserve preflight identity in known failure replies Keep direct preflight diagnostics out of provider error classification after the retry-controller integration. Preserve contention and native-overload coverage, and table-drive existing status cases without dropping assertions. Related: openclaw#135338
openclaw#135833) Consolidate preflight, provider-facet, and fallback settlement without changing ordering, presentation, or post-compaction attribution. Remove unused synthetic lifecycle history and waiter state. Maintainer-requested follow-up to openclaw#135577; no policy-text or incognito-contract changes.
Closes #135338 — stale generic instructions after Codex prompt-hook replacement.
What Problem This Solves
Fixes an issue where users continuing an ordinary Codex conversation could retain stale OpenClaw generic instructions after a
before_prompt_buildhook replaced the system prompt or explicitly returned an empty string. Sending the new configuration on resume alone did not update the next model request's inherited instruction history.Why This Change Was Made
The Codex plugin now establishes native configuration ownership before reusing the existing complete-policy injection carrier. Persistent resumes keep the native conversation, establish that the old configuration was unloaded, and append a complete superseding policy or explicit withdrawal; this also keeps configuration correct for compaction and native-child inheritance. Independent native/project/collaboration instructions and user authority remain separate.
The existing exact-generation live-thread owner now also holds ordinary incognito creation policy in memory, without adding idle expiry or persistence. Direct preflight refusals retain their identity through failover and reply presentation, rather than turning diagnostic text into provider auth, billing, or overload facts. Integration preserves main's single transient retry controller and subprocess diagnostic copying; no removed outer retry loop is restored.
User Impact
Unchanged, configuration-proven warm conversations retain their fast path. Changed or cold persistent resumes refresh the full generic policy, including an explicit empty withdrawal. Old policy text may remain in append-only history, but the later complete policy supersedes it.
The owner explicitly accepted guarded persistent refresh and changed-incognito refusal. When another lease/subscriber or failed unload prevents configuration proof, the turn refuses before inference and preserves the conversation. Ordinary cold refresh requires managed local non-proxy stdio; external sockets/proxies cannot provide this proof. Resolve contention and reconnect through managed local stdio. Supervised external connections keep their existing, narrower connection-lease contract.
A live incognito conversation cannot change its creation-time generic policy on stock Codex. A changed or emptied policy therefore refuses before inference; restore the original policy to continue the same conversation, or start a new incognito conversation for the new policy. This introduces no expiry or new store.
Unknown policy-write outcomes are not automatically replayed or rotated away. Default external diagnostic privacy, verbose detail limits, group silence, accepted-partial settlement, heartbeat visibility, and Control UI formatting remain under their existing owners. There are no new settings, schemas, dependencies, native patches, or operator-state changes.
Evidence
Native behavior and dependency contract
Stock
@openai/codex0.151.0 was verified against its official npm platform artifact (SHA-25698491713ffb196061003ee148636e743997cc31d76144ba7c53462269896891d). The baseline used production OpenClaw hook/prompt/lifecycle composition, admitted host authority, real native stdio, and a credential-free loopback Responses endpoint—not a mocked resume acknowledgment.All twelve baseline native turns completed, but the six second-turn replacement/empty-policy assertions failed. The repaired native implementation passed twelve scenarios, including warm/cold replacement and withdrawal, unchanged warm reuse, contention recovery, incognito original-policy same-thread recovery, and
A → B → native warm compaction → unchanged B. Captures contain 28 native HTTP requests; all 15 clients and both servers closed, with no Authorization headers or auth files. The same twelve scenarios were rerun successfully on exact published head6a8f0492d3f0bfab5830b72c1102ebe157731d3a/ tree112f6d7c0fd4aab1c68724161838c4b0a79d2218on Linux in Testbox run 33565101656: 28 requests, all 15 clients and both servers closed, no Authorization headers. Linux used frozen-lockfile stock Codex 0.151.0, native SHA-2569739cbc928b9c573be83256acd46668f5dd4f119d2d09e05246895ca2aaf0c9a. The temporary launcher retained identical probe logic and only relocated its source aliases to the isolated Linux checkout. These runs prove model-input composition, not external model inference or model compliance.Exact stock source personally inspected at
78c290807ce710180111df227df3b7a4fe845452:Integrated verification
The source-bound Linux Node 24.19.0 test phase passed 2,457 tests across 60 complete files, plus a separate 14-test startup-retry run, in Testbox run 33542677845. The later lint phase of that run correctly failed on the combined test-file size; five existing HTTP 402/422 cases were then table-driven without dropping inputs or assertions. Counts across these overlapping runs must not be summed.
The initial Linux run also exposed an obsolete startup fixture: it expected native resume overload while retaining a competing lease. The existing real-stdio test now proves both the no-write contention refusal and native overload after legitimate lease release, preserving the same client and binding.
Main's retry-controller consolidation remains intact. Two failing known-reply tests demonstrated that its message-based classification could turn preflight diagnostics into provider overload copy; the guarded known-reply entry fixes that without restoring outer retry loops. Main's protocol declaration-build repair was picked up by rebase, rather than patched around here; all 40 task files remained byte-identical during that rebase.
Fresh isolated Codex reviews covered the complete integrated candidate and the final pending delta: scoped-clean at P0/P1, no findings. Reviewers inspected code/evidence; execution results are recorded separately.
The post-consolidation owner suite passed 78 tests, and full
pnpm buildpassed on exact commit6a8f0492d3f0bfab5830b72c1102ebe157731d3a/ tree112f6d7c0fd4aab1c68724161838c4b0a79d2218in Testbox run 33561972328. Fullpnpm checkstopped at the assertion-baseline comparison because the prepared checkout was shallow and could not resolve the branch fork; its fallback compared unchanged older-base files against newer main. The unchanged exact-head fullpnpm buildandpnpm checkthen passed with complete Git history and the verified original fork in Testbox run 33565101656, providerblacksmith-testbox, leasetbx_01m1fgfg900589ywy3reb8arpb; no baseline was edited or bypassed. Exact-head PR CI also completed successfully. The final exact-head stock-native rerun also passed on that lease. The local attempt stopped before startup because the interrupted dependency install leftopenai/index.jsmissing; it is not counted as passing proof. Both ClawSweeper Rank-up moves are addressed: exact-head native/Testbox proof above and explicit compatibility/LOC acceptance.Exact integrated test command (60 complete files)
The final isolated worktree also runs the post-consolidation owner test and the full repository gates:
Scope and tradeoffs
Production LOC: +348/−177, net +171. Tests/support: +2661/−1073, net +1588. Docs: +58. Growth implements accepted configuration proof, volatile incognito-policy continuity, exact warm-owner revalidation, and non-retriable/private failure handling. The ordinary bypass and separate incognito reuse branch were removed; existing policy, ownership, SDK-error, and presentation mechanisms remain canonical.
No full-repository test suite, external model inference, live remote-worker run, native-child live spawn, or stronger supervised external-process attestation is claimed. Local Mac verification encountered filesystem/module-loading stalls and an incomplete, explicitly cancelled dependency install; those are not presented as passing checks or a proven OS/package-manager defect. Linux validation uses fresh lockfile-derived dependencies and exact source identities.
Regression introduction is unknown; no last-known-good release has been established. Documentation: https://docs.openclaw.ai/plugins/codex-harness-runtime#hook-boundaries and https://docs.openclaw.ai/plugins/codex-harness-reference.