Skip to content

fix(codex): preserve configured MCP on native fallback - #134941

Merged
obviyus merged 2 commits into
openclaw:mainfrom
itsuzef:fix/configured-mcp-dynamic-surface
Sep 2, 2026
Merged

obviyus merged 2 commits into
openclaw:mainfrom
itsuzef:fix/configured-mcp-dynamic-surface

Conversation

@itsuzef

@itsuzef itsuzef commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Configured static MCP tools disappeared from Codex turns when OpenClaw disabled Codex's native tool surface. The native mcp_servers projection was absent, while the dynamic producer materialized configured MCP only for scheduled runs. Operators saw a healthy configured server, but the model saw no tool and no useful failure.

Root cause

The Codex attempt runtime had two independent decisions:

  • disable native MCP for a restricted or OpenClaw-node execution policy
  • give configured static MCP dynamic ownership only to scheduled runs

An ordinary native-off turn therefore had no owner for configured MCP.

Fix

  • Give configured MCP one explicit owner: native on normal turns, dynamic on scheduled or native-off turns.
  • Keep transient native-off ownership from rotating the persistent Codex thread binding.
  • Use one configured-MCP materializer for scheduled and interactive turns.
  • Preserve explicit prompt, per-tool projected approval, and durable OpenClaw grants.
  • Bind interactive approval to the exact server, tool, call ID, and live attempt before the original MCP executor runs once.
  • Exclude approval-requiring MCP App tools from persistent app views because that call boundary does not own the same approval roundtrip.
  • Reserve configured and requester-scoped MCP names against each other, then compose both lists once.
  • Share the host approval roundtrip with native Codex elicitation instead of keeping a second implementation.

Evidence

The same isolated production Gateway flow used openai/gpt-5.6-sol, forced the Codex harness, set tools.exec.host="node", configured one static MCP server, and requested one hidden fixture value through openclaw agent.

Revision Harness MCP calls Result
current main 04bad80b953d codex (forced_plugin) 0 fixture__lookup_note is unavailable.
candidate 48397e587cca (Sol) codex (forced_plugin) 1 exact hidden value returned
exact head c909e68d223 (Luna) codex (forced_plugin) 1 exact hidden value returned

The hidden value was generated after the builds, never appeared in the prompt, and remained private to the fixture. The exact-head dist/ was built on Testbox, downloaded by hash, and used unchanged for the final isolated Gateway replay. All Gateways and both Testbox leases were stopped after proof. Public Testbox runs: initial red/green, exact-head build.

Codex contract checked

Direct inspection of openai/codex@da23e131e68b171909407f469da1b2f72d9c4f4a confirmed:

Validation

  • Current-main regression: expected one static materialization, received zero.
  • Candidate focused and sibling tests: 201 passed; the CI import repair then passed 107 focused tests.
  • Production Gateway red/green: passed.
  • Clean Linux candidate and baseline builds: passed.
  • Formatting and Oxlint: passed.
  • Plugin SDK export and surface checks: passed.
  • Max-lines, assertion-safety, coercion, deprecated-API, temp-path, conflict-marker, and docs-list guards: passed.
  • Local type-check and build were not run because this host forbids them; CI owns those gates.

Diff audit

  • Production: +258/-129 (net +129).
  • Tests: +176/-19 (net +157).
  • Test support: +1/-1.
  • Docs: +3/-2.

The positive production delta creates the missing dynamic owner and closure-bound approval boundary. The change replaces the scheduled-only materializer and removes the duplicate 61-line approval implementation; it does not add a second MCP or fallback stack.

@clawsweeper

clawsweeper Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added extensions: codex size: S triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Sep 1, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 1, 2026
@clawsweeper

clawsweeper Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 2, 2026, 2:13 PM ET / 18:13 UTC.

ClawSweeper review

What this changes

The PR makes configured static MCP tools available through OpenClaw’s dynamic Codex tool surface when native Codex tools are disabled, while preserving policy, approvals, name uniqueness, and cleanup.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

✅ Ready for maintainer review

