Repository navigation
fix(codex): keep local threads across Codex and OpenClaw version upgrades - #206089
NaturalMatchaKing wants to merge 1 commit into
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs real behavior proof before merge. What this changesPreserves local Codex threads and pending recovery metadata across version-only upgrades while retaining stricter connection-change checks. Example: Codex changes from 0.172.0 to 0.172.1 with the same CODEX_HOME and connection.
Review scores
ProductKind: Bug fix · Worth it: Needs a maintainer decision · Fix scope: Partial Merge readiness⛔ Blocked before merge - 2 items remain Keep open: current main retains the reported version-triggered rotation path, and this PR contains meaningful unique work. The revised implementation resolves both earlier findings; no additional definite code bug was established. Reviewed head: Decision needed
Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe Codex plugin converts initialized connection facts and plugin policy into persisted thread bindings, then uses those bindings to resume native conversations and recover pending subagent work. flowchart TD
A[User turn] --> B[Codex startup facts]
B --> C[Runtime and policy fingerprints]
C --> D[Thread lifecycle]
D --> E[Native Codex thread]
D --> F[SQLite binding and recovery metadata]
Technical reviewBest possible solution: Preserve version-only local continuity through the existing fingerprint and binding-write owners once the transition contract and upgrade compatibility are established. Do we have a high-confidence way to reproduce the issue? Current-main fingerprint construction, lifecycle rotation, and recovery preservation guards establish the reported path, corroborated by the supplied baseline observations; no target code was executed during this review. Is this the best way to solve the issue? Separating versioned inventory identity from durable local custody addresses the producer and its consumers coherently, but preservation changes the existing transition contract and covers only the local version-only portion of the linked report. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against a320c352377e. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +448, Tests +1412. Total +1860 across 17 files. Added test files: 2. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed November 26, 2026, 2:31 PM ET / 19:31 UTC (Revision 2). |
…pgrades Exclude transient Codex app-server version and user-agent fields from local-loopback runtime fingerprints and local binding plugin-app input fingerprints so routine local Codex CLI and OpenClaw patch upgrades resume existing native threads instead of rotating to fresh threads. Keep supervised connection fingerprints exact (preserving codexHome, homeScope, and cwd isolation), keep in-memory plugin-app inventory caches versioned, keep remote runtime matching exact, and migrate pending native subagent assignments and unmatched submission receipts cleanly when a legacy local runtime fingerprint upgrades in place while still clearing recovery metadata on codexHome, authProfileId, endpoint, or remote changes.
1c61961 to
cdd3169
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Related: #200018
What Problem This Solves
After a routine local Codex CLI or OpenClaw update (for example from
0.172.0to0.172.1), OpenClaw replaces active local Codex threads on the next user turn even when the localCODEX_HOMEdirectory, rollout files, endpoint, auth identity, and plugin policy did not change. Users lose native thread continuity, drop pending native subagent recovery metadata, and pay a cold prompt-cache rebuild across active sessions after every patch release.Three persisted local custody behaviors caused this loss:
buildCodexAppServerRuntimeFingerprinthashed transientappServerVersion,serverVersion, anduserAgentstrings intolocal-loopbackthread bindings.buildCodexPluginThreadConfigInputFingerprinthashed the full versionedpluginAppCacheKey(containingopenClawVersion,codexPluginVersion,appServerVersion,serverVersion, anduserAgent) intopluginAppsInputFingerprint.appServerRuntimeFingerprint,preserveNativePendingAssignmentsandpreserveCodexNativeSubagentSubmissionshashed the raw runtime fingerprint string, saw a connection mismatch, and dropped both pendingnativeSubagentAssignmentsand unmatchednativeSubagentSubmissionsfrom the committed binding row.User Impact
Local Codex sessions (
connectionClass: "local-loopback") resume their existing native thread across Codex CLI and OpenClaw version upgrades, including sessions whose bindings were persisted by an earlier release before this fix. Pending native subagent assignments and unmatched submission receipts survive the first legacy upgrade resume and migrate their connection ownership hash atomically in place.Supervised connection fingerprints introduced by
#104045(buildCodexAppServerConnectionFingerprint, containing top-levelcodexHome,homeScope, andcwdwithoutruntimeIdentity) stay strictly exact and are never normalized bynormalizeCodexAppServerLocalRuntimeFingerprint. Remote Codex connections still require exact runtime and app-cache fingerprint matches, in-memory app-inventory caches stay versioned across upgrades, and local sessions still rotate threads and clear stale recovery metadata cleanly whenevercodexHome, endpoint,authProfileId, account, desktop generation, supervision scope, or plugin policy changes. No configuration changes or manual migrations are required.Why This Change Was Made
Local loopback restarts after an in-place Codex or OpenClaw upgrade keep the same
CODEX_HOMEand native rollout store on disk. Separating local runtime fingerprints from transient patch-version strings, keeping supervised connection fingerprints exact, and migrating compatible local recovery ownership atomically inside the binding store preserves active threads and in-flight subagent recovery across routine upgrades without loosening any custody boundary.Evidence
Red-on-base regression verification (
0632420a317)0.172.0to0.172.1thread custody check on baseline0632420a317fails as expected:startOrResumeThreadrotated to a new thread (lifecycle.action: "started") instead of resumingthread-existing-local.native-subagent-submission-store.test.ts, upgrading a legacy0.172.0local binding to0.172.1) fails on baseline0632420a317withAssertionError: expected [] to deeply equal [ ... ]because patchingappServerRuntimeFingerprintdropped bothnativeSubagentAssignmentsandnativeSubagentSubmissions.cdd316973ce.Automated test, typecheck, lint, and ratchet checks (
cdd316973ce)--maxWorkers=1across 2 shards (9 files, 318 tests passed oncdd316973ce: 5 files / 102 tests inextension-codexand 4 files / 216 tests inextension-database-workers):extensions/codex/src/app-server/plugin-app-cache-key.test.tsextensions/codex/src/app-server/thread-binding-policy.test.tsextensions/codex/src/app-server/thread-lifecycle.version-bump.test.tsextensions/codex/src/app-server/session-binding.test.tsextensions/codex/src/app-server/native-subagent-inventory.test.tsextensions/codex/src/app-server/native-subagent-submission-store.test.tsextensions/codex/src/app-server/thread-lifecycle.binding.test.tsextensions/codex/src/app-server/native-tool-catalog.test.tsextensions/codex/src/app-server/plugin-thread-config.test.tspnpm tsgo:core,pnpm tsgo:extensions,pnpm tsgo:extensions:test.node scripts/run-oxlint.mjs --tsconfig extensions/tsconfig.json(0 problems in 17 files)oxfmt --check(all 17 files formatted cleanly)node scripts/check-line-cap-ratchet.mjs --base 0632420a317(0 new violations or over-cap growth)git diff --check 0632420a317..cdd316973ce(clean, empty.github/diff)git merge-tree --write-tree --merge-base=0632420a317 origin/main HEAD(clean 0-conflict merge againstorigin/main8e2c8f5b57a)pnpm build:runtime) passes on both baseline (0632420a317) and candidate (cdd316973ce).Isolated CLI and native Codex proof
Verified offline on exact head
cdd316973ceversus baseline0632420a317with both built runtimes (openclaw.mjs agent --local) driving the real nativecodexbinary (0.172.0) through a transparent JSON-RPC stdio wrapper and a loopback-only synthetic127.0.0.1Responses server, using isolated temporaryOPENCLAW_HOME,OPENCLAW_STATE_DIR, andCODEX_HOMEdirectories with zero real credentials and blocked non-loopback proxies. The wrapper logged everyinitialize,thread/start, andthread/resumecall verbatim and rewrote only theinitializeresponse version string (0.172.0->0.172.1->0.172.2) to simulate local CLI upgrades against the same rollout store.After Baseline Turn 1 persisted its legacy
0632420a317SQLite binding row, schema-valid pendingnativeSubagentAssignments(1 entry) and unmatchednativeSubagentSubmissions(1 receipt) keyed to the legacy connection fingerprint were seeded directly intoopenclaw.sqlite(plugin_state_entries), and the state and rollout store were snapshotted and restored in place before Candidate Case A to verify real cold SQLite migration.CODEX_HOME0632420a317)0.172.0CODEX_HOME_Athread/start(1 start, 0 resume)thread-10632420a317)0.172.1CODEX_HOME_Athread/start(1 start, 0 resume)thread-2cdd316973ce)0.172.1CODEX_HOME_Athread/resume(0 start, 1 resume)thread-1cdd316973ce)0.172.2CODEX_HOME_Athread/resume(0 start, 1 resume)thread-1cdd316973ce)0.172.2CODEX_HOME_Bthread/start(1 start, 0 resume)thread-3Scope note: this offline loopback proof verifies real built-OpenClaw thread custody continuity, legacy binding and subagent recovery ownership migration, and
CODEX_HOMErotation boundaries against the native Codex binary and SQLite store. It does not claim or measure live upstream provider prompt-cache hit rates or billing.