Repository navigation
fix(codex): restore persona on remote app-server connections - #162156
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: blocked before merge. Reviewed September 30, 2026, 6:55 PM ET / 22:55 UTC (Revision 2). ClawSweeper reviewWhat this changesThe Codex plugin moves shared workspace persona and memory guidance into refreshable app-server thread instructions, updates lifecycle coverage and docs, and excludes selected personal USER files from that inheritable carrier. Regression provenancePossible regression — suspected (failure trace). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 5 items remain Current main still lacks reliable persona delivery on remote Codex connections. The latest head addresses the earlier personal-profile leak, but deliberately stops delivering selected personal profiles on those connections and needs an explicit compatibility decision. Priority: P1 Review scores
Verification
How this fits togetherOpenClaw prepares workspace instructions and sends them through its Codex plugin to an app-server. Codex turns those instructions into model context and can pass thread instructions to native child agents; a managed inference relay provides a separate parent-only path. flowchart LR
A[Shared workspace files] --> C[Codex adapter]
B[Selected personal profile] --> C
C --> D{Managed relay available}
D -->|Yes| E[Parent-only model request]
D -->|No| F[Refreshable thread context]
E --> G[Parent model]
F --> H[Parent model and native children]
Decision needed
Why: The patch makes a defensible isolation choice that changes existing profile behavior and native-child instruction scope; source review cannot authorize that product and security tradeoff. Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource -27, Tests +204, Docs +16. Total +193 across 33 files. View PR surface stats
Review metricsNone. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Use the existing thread refresh path for shared workspace guidance and keep personal content parent-only; make any unsupported remote personal-profile selection visible to users under an approved upgrade policy. Do we have a high-confidence way to reproduce the issue? Yes. Current-main OpenClaw source sends remote persona through the replaceable collaboration field, and Codex 0.158.0 source confirms catalog instructions take precedence; the PR reports before/after real-model and native WebSocket observations. This read-only review did not execute a turn. Is this the best way to solve the issue? No, as submitted. The shared thread carrier is a focused repair, but dropping selected remote personal profiles needs an approved, user-visible upgrade outcome, and the changed child-inheritance scope needs owner acceptance. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 9cc63c373ce8. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Addressed both findings. The native thread section now includes only shared persona; selected personal The native WebSocket regression failed on the previous head because the personal marker reached the model. It now passes through creation, edits, and removal; the managed test still delivers the overlay to the parent and excludes it from child/compaction requests. The system-prompt and user-model guides now match this behavior. |
Move the runtime source from OpenClaw 9d9c8568c5 to main commit 6f91eda9c72d6b4c2640cb76b5a753e64089f6f2 (openclaw/openclaw#162156), which restores persona delivery on remote Codex app-server connections and drops the per-turn "parent-local egress workaround is unavailable" WARN that every dedicated Codex turn logged. Refresh the archive checksum and build timestamp. Rebase the read-only-paths bridge patch: upstream compacted the network-proxy case in config.test.ts, so only that test hunk is rewritten; the source hunks are byte-identical. The connect bridge patch applies unchanged. Update the workspace-template version to the source's 2026.9.7; the four template bodies and their identity are unchanged.
Root cause: extensions/codex/src/app-server/thread-lifecycle-run.ts:154 dropped the native thread developer carrier whenever the managed inference relay existed, and extensions/codex/src/app-server/run-attempt-turn-request.ts:293 put skills, shared persona, memory and session project guidance into the relay text that inference-context.ts:271 adds to every request's top-level `instructions`. GPT-6.2 Sol and Astra never cache `instructions`, so every warm request in a turn re-paid that whole block. Fixes #206421 Thanks @brandon-julio-t for the precise report (managed vs `appServer.command` A/B with per-request usage), and @NaturalMatchaKing for the A/B evidence in #204136. ## What changed - Skills, shared persona (`SOUL.md`, `IDENTITY.md`, workspace-root `USER.md`), memory guidance and session project guidance now always ride the existing refreshable thread developer section, on managed connections too. Codex sends that as a `developer` input item, so it sits in the cached prefix, and later requests in a turn only append. - The relay keeps only parent-only text: the selected personal `users/<id>/USER.md` overlay, cron policy, plugin `before_prompt_build` system context, and per-turn conversation instructions. Per-turn plugin context stays off the thread on relay connections (`turnRefreshableInstructions` split; still thread-carried when there is no relay, as before). - `workspace-context.ts` renders the personal-only persona with the same renderer; the codex context plumbs `personalPersonaInstructions` instead of the full persona. - Edits to that section no longer refuse a thread kept alive by background work. Before this, a skill, persona or memory edit made the next message cold-resume the thread, and a thread kept alive by a running background command refused with "still has background work… stop its running work and retry". `appServer.command` and other non-relay connections already failed this way on main; managed connections would have started to with the carrier move. Now the refreshable section is left out of the thread configuration fingerprint, and persistent live threads keep the same in-memory record incognito threads already had of the section the thread was natively given (`nativeRefreshableInstructions`) and the one last delivered. On reuse (`thread-lifecycle-warm.ts`): - Idle thread, section changed: cold resume, as on main, so native configuration carries the current section and compaction rebuilds from it. On managed connections this costs one uncached turn per edit. - Protected thread (running background command or child), section changed: the existing appended developer handoff instead of the refusal; the existing post-compaction restore re-delivers it. - Self-heal: the first later turn where the thread is no longer protected and its native section still differs from the current one cold-resumes. - Managed relay fallback: while a thread's native section differs from the current one (an edited incognito thread, or a protected persistent thread waiting for its cold resume), the relay also sends the current section in request `instructions`, as main did for every request, so a post-compaction continuation sees it. It stops when the native copy matches again (after the self-heal cold resume); unedited threads never pay for it. The section never holds the selected personal overlay, so that is still sent once (`renderCodexRelayRefreshableFallback`, thread-policy.ts). No new field, flag or persisted state: the comparison uses the in-memory record, and ephemeral lifetime is keyed off the generic policy that only ephemeral records carry. - Remaining narrow gap, only on connections without a relay (`appServer.command`): an edit made while background work keeps the thread protected, followed by a native compaction before that work ends, can let one continuation request see the previous section. On main those threads refuse the next turn outright. Codex samples the continuation right after compaction, before injected developer messages are drained (`codex-rs/core/src/session/turn.rs` pending-input drain is deferred after auto-compaction; `session/inject.rs` queues injections into the active turn), and the host restore lands on the request after it. It heals on the first unprotected turn. Not taken: (B) carrying the section in turn-level `collaborationMode.settings.developer_instructions`, because a model catalog's default-mode override wins over caller text, it replaces the built-in Default-mode text and collides with OpenClaw's cron collaboration instructions, and native children do not inherit it; (D) asking Codex to drain injected developer messages before the post-compaction continuation, or to accept developer instructions in thread settings, needs a Codex dependency bump. - Report estimate counts the stable section on the thread in both modes. - No model-facing wording changed. Layout change: a user with a personal overlay gets two `## OpenClaw Agent Soul` blocks (shared in the thread, personal in the relay). - `inference-dispatch.ts` untouched (#206475 size recovery kept). ## What remains: 97.2% vs 99.5% Live gpt-6.2-sol against main `712db11dfc9e`, the reporter's five-tool-call turn. Two runs per arm on `2ca1ebe03be6` plus one per arm on `a286631217b9` (the stale-section cold resume does not touch an unedited turn; earlier heads had three runs per arm with the same results). Warm-request cache hit and per-request `input/cached` come from the Codex rollout: | arm | warm hit | uncached input per warm request | previous request's input not cached | uncached input per turn | |---|---|---|---|---| | main, managed relay | 70.6–70.7% | ~6,150–6,200 tokens | 6,054–6,100 tokens | 51.5–51.8k | | this PR, managed relay | 97.2–97.3% | ~570 tokens | 421 tokens | 23.9–24.0k | | `appServer.command` (no relay) | 99.5% | ~100 tokens | 3 tokens | 20.5–20.6k | The remaining ~420 tokens per warm request are the relay's per-turn conversation instructions and tool bindings, which still go in top-level `instructions` and are never cached on these models. They are per-turn facts, so moving them is a separate change (for example to turn `additionalContext`); this PR does not move them. ## Earlier attempt #141270 (@mbelinky) aimed at the same carrier: workspace persona and memory on the thread developer instructions. This PR is a smaller change at the relay/lifecycle owners and does not build on it. ## Deliberate decision reversed This reverses #142276's parent-only delivery for shared text: native Codex subagents now inherit shared persona, skills and memory guidance through `developer_instructions` (`codex-rs/core/src/agent/child_config.rs` `inherited_developer_instructions`). Reasoning: that is already the behavior of every connection without a relay (#162156 called it intentional); native delegation is off wherever session tools are denied; the original #142276 problem (catalog collaboration text replacing caller instructions) is solved by thread developer instructions; and keeping the split costs every managed user about 2.2x the uncached input on a five-tool-call turn (51.8k vs 24.0k tokens; about 11x per warm request). The personal overlay stays parent-only (#162156 privacy boundary kept). A child created after an in-place edit inherits the thread's creation-time section, the same limitation incognito threads already document. ## Evidence Proof comments: #206554 (comment) (cache and request bodies), #206554 (comment) (background-work P1), #206554 (comment) (`2ca1ebe03be6`: scripted lane, live cache, live managed P1), #206554 (comment) (`a286631217b9`: stale-section cold resume, compaction and self-heal regressions, live P1 on both routes, cache), #206554 (comment) (`76341cb30f58`: managed relay fallback regression, live managed P1). Child-inheritance decision: #206554 (comment) - Scripted lane (real managed bundled codex 0.172.0 app-server, real relay, synthetic Responses upstream recording bodies): `run-attempt.skills.native.test.ts` "keeps managed skills in the cached native prefix across a multi-request turn" is red on main (skills in `instructions` on every frame) and green here (marker once in a `developer` input item, each frame's input extends the previous one byte-for-byte). - Background-work regression: `run-attempt.native-background-outcome.test.ts` "refreshes edited skills on a protected thread, then cold-resumes once it ends" (managed relay and `appServer.command`): the protected edit arrives as one handoff with no refusal, and after the listener ends the next turn unsubscribes and cold-resumes with the edited catalog. Red on `8fd3970192d6` (refusal) and on `2ca1ebe03be6` (no self-heal); green here. - Compaction regression: `run-attempt.skills.native.test.ts` "keeps a withdrawn catalog withdrawn after native compaction rebuilds the persistent thread" (real Codex binary, pre-sampling auto-compaction): the continuation request after compaction no longer carries the withdrawn creation catalog. Red on `2ca1ebe03be6`, green here; the incognito case keeps its documented one-request reversion. - Real Gateway + `openclaw agent`, gpt-6.2-sol, a native-shell `sleep` listener started on turn 1, a skill installed with `openclaw skills install`, then turn 2: previous head refuses on both routes; this PR answers with the new skill on both, through a warm refresh handoff, with turn 2's first request cached up to the previous input. After a Gateway restart, the cold resume carries the current section. ## Merge danger Two-way door: no stored state, schema or config changes; a revert restores the previous layout. On first turn after upgrade each managed thread gets one cold resume (Gateway restart) that installs the section, as before. Restricted threads on connections without a relay rotate once after upgrade because their stored fingerprint included the section; afterwards edits cold-resume them instead of rotating them. Blast radius: Codex harness thread lifecycle and relay instructions. Co-authored-by: Ayaan Zaidi <[email protected]>
…#206554) Root cause: extensions/codex/src/app-server/thread-lifecycle-run.ts:154 dropped the native thread developer carrier whenever the managed inference relay existed, and extensions/codex/src/app-server/run-attempt-turn-request.ts:293 put skills, shared persona, memory and session project guidance into the relay text that inference-context.ts:271 adds to every request's top-level `instructions`. GPT-6.2 Sol and Astra never cache `instructions`, so every warm request in a turn re-paid that whole block. Fixes openclaw#206421 Thanks @brandon-julio-t for the precise report (managed vs `appServer.command` A/B with per-request usage), and @NaturalMatchaKing for the A/B evidence in openclaw#204136. ## What changed - Skills, shared persona (`SOUL.md`, `IDENTITY.md`, workspace-root `USER.md`), memory guidance and session project guidance now always ride the existing refreshable thread developer section, on managed connections too. Codex sends that as a `developer` input item, so it sits in the cached prefix, and later requests in a turn only append. - The relay keeps only parent-only text: the selected personal `users/<id>/USER.md` overlay, cron policy, plugin `before_prompt_build` system context, and per-turn conversation instructions. Per-turn plugin context stays off the thread on relay connections (`turnRefreshableInstructions` split; still thread-carried when there is no relay, as before). - `workspace-context.ts` renders the personal-only persona with the same renderer; the codex context plumbs `personalPersonaInstructions` instead of the full persona. - Edits to that section no longer refuse a thread kept alive by background work. Before this, a skill, persona or memory edit made the next message cold-resume the thread, and a thread kept alive by a running background command refused with "still has background work… stop its running work and retry". `appServer.command` and other non-relay connections already failed this way on main; managed connections would have started to with the carrier move. Now the refreshable section is left out of the thread configuration fingerprint, and persistent live threads keep the same in-memory record incognito threads already had of the section the thread was natively given (`nativeRefreshableInstructions`) and the one last delivered. On reuse (`thread-lifecycle-warm.ts`): - Idle thread, section changed: cold resume, as on main, so native configuration carries the current section and compaction rebuilds from it. On managed connections this costs one uncached turn per edit. - Protected thread (running background command or child), section changed: the existing appended developer handoff instead of the refusal; the existing post-compaction restore re-delivers it. - Self-heal: the first later turn where the thread is no longer protected and its native section still differs from the current one cold-resumes. - Managed relay fallback: while a thread's native section differs from the current one (an edited incognito thread, or a protected persistent thread waiting for its cold resume), the relay also sends the current section in request `instructions`, as main did for every request, so a post-compaction continuation sees it. It stops when the native copy matches again (after the self-heal cold resume); unedited threads never pay for it. The section never holds the selected personal overlay, so that is still sent once (`renderCodexRelayRefreshableFallback`, thread-policy.ts). No new field, flag or persisted state: the comparison uses the in-memory record, and ephemeral lifetime is keyed off the generic policy that only ephemeral records carry. - Remaining narrow gap, only on connections without a relay (`appServer.command`): an edit made while background work keeps the thread protected, followed by a native compaction before that work ends, can let one continuation request see the previous section. On main those threads refuse the next turn outright. Codex samples the continuation right after compaction, before injected developer messages are drained (`codex-rs/core/src/session/turn.rs` pending-input drain is deferred after auto-compaction; `session/inject.rs` queues injections into the active turn), and the host restore lands on the request after it. It heals on the first unprotected turn. Not taken: (B) carrying the section in turn-level `collaborationMode.settings.developer_instructions`, because a model catalog's default-mode override wins over caller text, it replaces the built-in Default-mode text and collides with OpenClaw's cron collaboration instructions, and native children do not inherit it; (D) asking Codex to drain injected developer messages before the post-compaction continuation, or to accept developer instructions in thread settings, needs a Codex dependency bump. - Report estimate counts the stable section on the thread in both modes. - No model-facing wording changed. Layout change: a user with a personal overlay gets two `## OpenClaw Agent Soul` blocks (shared in the thread, personal in the relay). - `inference-dispatch.ts` untouched (openclaw#206475 size recovery kept). ## What remains: 97.2% vs 99.5% Live gpt-6.2-sol against main `2553b7e25179`, the reporter's five-tool-call turn. Two runs per arm on `2ca1ebe03be6` plus one per arm on `a286631217b9` (the stale-section cold resume does not touch an unedited turn; earlier heads had three runs per arm with the same results). Warm-request cache hit and per-request `input/cached` come from the Codex rollout: | arm | warm hit | uncached input per warm request | previous request's input not cached | uncached input per turn | |---|---|---|---|---| | main, managed relay | 70.6–70.7% | ~6,150–6,200 tokens | 6,054–6,100 tokens | 51.5–51.8k | | this PR, managed relay | 97.2–97.3% | ~570 tokens | 421 tokens | 23.9–24.0k | | `appServer.command` (no relay) | 99.5% | ~100 tokens | 3 tokens | 20.5–20.6k | The remaining ~420 tokens per warm request are the relay's per-turn conversation instructions and tool bindings, which still go in top-level `instructions` and are never cached on these models. They are per-turn facts, so moving them is a separate change (for example to turn `additionalContext`); this PR does not move them. ## Earlier attempt openclaw#141270 (@mbelinky) aimed at the same carrier: workspace persona and memory on the thread developer instructions. This PR is a smaller change at the relay/lifecycle owners and does not build on it. ## Deliberate decision reversed This reverses openclaw#142276's parent-only delivery for shared text: native Codex subagents now inherit shared persona, skills and memory guidance through `developer_instructions` (`codex-rs/core/src/agent/child_config.rs` `inherited_developer_instructions`). Reasoning: that is already the behavior of every connection without a relay (openclaw#162156 called it intentional); native delegation is off wherever session tools are denied; the original openclaw#142276 problem (catalog collaboration text replacing caller instructions) is solved by thread developer instructions; and keeping the split costs every managed user about 2.2x the uncached input on a five-tool-call turn (51.8k vs 24.0k tokens; about 11x per warm request). The personal overlay stays parent-only (openclaw#162156 privacy boundary kept). A child created after an in-place edit inherits the thread's creation-time section, the same limitation incognito threads already document. ## Evidence Proof comments: openclaw#206554 (comment) (cache and request bodies), openclaw#206554 (comment) (background-work P1), openclaw#206554 (comment) (`2ca1ebe03be6`: scripted lane, live cache, live managed P1), openclaw#206554 (comment) (`a286631217b9`: stale-section cold resume, compaction and self-heal regressions, live P1 on both routes, cache), openclaw#206554 (comment) (`76341cb30f58`: managed relay fallback regression, live managed P1). Child-inheritance decision: openclaw#206554 (comment) - Scripted lane (real managed bundled codex 0.172.0 app-server, real relay, synthetic Responses upstream recording bodies): `run-attempt.skills.native.test.ts` "keeps managed skills in the cached native prefix across a multi-request turn" is red on main (skills in `instructions` on every frame) and green here (marker once in a `developer` input item, each frame's input extends the previous one byte-for-byte). - Background-work regression: `run-attempt.native-background-outcome.test.ts` "refreshes edited skills on a protected thread, then cold-resumes once it ends" (managed relay and `appServer.command`): the protected edit arrives as one handoff with no refusal, and after the listener ends the next turn unsubscribes and cold-resumes with the edited catalog. Red on `8fd3970192d6` (refusal) and on `2ca1ebe03be6` (no self-heal); green here. - Compaction regression: `run-attempt.skills.native.test.ts` "keeps a withdrawn catalog withdrawn after native compaction rebuilds the persistent thread" (real Codex binary, pre-sampling auto-compaction): the continuation request after compaction no longer carries the withdrawn creation catalog. Red on `2ca1ebe03be6`, green here; the incognito case keeps its documented one-request reversion. - Real Gateway + `openclaw agent`, gpt-6.2-sol, a native-shell `sleep` listener started on turn 1, a skill installed with `openclaw skills install`, then turn 2: previous head refuses on both routes; this PR answers with the new skill on both, through a warm refresh handoff, with turn 2's first request cached up to the previous input. After a Gateway restart, the cold resume carries the current section. ## Merge danger Two-way door: no stored state, schema or config changes; a revert restores the previous layout. On first turn after upgrade each managed thread gets one cold resume (Gateway restart) that installs the section, as before. Restricted threads on connections without a relay rotate once after upgrade because their stored fingerprint included the section; afterwards edits cold-resume them instead of rotating them. Blast radius: Codex harness thread lifecycle and relay instructions. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Fixes missing SOUL.md, IDENTITY.md, shared workspace USER.md and memory guidance on Codex connections without OpenClaw's managed inference relay. This includes OCE dedicated Codex: the Gateway connects over WebSocket to a Codex app-server running in a separate Harness.
OpenClaw loaded these files and sent them in
turn/start.collaborationMode.settings.developer_instructions. Since openai/codex#36351, Codex prefers the active model's catalog-provided collaboration instructions over that field. The persona could therefore appear in recorded turn parameters while never reaching the model.OC #142276 restored persona for supported managed-relay connections, but explicitly excluded external app-server connections. OC #140422 subsequently fixed skills on those connections; persona and memory guidance still used the replaceable field. This is a Codex instruction-delivery compatibility problem, independent of shared PVCs or Gateway placement.
Related: OCE #552. Prior art: OC #141270, adapted to the current lifecycle while preserving managed-relay delivery.
User Impact
Affected Codex conversations receive their configured shared workspace persona. Editing or clearing it takes effect on the next turn without creating a new conversation.
Native Codex children can inherit shared persona and memory guidance from this thread-carried context; that behavior is intentional. Selected personal
users/<profile-id>/USER.mdoverlays are excluded. These connections use shared user preferences only and log a warning if a personal overlay was selected. Remote personal-profile delivery remains deferred until a parent-only carrier is available. Managed relay connections still deliver the selected overlay only to the parent.Incognito threads retain the existing refresh limitations: the immediate continuation after native compaction, or a fresh child without inherited history, can see creation-time instructions before a refresh applies. Removing persona does not erase earlier conversation history.
Why This Change Was Made
For connections without a managed relay, send skills, shared persona and memory guidance together through the native
thread/startandthread/resumedeveloperInstructionsfield. Codex includes that field independently of its collaboration-mode instructions. Reuse the skills lifecycle for edits, withdrawal and compaction recovery, keeping the refreshable section separate from generic policy.The preparation owner renders both full persona (for the managed parent-only relay) and shared persona (for inheritable thread instructions), using the loader's
personalUsermetadata rather than guessing from paths. Personal overlays never enter the fallback thread section or its history. Omitted overlays report zero injected characters. Remove the obsolete persona collaboration path and update the documentation.Scope boundaries:
Evidence
7129faaf068with unchanged Harness OC9d9c8568c51/ Codex 0.158.0, retaining OCE's existing runtime bridge patches. This was not an all-container release upgrade. Subsequent changes clarify naming and exclude selected personal overlays from the remote fallback. The full OCE run covered shared persona; the personal-profile boundary is covered by the focused tests below, not by that earlier deployment.Personal-profile boundary follow-up
ClawSweeper correctly identified that combining the selected personal overlay with shared persona would make it inheritable by native children. The regression first failed on
45181722e0a7: the personal marker appeared in the real native WebSocket model request. After the fix:users/arbitrary.All 12 focused preparation, native, and managed cases passed in 42.84 seconds total (two serial Vitest shards). Independent review found no actionable P0/P1 defect in this follow-up. Extension production/test typechecks, scoped core/extension lint, and formatting passed. All 165 existing run-attempt/report tests also passed (77.06 seconds). The existing external WebSocket case took 0.482 seconds; no new process fixture was added. Native child inheritance is grounded in Codex 0.158.0
child_config.rs; the remote regression inspects what enters native model history, rather than launching a native child.Local check limitations
The remaining prompt-snapshot assertion checks that generation makes zero jiti plugin-loader calls. It observed three calls to the untouched OpenAI
provider-policy-api.ts. Replaying that assertion with all PR changes removed, at original base7c5997006c892b87432233f57c87188e97426e44, produced the identical failure. This PR does not fix that pre-existing performance check.The full root-test typecheck could not complete because this sparse checkout omits the tracked Android release script and Linux release-version fixture it imports. Extension production/test typechecks and a focused typecheck of the changed snapshot helper passed. The prior head
45181722e0a7passed the hosted CI gate. That result does not certify the personal-profile follow-up head.