Skip to content

fix(codex): restore persona on remote app-server connections - #162156

Merged
Kimiyu-186 merged 4 commits into
mainfrom
codex/persona-thread-delivery-0930
Sep 30, 2026
Merged

Kimiyu-186 merged 4 commits into
mainfrom
codex/persona-thread-delivery-0930

Conversation

@Kimiyu-186

@Kimiyu-186 Kimiyu-186 commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

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.md overlays 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/start and thread/resume developerInstructions field. 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 personalUser metadata 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:

  • Existing managed-relay delivery remains parent-only and request-local.
  • Workspace loading, privacy filters, size budgets, AGENTS.md handling and memory-tool routing are unchanged.
  • No new relay, OCE-specific branch, authentication change, storage change or Codex dependency update. OpenClaw remote worker mode is outside this fix.
  • OCE rollout requires a later runtime pin update; this PR changes the OC adapter.

Evidence

  • Complete local OCE baseline: two fresh real-model turns received AGENTS but missed all three persona markers, despite verified workspace delivery.
  • A real native Codex WebSocket regression fails before the fix and passes afterward with catalog-owned collaboration instructions. It covers initial delivery, edits and removal on the same thread. All four native tests pass, including incognito refresh after compaction. The new WebSocket case took 0.512 seconds in the recorded passing run.
  • Complete local OCE candidate: fresh persona, same-conversation edits, clearing SOUL, and continuation after completed native compaction all passed. Four real-model turns retained one native thread ID and made zero tool calls. Native rollout records confirm persona in model-facing developer messages; original workspace files were restored.
  • Live validation used candidate Gateway OC 7129faaf068 with unchanged Harness OC 9d9c8568c51 / 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.
  • Focused lifecycle/compaction and run-attempt regressions, production/test types, scoped lint, formatting and QA runtime build passed. Independent review found no P0/P1 issue in the selected implementation diff. After the naming cleanup, all 14 workspace-context tests and all four native tests passed (the external WebSocket regression took 0.466 seconds). Extension production/test types and scoped lint passed; 16/17 prompt-snapshot tests passed, including persona isolation and prompt content.

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:

  • The same test observes shared USER.md in developer messages and no personal marker anywhere in model requests across creation, edits, and withdrawal. Its report records zero personal characters injected.
  • The existing managed-relay test observes the personal overlay on the parent request, excludes it from child and compaction requests, and verifies it never enters native thread requests.
  • Existing preparation tests cover profile selection and workspace-path remapping, including a shared root USER.md in a directory named users/arbitrary.
  • Updated the system-prompt and user-model guides to match the actual carriers and deferred personal-profile scope.

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 base 7c5997006c892b87432233f57c87188e97426e44, 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 45181722e0a7 passed the hosted CI gate. That result does not certify the personal-profile follow-up head.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: codex size: L labels Sep 30, 2026
@Kimiyu-186
Kimiyu-186 marked this pull request as ready for review September 30, 2026 22:02
@clawsweeper

clawsweeper Bot commented Sep 30, 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.

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 30, 2026
@clawsweeper

clawsweeper Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 30, 2026, 6:55 PM ET / 22:55 UTC (Revision 2).

ClawSweeper review

What this changes

The 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 provenance

Possible 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
Reviewed head: 606329a1edde85edd19003b31bb8eb4df96326e9
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Direct native and reported real-model proof is strong, while the unapproved personal-profile compatibility change limits merge readiness.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The contributor reports real-model turns through the remote Gateway path showing shared persona delivery, edits, clearing, and post-compaction continuation. For the final head, the inspected regression uses the production Codex adapter over a real native WebSocket app-server and captures model requests showing shared USER content, edited and withdrawn persona, and no selected personal marker; the managed-path case checks parent-only delivery. The review did not execute these runs. No stored-data format or migration changes.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The contributor reports real-model turns through the remote Gateway path showing shared persona delivery, edits, clearing, and post-compaction continuation. For the final head, the inspected regression uses the production Codex adapter over a real native WebSocket app-server and captures model requests showing shared USER content, edited and withdrawn persona, and no selected personal marker; the managed-path case checks parent-only delivery. The review did not execute these runs. No stored-data format or migration changes.
Evidence reviewed 11 items Current main behavior: At the fetched main revision, ordinary remote persona still uses the collaboration instruction field that catalog-owned instructions can replace.
Latest release check: The supplied latest release tag, v2026.9.7, also retains the legacy collaboration carrier; it does not contain this remote repair.
Dependency contract: The Codex 0.158.0 source prefers catalog collaboration instructions over caller-supplied collaboration settings, establishing why the current OpenClaw carrier can be ineffective.
Findings 1 actionable finding [P1] Preserve or explicitly migrate remote personal-profile delivery
Security None None.

How this fits together

OpenClaw 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]
Loading

Decision needed