Keep open. The proposed native-off dynamic owner fixes a current-main MCP disappearance, preserves per-tool approval and cleanup, and has supplied exact-head Gateway red/green proof; no introduced blocking defect was found.

Priority: P1
Reviewed head: c909e68d22379ea924f960a0ac92303a67f8e6ae

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Strong real Gateway proof and focused boundary coverage support a correct compatibility-sensitive repair.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The changed production owner is the Codex dynamic MCP materializer; the PR supplies an isolated real Gateway baseline and exact-head replay through the forced Codex harness, showing the formerly absent configured MCP call now executes and returns the hidden fixture value.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The changed production owner is the Codex dynamic MCP materializer; the PR supplies an isolated real Gateway baseline and exact-head replay through the forced Codex harness, showing the formerly absent configured MCP call now executes and returns the hidden fixture value.
Evidence reviewed 7 items Current-main behavior: Current main only materializes configured static MCP for authenticated scheduled runs, leaving an ordinary native-off turn without this dynamic owner.
Introduced ownership boundary: The PR selects a transient configured-MCP dynamic surface exactly when static servers exist and the native tool surface is disabled.
Approval and closure enforcement: Dynamic MCP execution awaits approval before the original executor, while the host revalidates active authority after Gateway request and wait operations.
Findings None None.
Security None None.

How this fits together

The Codex plugin assembles each agent turn’s tool surface from configured MCP servers and policy. It passes either native MCP configuration or OpenClaw-managed dynamic tools to Codex, which then invokes the selected tool during the turn.

flowchart LR
A[Configured MCP servers] --> B[Codex turn policy]
B --> C{Native tool surface enabled?}
C -->|Yes| D[Native Codex MCP]
C -->|No| E[OpenClaw dynamic MCP]
D --> F[Tool call]
E --> F
F --> G[Agent response]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +129, Tests +157, Docs +1. Total +287 across 15 files.

View PR surface stats
Area Files Added Removed Net
Source 10 256 127 +129
Tests 4 177 20 +157
Docs 1 3 2 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 15 436 149 +287

Review metrics

Metric Value Why it matters
Production and test delta production +258/-129; tests +176/-19; test support +1/-1 The production growth establishes the missing dynamic owner and approval boundary, while focused regressions cover execution, policy, collisions, and cleanup.

Technical review

Best possible solution:

Retain one configured-MCP owner per turn: native MCP on ordinary native-enabled turns and the policy-filtered OpenClaw dynamic surface on scheduled or native-off turns.

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

Yes. The supplied isolated Gateway red/green run reproduces current-main zero MCP calls under native-off policy and records one exact-head call returning the hidden value.

Is this the best way to solve the issue?

Yes. The patch gives configured MCP a single policy-filtered owner on each turn instead of restoring native MCP or adding a fallback path.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: Configured MCP tools can disappear from active Codex turns when policy disables the native tool surface.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The changed production owner is the Codex dynamic MCP materializer; the PR supplies an isolated real Gateway baseline and exact-head replay through the forced Codex harness, showing the formerly absent configured MCP call now executes and returns the hidden fixture value.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed production owner is the Codex dynamic MCP materializer; the PR supplies an isolated real Gateway baseline and exact-head replay through the forced Codex harness, showing the formerly absent configured MCP call now executes and returns the hidden fixture value.

Evidence

