Repository navigation
fix(codex): move skills list and memory pointer to collaboration instructions - #87788
Conversation
|
Codex review: needs maintainer review before merge. Reviewed May 29, 2026, 1:35 AM ET / 05:35 UTC. Summary PR surface: Source +31, Tests +29, Docs +10. Total +70 across 9 files. Reproducibility: yes. source-backed rather than locally executed: current main assembles skills and the workspace-memory reference into the native Codex turn input, and the PR body gives a concrete two-turn gateway flow showing the repeated blocks before the fix. Review metrics: none identified. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Next step before merge
Security Review detailsBest possible solution: Land the prompt-surface change after normal maintainer review and required checks, keeping stable skills/memory pointers in collaboration developer instructions while preserving full MEMORY.md fallback in turn input. Do we have a high-confidence way to reproduce the issue? Yes, source-backed rather than locally executed: current main assembles skills and the workspace-memory reference into the native Codex turn input, and the PR body gives a concrete two-turn gateway flow showing the repeated blocks before the fix. Is this the best way to solve the issue? Yes. Moving only the stable skills catalog and tool-routed memory pointer to turn-scoped collaboration developer instructions is narrower than changing skill discovery or memory loading, and the PR keeps full MEMORY.md fallback injection unchanged. AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against fa1d5f658469. Label changesLabel justifications:
Evidence reviewedPR surface: Source +31, Tests +29, Docs +10. Total +70 across 9 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
|
f61bd14 to
8265ac6
Compare
|
@clawsweeper review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
I noticed this PR was mentioned from #85646, so I checked the overlapping Codex prompt-routing path. Facts from that check:
So the reconciled target I see is: keep this PR's memory-pointer routing, but apply a bundled-only trust boundary before moving skills into developer instructions. |
8d765e5 to
48dc15d
Compare
|
Maintainer verification for head pnpm test extensions/codex/src/app-server/run-attempt.test.ts extensions/codex/src/app-server/thread-lifecycle.test.ts -- --reporter=verbose
git diff --check
/Users/steipete/Projects/agent-scripts/skills/autoreview/scripts/autoreview --mode branch --base origin/main
pnpm check:changedResults:
Known proof gap: no live gateway/model session was rerun after the maintainer fix; the PR body records that explicitly. |
Summary
This PR reduces repeated per-turn Codex prompt payload by moving two stable OpenClaw context blocks out of native Codex user input and into turn-scoped collaboration developer instructions:
OpenClaw Workspace MemorypointerFull
MEMORY.mdfallback injection is intentionally unchanged. When memory tools are unavailable, tools are disabled, or the active workspace differs from the configured memory workspace,MEMORY.mdstill uses the existing bounded turn-context path.Why
Native Codex threads preserve prior user turns in their transcript. OpenClaw was adding stable runtime/reference blocks to the user prompt every turn, so those blocks accumulated in the native Codex thread history, and bloated the context with duplicate content.
That is especially wasteful for the compact OpenClaw skills list:
The
OpenClaw Workspace Memoryblock has the same problem whenMEMORY.mdis routed through memory tools. It is a pointer telling Codex that durable memory exists and which tools to use. It does not need to live inside the repeated user prompt.This matters because the user prompt should stay focused on the current user request and truly turn-specific reference context. Stable routing and reference context belongs in developer-instruction surfaces where Codex already handles collaboration-mode overlays.
How
The change splits Codex prompt assembly more cleanly by lifetime and role:
OpenClaw Skillsis rendered as turn-scoped collaboration developer instructions for native Codex turns.OpenClaw Workspace Memorypointer is rendered as turn-scoped collaboration developer instructions.buildCodexOpenClawPromptContextno longer includes skills or the memory pointer in the per-turn user prompt wrapper.MEMORY.mdfallback content is still included through the existing bounded workspace prompt context when the tool-routed memory path is not valid.This keeps stable context available to Codex while reducing repeated user-input payload in normal native Codex sessions.
Behavior addressed
Native Codex turns should stop repeating the compact OpenClaw skills list and tool-routed memory pointer in the per-turn user input. Those blocks should instead arrive through turn-scoped collaboration developer instructions. Full
MEMORY.mdfallback injection should continue to behave exactly as before.Real environment tested
Local OpenClaw source checkout, using the Codex app-server test harness.
bash node scripts/run-vitest.mjs extensions/codex/src/app-server/run-attempt.test.ts extensions/codex/src/app-server/attempt-context.test.ts extensions/codex/src/app-server/thread-lifecycle.test.ts --run git diff --check node_modules/.bin/oxfmt --check extensions/codex/src/app-server/attempt-context.ts extensions/codex/src/app-server/run-attempt.ts extensions/codex/src/app-server/thread-lifecycle.ts extensions/codex/src/app-server/run-attempt.test.ts docs/concepts/system-prompt.md docs/plugins/codex-harness-reference.md docs/plugins/codex-harness-runtime.md docs/reference/token-use.mdEvidence after fix
The Codex app-server tests now assert that:
collaborationMode.settings.developer_instructionsturn/startuser inputOpenClaw Workspace Memorypointer is present in collaboration developer instructionsturn/startuser inputMEMORY.mdfallback content remains in the existing prompt path when memory tools cannot route itMEMORY.mdbootstrap files still use the normal workspace context behaviorThe targeted test run passed:
text
Test Files 3 passed (3)
Tests 124 passed (124)
Observed result after fix
For normal native Codex turns with memory tools available, stable skills metadata and the memory-tool pointer are no longer repeated inside the user prompt. Codex still receives them as turn-scoped developer instructions, while the current user request remains clean.
When the full
MEMORY.mdfallback path is required,MEMORY.mdremains in the bounded turn-context path as before.Real behavior proof guidance
Before the fix I ran the gateway, reset the session with
/new, and prompted it first:reply only "1". This step is needed as we want to check what happens to the prompt on the second turn. After the agent's reply, I entered the next prompt:check your current system prompt. report, do you have any duplicated blocks in there, like files being included multiple timesAgent's reply:
After the fix, I did the same: reset the session with
/new, and prompted it first:reply only "1". After the agent's reply, I entered the same next prompt:check your current system prompt. report, do you have any duplicated blocks in there, like files being included multiple timesAgent's reply now changed to reflect the expected behavior:
As expected, the agents does not see the addressed repetition anymore. It still identifies other duplications, but they are outside of the scope of this PR: skill overlap between Codex and OpenClaw, and conversation history bloat.
Real behavior proof
pnpm check:changedfor the changed extension/docs lanes.pnpm test extensions/codex/src/app-server/run-attempt.test.ts extensions/codex/src/app-server/thread-lifecycle.test.ts -- --reporter=verbose git diff --check /Users/steipete/Projects/agent-scripts/skills/autoreview/scripts/autoreview --mode branch --base origin/main pnpm check:changedTest Files 2 passed (2)andTests 124 passed (124). The final Blacksmith Testbox run wastbx_01ksvtb706dcemdf9rzeq4fe6swith GitHub Actions run https://github.com/openclaw/openclaw/actions/runs/26677310030, and completed with exit code 0. Autoreview completed clean withautoreview clean: no accepted/actionable findings reported.turn/startuser input, and recorded in trajectorysystemPromptrather than the user prompt. The tests also assert the routed memory pointer is delivered through collaboration developer instructions, full MEMORY.md fallback still uses the existing prompt path, ordinary delivery hints are rewrapped without leaking metadata into user text, and lightweight cron prompts stay byte-for-byte unchanged with no skills overlay.