Skip to content

fix(codex): stop quoted context from triggering explicit skill mentions - #123345

Merged
steipete merged 1 commit into
mainfrom
steipete/issue-122812-root-cause-b17a34
Aug 13, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/issue-122812-root-cause-b17a34

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Fixes #122812

What Problem This Solves

Codex-backed agents could invoke a skill because its $skill-name token appeared in projected conversation history or quoted inbound context (reply quotes, room backlog) rather than in the raw current user message. Codex byte-scans every turn text input for explicit $name skill mentions and [@name](plugin://...) links (codex-rs/skills/src/mentions.rs, codex-rs/skills/src/selection.rs:94-103) with no quoting or code-fence awareness, and OpenClaw's Codex adapter packs projected history plus the current request into one UserInput::Text — so a historical $example-manual inside <conversation_context> was indistinguishable from a freshly typed one. Codex selected the skill and injected its full body, exactly the deterministic signature in the issue report.

Why This Change Was Made

Codex's UserInput enum has no unscanned text variant, so the only correct owner for the fix is OpenClaw's projection boundary. The repo already has the canonical technique pointing the other direction: escapeCodexChatText (extensions/codex/src/command-formatters.ts) neutralizes mention triggers with fullwidth lookalikes so Codex output cannot ping channel users. This change mirrors it channel→Codex: neutralizeCodexExplicitMentionSigils swaps $name → $name and [@name]( → [@name]( inside the rendered <conversation_context> block (the single choke point shared by fresh-thread continuity, context-engine, and stale-binding-resume projections) and the inbound quoted-reply/room-backlog envelope. Fullwidth characters keep identical UTF-16 lengths, so no truncation/range math changes. The raw current request stays untouched: a $skill the user actually types this turn still resolves.

The other half of #122812 — external channels not resolving $skill at all — is the documented WebChat/Control-UI-only product contract (docs/tools/skills.md, feature commit 7fa95e2) and is intentionally unchanged here, matching the ClawSweeper recommendation on the issue.

User Impact

Codex-harness agents no longer falsely report that the user explicitly invoked a skill when the $skill token only exists in history, summaries, quoted replies, or room backlog. Genuine current-turn explicit mentions keep working.

Evidence

  • Both regression tests fail on pre-fix code (2 failed) and pass with the fix: node scripts/run-vitest.mjs extensions/codex/src/app-server/context-engine-projection.test.ts extensions/codex/src/app-server/run-attempt-state.test.ts → 25 passed.
  • node scripts/check-changed.mjs green (remote proof backend unreachable; local fallback per policy).
  • Codex autoreview (gpt-5.6-sol, high): clean, "patch is correct (0.99)".
  • Dependency contract verified directly in sibling Codex source at 91d6f48992ad (skills/src/selection.rs, skills/src/mentions.rs, protocol/src/user_input.rs).
  • Production LOC +18/−3 (tests +46): new invariant enforcement at a dependency boundary; Codex offers no unscanned input channel to absorb it net-neutral.

Supersedes the approach in #123311 for the reported defect; the cross-channel $skill expansion proposed there remains a separate product decision. Thanks @hannesrudolph for the report and the detailed provenance diagnosis.

Codex byte-scans every turn text input for $name skill mentions and
[@name](plugin://...) links (codex-rs/skills/src/mentions.rs), so historical
$skill tokens inside OpenClaw's projected <conversation_context> block and
inbound quoted-reply/room-backlog context counted as current explicit
invocations and injected skill bodies the user never requested.

Neutralize mention sigils with same-length fullwidth lookalikes (the
escapeCodexChatText technique) in projected history and inbound context;
only the raw current request stays selectable.

Fixes #122812
@clawsweeper

clawsweeper Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 13, 2026 22:23
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 13, 2026
@clawsweeper

clawsweeper Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 13, 2026, 6:28 PM ET / 22:28 UTC.

ClawSweeper review

What this changes

The PR makes projected Codex history and quoted inbound context inert for explicit skill scanning while preserving skill mentions in the current user request.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open for maintainer review. The supplied patch and tests support a focused fix, but the read-only sandbox failed before any repository, history, scoped-policy, or Codex dependency inspection could run; the protected maintainer label also requires explicit human handling.

Priority: P2
Reviewed head: 08f1d03445c681604a770ad7d8f64ff85d192647
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The supplied patch is focused and has targeted regression coverage, with final confidence limited by the unavailable read-only inspection environment.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-associated PR is not subject to the external-contributor real-behavior-proof gate; its supplied regression-test evidence remains supplemental.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-associated PR is not subject to the external-contributor real-behavior-proof gate; its supplied regression-test evidence remains supplemental.
Evidence reviewed 3 items Inspection infrastructure failure: The read-only command sandbox failed before executing inspection commands, so current source, git history, scoped policy files, and sibling Codex source could not be independently verified.
Affirmative Codex dependency signal: The PR body explicitly states that behavior depends on Codex UserInput text scanning and cites Codex skill-selection sources; direct dependency inspection was blocked by the sandbox failure.
Focused supplied diff: The supplied PR patches only Codex projection and inbound-context handling, with regression coverage for historical versus current-request mention handling.
Findings None None.
Security None None.

How this fits together

The Codex extension combines OpenClaw context with the active request before submitting a Codex turn. Codex skill selection then scans that submitted text, so this boundary determines whether a mention is historical reference text or a current invocation.

flowchart LR
  A[Conversation history] --> C[Codex context projection]
  B[Current user request] --> C
  D[Quoted reply or room backlog] --> E[Inbound context envelope]
  C --> F[Codex turn input]
  E --> F
  F --> G[Skill mention selection]
  G --> H[Agent run]
Loading

Decision needed

Question Recommendation
Should this focused Codex projection fix land independently while the broader cross-channel skill-contract proposal remains separate? Land the focused safeguard: Confirm the current-head Codex input paths and regression behavior, then merge this targeted false-selection repair independently.

Why: The PR carries a protected maintainer label, and the required local source and Codex-contract inspection could not be completed in this review environment.

Before merge

  • Resolve merge risk (P1) - Independent verification of the Codex scanner contract and all OpenClaw prompt-construction paths was blocked by the read-only sandbox failure.
  • Complete next step (P2) - A protected maintainer-labeled PR and unavailable local inspection require explicit maintainer validation rather than automated repair or closure.
Agent review details

Security

None.

PR surface

Source +18, Tests +41. Total +59 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 23 5 +18
Tests 2 41 0 +41
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 64 5 +59

Review metrics

Metric Value Why it matters
Production versus test delta production +18/-3; tests +41/-0 The supplied diff adds a small boundary invariant and focused regression coverage rather than expanding configuration or persisted state.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land a narrowly scoped projection-boundary safeguard only after a maintainer confirms on the current head that every reference-context input is neutralized without changing genuine current-turn invocation behavior.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land a narrowly scoped projection-boundary safeguard only after a maintainer confirms on the current head that every reference-context input is neutralized without changing genuine current-turn invocation behavior.

Do we have a high-confidence way to reproduce the issue?

Unclear: the PR body supplies a concrete regression scenario, but sandbox failure prevented an independent current-head reproduction or source trace.

Is this the best way to solve the issue?

Unclear: neutralizing reference-context text at the Codex projection boundary appears appropriately narrow, but the complete input-path and Codex-contract checks could not be performed.

AGENTS.md: unclear because the file could not be read completely.

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

Labels

Label changes:

  • add P2: This is a bounded correction for unintended skill selection in the Codex extension.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-associated PR is not subject to the external-contributor real-behavior-proof gate; its supplied regression-test evidence remains supplemental.

Label justifications:

  • P2: This is a bounded correction for unintended skill selection in the Codex extension.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-associated PR is not subject to the external-contributor real-behavior-proof gate; its supplied regression-test evidence remains supplemental.

Evidence

What I checked:

  • Inspection infrastructure failure: The read-only command sandbox failed before executing inspection commands, so current source, git history, scoped policy files, and sibling Codex source could not be independently verified.
  • Affirmative Codex dependency signal: The PR body explicitly states that behavior depends on Codex UserInput text scanning and cites Codex skill-selection sources; direct dependency inspection was blocked by the sandbox failure. (08f1d03445c6)
  • Focused supplied diff: The supplied PR patches only Codex projection and inbound-context handling, with regression coverage for historical versus current-request mention handling. (extensions/codex/src/app-server/context-engine-projection.ts, 08f1d03445c6)

Likely related people:

  • steipete: The available PR metadata identifies this maintainer-associated contributor as the author of the focused Codex extension repair; local feature-history verification was unavailable. (role: current Codex extension contributor; confidence: low; commits: 08f1d03445c6; files: extensions/codex/src/app-server/context-engine-projection.ts, extensions/codex/src/app-server/run-attempt-state.ts)

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.

@steipete
steipete merged commit e04dfd2 into main Aug 13, 2026
158 of 159 checks passed
@steipete
steipete deleted the steipete/issue-122812-root-cause-b17a34 branch August 13, 2026 22:33
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit that referenced this pull request Aug 13, 2026
#123345 added the file without a project owner; the full-suite coverage
guard fails for any PR that runs it.
steipete added a commit that referenced this pull request Aug 13, 2026
#123345 added extensions/codex/src/app-server/run-attempt-state.test.ts
without a lane owner; the full-suite ownership audit
(test/vitest-projects-config.test.ts) fails on main and every PR. Register
it beside its run-attempt siblings in the attempt-extra lane.
steipete added a commit that referenced this pull request Aug 14, 2026
* feat(docker): schedule image refreshes

* docs(docker): explain weekly image refreshes

* test(scripts): gate workflow-step execution on bash 4 mapfile support

Stock macOS bash 3.2 lacks mapfile; CI truth is Linux bash 5.

* test: cover docker-release suffix threading and sanctioned second caller

* test(codex): wire run-attempt-state into the attempt-extra project

#123345 added the file without a project owner; the full-suite coverage
guard fails for any PR that runs it.

* fix(ci): run build-artifacts PR validation on hosted runners

ci-build-artifacts-testbox.yml pinned PR runs to blacksmith-16vcpu and
ran Testbox lifecycle steps unconditionally, so the prepare-run landing
gate starved for every PR during a Blacksmith outage even with
OPENCLAW_CI_RUNNER_BACKEND=github. PR events now build on ubuntu-24.04
with dispatch-only Testbox steps, mirroring ci-check-testbox.yml.

* test(ci): align build-artifacts dispatch guard
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 14, 2026
…ns (openclaw#123345)

Codex byte-scans every turn text input for $name skill mentions and
[@name](plugin://...) links (codex-rs/skills/src/mentions.rs), so historical
$skill tokens inside OpenClaw's projected <conversation_context> block and
inbound quoted-reply/room-backlog context counted as current explicit
invocations and injected skill bodies the user never requested.

Neutralize mention sigils with same-length fullwidth lookalikes (the
escapeCodexChatText technique) in projected history and inbound context;
only the raw current request stays selectable.

Fixes openclaw#122812
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 14, 2026
…law#123363)

openclaw#123345 added extensions/codex/src/app-server/run-attempt-state.test.ts
without a lane owner; the full-suite ownership audit
(test/vitest-projects-config.test.ts) fails on main and every PR. Register
it beside its run-attempt siblings in the attempt-extra lane.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 14, 2026
…#123348)

* feat(docker): schedule image refreshes

* docs(docker): explain weekly image refreshes

* test(scripts): gate workflow-step execution on bash 4 mapfile support

Stock macOS bash 3.2 lacks mapfile; CI truth is Linux bash 5.

* test: cover docker-release suffix threading and sanctioned second caller

* test(codex): wire run-attempt-state into the attempt-extra project

openclaw#123345 added the file without a project owner; the full-suite coverage
guard fails for any PR that runs it.

* fix(ci): run build-artifacts PR validation on hosted runners

ci-build-artifacts-testbox.yml pinned PR runs to blacksmith-16vcpu and
ran Testbox lifecycle steps unconditionally, so the prepare-run landing
gate starved for every PR during a Blacksmith outage even with
OPENCLAW_CI_RUNNER_BACKEND=github. PR events now build on ubuntu-24.04
with dispatch-only Testbox steps, mirroring ci-check-testbox.yml.

* test(ci): align build-artifacts dispatch guard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: codex maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: $skill invocation is harness-dependent and projected history can trigger false explicit selection

1 participant