fix(agents): bound plugin system context#87341
Conversation
|
Codex review: needs maintainer review before merge. Reviewed May 27, 2026, 3:38 PM ET / 19:38 UTC. Summary PR surface: Source +31, Tests +131. Total +162 across 7 files. Reproducibility: yes. Current main source shows plugin hook system context is concatenated with blank-line separators, and the PR body includes a real local plugin smoke showing the compiled prompt after the fix. Review metrics: 1 noteworthy metric.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge Security Review detailsBest possible solution: Land the narrow hook-merge wrapper once maintainers accept the plugin prompt-format compatibility tradeoff and normal checks pass; keep the lower-level composer plugin-agnostic. Do we have a high-confidence way to reproduce the issue? Yes. Current main source shows plugin hook system context is concatenated with blank-line separators, and the PR body includes a real local plugin smoke showing the compiled prompt after the fix. Is this the best way to solve the issue? Yes, with maintainer compatibility approval. Wrapping only the plugin hook merge outputs is narrower than changing the lower-level system prompt composer or requiring each plugin author to add their own boundary. AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against 90f30075aa72. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +31, Tests +131. Total +162 across 7 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
|
|
ClawSweeper PR egg ✨ Hatched: 🥚 common Clockwork Shellbean Hatch commandComment Hatchability rules:
Rarity: 🥚 common. What is this egg doing here?
|
db0c6ec to
552367e
Compare
552367e to
65c9d6e
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
65c9d6e to
999fde4
Compare
999fde4 to
0b42c56
Compare
|
Addressed the Codex app-server sibling test request and updated the PR body verification for current head @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Closing this PR as superseded by the equivalent fix already on That commit adds the plugin hook system-context boundary, applies it in the harness and embedded/CLI prompt hook merge paths, and updates the Codex app-server sibling expectation. Keeping this PR open would only conflict with the landed canonical implementation. |
Summary
Fixes #87045 by wrapping plugin-emitted system context with a stable boundary and attribution note before it is joined into model-visible system/developer instructions.
The wrapper is applied only at plugin hook merge points for
before_prompt_build/ legacybefore_agent_startsystem context. The lower-level system prompt composer remains unchanged, so non-plugin runtime context is not mislabeled as plugin content.Root Cause
Plugin hook fields such as
appendSystemContextwere joined next to the base system prompt with only blank-line separation. When the base prompt ended with Codex workspace-file Markdown and the plugin emitted another##heading, the model could treat the plugin block as another section of the preceding workspace file.Behavior Change
Plugin-provided
prependSystemContextandappendSystemContextnow render as a separate# OpenClaw Plugin System Contextblock bounded by---, with a note that the content came from OpenClaw plugins and is not part of a workspace file or project document.Real behavior proof
Behavior addressed: Plugin hook system context no longer appears as an unbounded continuation of workspace-file Markdown across harness, embedded runner, CLI prompt preparation, and Codex app-server prompt preparation paths.
Real environment tested: Local OpenClaw checkout on macOS, branch
codex/87045-plugin-context-boundary, current head0b42c568795839cb13f8494e6ca356f635161028, rebased ontoorigin/mainbefore rerunning verification on May 27, 2026.Exact steps or command run after this patch:
Evidence after fix: Terminal output from the real local plugin smoke on current head showed the compiled system prompt with a plugin boundary and attribution note before the plugin-supplied rules. Current head was verified as
0b42c568795839cb13f8494e6ca356f635161028; focused regression proof passed 7 test files / 439 tests, including the Codex app-server sibling coverage requested by review, andgit diff --check origin/main...HEADcompleted cleanly. The copied terminal output is included below.Observed result after fix: The real local plugin hook returned
appendSystemContext: "## My Custom Rules\n\nFoo bar baz."; the compiled system prompt places the workspace-style## TOOLS.mdcontent first, then inserts---,# OpenClaw Plugin System Context, the plugin attribution note, the plugin rules, and a closing---before the model identity text. The Codex app-server sibling test now also asserts wrapped pre- and post-system plugin context around the custom Codex system prompt.What was not tested: Live model attribution smoke. Focused oxlint was attempted, but the wrapper is currently blocked before linting by unrelated plugin-sdk boundary DTS errors in current main under
src/media/*andsrc/gateway/managed-image-attachments.ts.Before evidence (optional but encouraged): Not captured; the proof here is after-fix terminal output plus focused regression coverage.
Current head verified:
Terminal output copied from the smoke:
Focused regression proof also passed:
git diff --check origin/main...HEADcompleted cleanly.Verification
0b42c568795839cb13f8494e6ca356f635161028initializeGlobalHookRunner+prepareCliRunContext, with redacted compiledcontext.systemPromptshown abovenode scripts/run-vitest.mjs extensions/codex/src/app-server/run-attempt.test.ts src/agents/harness/prompt-compaction-hook-helpers.test.ts src/agents/embedded-agent-runner/run/attempt.test.ts src/agents/cli-runner/prepare.test.tsgit diff --check origin/main...HEADFixes #87045