What I checked:

  • Current-main behavior: Current main only materializes configured static MCP for authenticated scheduled runs, leaving an ordinary native-off turn without this dynamic owner. (extensions/codex/src/app-server/run-attempt-runtime.ts:187, 1212f991db46)
  • Introduced ownership boundary: The PR selects a transient configured-MCP dynamic surface exactly when static servers exist and the native tool surface is disabled. (extensions/codex/src/app-server/run-attempt-runtime.ts:227, c909e68d2237)
  • Approval and closure enforcement: Dynamic MCP execution awaits approval before the original executor, while the host revalidates active authority after Gateway request and wait operations. (src/agents/agent-bundle-mcp-harness.ts:120, c909e68d2237)
  • Regression coverage: Focused tests cover denial before the original MCP call, one allowed execution, approval modes and grants, dynamic name collision handling, and disposal. (src/agents/agent-bundle-mcp-harness.test.ts:244, c909e68d2237)
  • Supplied production proof: The PR body records an isolated real Gateway baseline with zero MCP calls and exact-head replay with one call and the hidden fixture value returned; it links both Testbox Actions runs. (c909e68d2237)
  • Direct Codex contract inspection: The available sibling Codex source shows native MCP registration precedes dynamic tools and duplicate external names retain the first owner, supporting native/dynamic exclusivity and the reserved-name approach. Local checkout ownership could not be independently verified because its remote is an OpenClaw cache. (codex-rs/core/src/tools/registry.rs:371, 5adb68a49933ae446bf11935662c83dba55a0804)

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Josh Avant: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Ayaan Zaidi: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (13 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-01T18:35:08.996Z sha 1e18ec5e996d6a60f373c9efc452e34b852dd0b7 :: needs real behavior proof before merge. :: [P1] Preserve an approvable path for configured MCP tools
  • reviewed 2026-09-01T19:16:40.268Z sha 1e18ec5e996d6a60f373c9efc452e34b852dd0b7 :: needs real behavior proof before merge. :: [P1] Implement approval-and-resume instead of permanently rejecting tools | [P1] Do not filter newly owned static tools through a native-only catalog | [P2] Use attempt-neutral wording for materializer diagnostics
  • reviewed 2026-09-01T23:09:14.566Z sha 3633d5b488a84d7802087ab5a5c096c15cf18b81 :: needs real behavior proof before merge. :: [P1] Include owned MCP specs with restored supervised catalogs | [P1] Pass the materialized plugin owner into interactive approval
  • reviewed 2026-09-01T23:26:13.578Z sha 036b29a73e5a259d59608662833a12d1922bd945 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-02T04:18:33.596Z sha 036b29a73e5a259d59608662833a12d1922bd945 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-02T15:44:00.092Z sha 48397e5 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-02T15:52:51.288Z sha 48397e5 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-02T16:43:42.421Z sha c909e68 :: needs maintainer review before merge. :: none

@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. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 1, 2026
@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Sep 1, 2026
@itsuzef

itsuzef commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Sep 1, 2026
@itsuzef
itsuzef force-pushed the fix/configured-mcp-dynamic-surface branch from 80dfa6a to 2cb0916 Compare September 1, 2026 17:20
@itsuzef

itsuzef commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Sep 1, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. labels Sep 1, 2026
@itsuzef

itsuzef commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 2, 2026
@obviyus obviyus self-assigned this Sep 2, 2026
Co-authored-by: Youssef Hemimy <53057646+itsuzef@users.noreply.github.com>
@obviyus
obviyus force-pushed the fix/configured-mcp-dynamic-surface branch from 036b29a to 48397e5 Compare September 2, 2026 15:35
@obviyus obviyus changed the title fix(codex): deliver configured static MCP on dynamic-surface attempts fix(codex): preserve configured MCP on native fallback Sep 2, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Sep 2, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Sep 2, 2026
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Sep 2, 2026
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Sep 2, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Sep 2, 2026
@obviyus
obviyus merged commit 1e37a56 into openclaw:main Sep 2, 2026
762 of 773 checks passed
@obviyus

obviyus commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

Thanks @itsuzef!

Proof: An isolated production Gateway selected the Codex harness with tools.exec.host="node". Current main exposed no configured MCP tool and made zero fixture calls. The merged head exposed the configured tool once, made one call, and returned the exact hidden fixture value. Exact-head build, type-check, focused tests, Autoreview, and CI passed.

  • Bug: Configured static MCP tools disappeared when a Codex turn disabled the native MCP surface.
  • Fix: The Codex attempt producer now assigns configured MCP to exactly one native or dynamic owner, preserves approval and persistent-binding rules, and reserves names across static and requester-scoped MCP.
Before After
fixture__lookup_note is unavailable.; 0 MCP calls Hidden value returned; 1 MCP call

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 P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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.

3 participants