Question Recommendation
Should no-relay Codex connections intentionally stop delivering selected personal USER profiles on every model until a proven parent-only carrier exists, while allowing shared persona inheritance and the documented incognito freshness limits? Approve shared-only remote behavior: Accept the profile omission and inheritance limits, with a user-visible notice and clear upgrade documentation until a parent-only carrier exists.

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

  • Preserve or explicitly migrate remote personal-profile delivery (P1) - Filtering selected personal USER files out of the new thread carrier removes them from every no-relay connection. Remote models without a catalog override previously received that overlay through the per-turn collaboration field, so an existing selected profile can stop affecting replies after upgrade; the new warning reaches logs only. Keep a proven parent-only path or obtain explicit owner approval and provide a user-visible omission and recovery path.
  • Resolve merge risk (P1) - After upgrade, no-relay Codex connections omit a selected personal USER profile even on models that previously consumed the legacy per-turn field; the warning is confined to logs and the compatibility loss has no explicit maintainer acceptance.
  • Resolve merge risk (P1) - Native children can inherit shared persona and memory guidance, while an incognito continuation or fresh child can see creation-time guidance after edits or removal. Acceptance of the analogous skill-catalog limits does not establish acceptance for persona and user preferences.
  • Complete next step (P2) - Resolve the remote personal-profile compatibility finding and obtain owner approval for shared persona inheritance and incognito freshness limits before merge.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

  • [P1] Preserve or explicitly migrate remote personal-profile delivery — src/agents/harness/workspace-context.ts:143-145
Agent review details

Security

None.

PR surface

Source -27, Tests +204, Docs +16. Total +193 across 33 files.

View PR surface stats
Area Files Added Removed Net
Source 19 114 141 -27
Tests 10 304 100 +204
Docs 4 44 28 +16
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 33 462 269 +193

Review metrics

None.

Merge-risk options

Maintainer options:

  1. Approve and surface the omission (recommended)
    Approve shared-only remote delivery and the documented native-child limits, then show affected users that their selected personal profile was omitted.
  2. Retain a proven parent-only path
    Keep legacy personal delivery only where final model-request and child-boundary proof establishes it remains parent-only.
  3. Pause for native support
    Wait for a Codex parent-only instruction carrier if neither the omission nor a bounded legacy path is acceptable.

Technical review

Best 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:

  • [P1] Preserve or explicitly migrate remote personal-profile delivery — src/agents/harness/workspace-context.ts:143-145
    Filtering selected personal USER files out of the new thread carrier removes them from every no-relay connection. Remote models without a catalog override previously received that overlay through the per-turn collaboration field, so an existing selected profile can stop affecting replies after upgrade; the new warning reaches logs only. Keep a proven parent-only path or obtain explicit owner approval and provide a user-visible omission and recovery path.
    Confidence: 0.88

Overall correctness: patch is incorrect
Overall confidence: 0.88

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 9cc63c373ce8.

Labels

Label changes:

  • remove merge-risk: 🚨 security-boundary: Current PR review merge-risk labels are merge-risk: 🚨 compatibility, merge-risk: 🚨 session-state.

Label justifications:

  • P1: The current remote Codex persona failure affects agent replies, and this repair also changes existing personal-profile behavior.
  • merge-risk: 🚨 compatibility: A selected personal USER profile can stop influencing replies on no-relay connections after upgrade.
  • merge-risk: 🚨 session-state: Shared persona moves into native thread state, where child inheritance and incognito refresh timing affect which instructions a turn sees.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (terminal): The contributor reports real-model turns through the remote Gateway path showing shared persona delivery, edits, clearing, and post-compaction continuation. For the final head, the inspected regression uses the production Codex adapter over a real native WebSocket app-server and captures model requests showing shared USER content, edited and withdrawn persona, and no selected personal marker; the managed-path case checks parent-only delivery. The review did not execute these runs. No stored-data format or migration changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The contributor reports real-model turns through the remote Gateway path showing shared persona delivery, edits, clearing, and post-compaction continuation. For the final head, the inspected regression uses the production Codex adapter over a real native WebSocket app-server and captures model requests showing shared USER content, edited and withdrawn persona, and no selected personal marker; the managed-path case checks parent-only delivery. The review did not execute these runs. No stored-data format or migration changes.

Evidence

What I checked:

Likely related people:

  • Josh Lehman: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Colton-Harris: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • RoboClaw: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Sarah Fortune: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Resolve the selected personal-profile upgrade behavior with the Codex and profile owners and give affected users a visible outcome.
  • Record the owner's decision on shared persona inheritance and incognito refresh limits.

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 (1 earlier review cycle)
  • reviewed 2026-09-30T22:10:44.173Z sha 4518172 :: blocked before merge. :: [P1] Keep personal USER profiles out of native child instructions | [P3] Update the system-prompt guide for external Codex connections

@Kimiyu-186

Copy link
Copy Markdown
Contributor Author

Addressed both findings. The native thread section now includes only shared persona; selected personal users/<profile-id>/USER.md overlays stay on the managed parent-only relay. On connections without that relay, personal overlays are explicitly omitted, logged, and reported as zero characters injected. Remote personal-profile support remains deferred rather than putting it into inheritable history. Shared persona inheritance is intentional.

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.

@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Sep 30, 2026
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. label Sep 30, 2026
@Kimiyu-186
Kimiyu-186 merged commit 6f91eda into main Sep 30, 2026
201 of 205 checks passed
@Kimiyu-186
Kimiyu-186 deleted the codex/persona-thread-delivery-0930 branch September 30, 2026 23:05
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 1, 2026
miguelbranco80 pushed a commit to raw-labs/openclaw-enterprise that referenced this pull request Oct 3, 2026
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.
obviyus added a commit that referenced this pull request Nov 27, 2026
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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 28, 2026
…#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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation extensions: codex merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Follow up dedicated Codex SOUL/persona delivery after demo

1 participant