Skip to content

fix(agents): quarantine invalid runtime tool schemas - #88368

Merged
steipete merged 4 commits into
test-neutral-tool-schema-fixtures-refresh-20260531from
fuzz-tool-schema-runtime-20260530
May 31, 2026
Merged

steipete merged 4 commits into
test-neutral-tool-schema-fixtures-refresh-20260531from
fuzz-tool-schema-runtime-20260530

Conversation

@vincentkoc

@vincentkoc vincentkoc commented May 30, 2026 •

Copy link
Copy Markdown
Member

Summary

  • quarantine runtime tools whose input schemas cannot be projected before model session creation
  • apply the same quarantine path to embedded attempts, compaction, and doctor runtime checks
  • share runtime quarantine helpers so unreadable tool rows/descriptors do not crash the turn before content

Stack

Verification

  • node scripts/run-vitest.mjs src/agents/tool-schema-projection.test.ts src/agents/tool-schema-quarantine.test.ts src/agents/embedded-agent-runner/run/attempt.spawn-workspace.context-engine.test.ts src/agents/embedded-agent-runner/compact.hooks.test.ts src/flows/doctor-core-checks.runtime.test.ts --reporter=verbose
  • ./node_modules/.bin/oxfmt --check $(cat /tmp/runtime-quarantine-files-current.txt)
  • node scripts/run-oxlint.mjs $(cat /tmp/runtime-quarantine-files-current.txt)
  • git diff --check @{u}...HEAD
  • rg -n "dofbot|doftbot" $(cat /tmp/runtime-quarantine-files-current.txt) || true
  • .agents/skills/autoreview/scripts/autoreview --mode branch --base @{u}
  • node scripts/crabbox-wrapper.mjs run --provider aws --label runtime-quarantine-check-changed-rebased --shell -- "pnpm check:changed" (run_fd4a5a4583a2, AWS lease cbx_f87d69efa9b8, slug silver-prawn)

Real behavior proof

Behavior addressed: unsupported or unreadable active runtime tool schemas are quarantined before embedded attempt or compaction model projection, while doctor reports the active blocker instead of crashing.
Real environment tested: local Codex gwt worktree stacked on #88649 plus AWS Crabbox Linux c7a.8xlarge remote changed gate.
Exact steps or command run after this patch: targeted Vitest, oxfmt, oxlint, diff whitespace check, private-name scrub, autoreview, and AWS Crabbox pnpm check:changed listed above.
Evidence after fix: targeted tests passed 3 routed Vitest shards / 125 tests; formatting, lint, diff, scrub, and autoreview passed; AWS Crabbox run_fd4a5a4583a2 passed pnpm check:changed and cleaned up its lease.
Observed result after fix: bad runtime tool schemas are filtered/quarantined before provider/model projection, healthy tools remain available, and doctor can surface the offending active tool/plugin path.
What was not tested: no live Telegram turn in this slice; that belongs to a later end-to-end proof after the runtime and doctor PRs are landed/retargeted.

@vincentkoc vincentkoc self-assigned this May 30, 2026
@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime commands Command implementations agents Agent runtime and tooling extensions: codex size: XL maintainer Maintainer-authored PR labels May 30, 2026
@clawsweeper

clawsweeper Bot commented May 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed May 31, 2026, 12:48 PM ET / 16:48 UTC.

Summary
The branch adds runtime tool-schema quarantine helpers and applies them to embedded attempts, compaction, and doctor runtime checks with regression tests for unreadable schemas.

PR surface: Source +315, Tests +413. Total +728 across 12 files.

Reproducibility: yes. by source inspection: current main paths send active tools into provider/runtime projection before the new quarantine guard, and the PR tests model unreadable parameters getters that would throw. I did not run tests in this read-only review.

Review metrics: 1 noteworthy metric.

  • Stack prerequisite: 1 open base PR. The PR targets the fixture-cleanup branch, so main-merge proof depends on the base landing or a retargeted branch.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🦞 diamond lobster
Patch quality: 🧂 unranked krab
Result: blocked by patch quality or review findings.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Preserve readable quarantined names in bundled runtime reservations for attempt and compaction.
  • [P2] Add doctor coverage for unreadable bundled MCP rows/names before policy filtering.
  • Retarget after the stacked fixture PR lands and rerun focused proof.

Risk before merge

  • [P1] Quarantine-and-continue changes the existing fail-closed behavior for malformed active tool schemas; maintainers should explicitly accept that compatibility and security posture before merge.
  • [P1] Readable names from provider-normalizable quarantined tools are not reserved before bundled MCP/LSP materialization, so a different bundled tool can be exposed under a name that was blocked for the turn.
  • [P1] The branch is stacked on test(agents): use neutral tool schema fixtures #88649 and still needs that prerequisite landed or a retargeted branch plus refreshed proof.

Maintainer options:

  1. Reserve quarantined names before merge (recommended)
    Carry readable names from quarantined active tools into bundled MCP/LSP reservedToolNames in attempt and compaction, with collision regression tests.
  2. Confirm the default policy
    Maintainers can intentionally accept quarantine-and-continue as the default, but that decision should be visible because existing malformed-tool setups previously failed closed.
  3. Retarget after the fixture base
    Wait for test(agents): use neutral tool schema fixtures #88649 or retarget this branch to main before treating CI and proof as land-ready.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Preserve readable names from provider-normalizable quarantine diagnostics in bundled MCP/LSP reservedToolNames for embedded attempts and compaction, and add regression coverage for active-tool/bundled-tool name collisions.

Next step before merge

  • [P2] A narrow automated repair can preserve quarantined names and plug the doctor bundle gap, while compatibility policy and stacked-base landing still need human review.

Security
Needs attention: Needs attention because the quarantine path can allow bundled tool-name reuse after an active tool with that readable name is blocked; no separate supply-chain change was found.

Review findings

  • [P1] Reserve quarantined active tool names — src/agents/embedded-agent-runner/run/attempt.ts:1418-1424
  • [P1] Reserve quarantined names during compaction — src/agents/embedded-agent-runner/compact.ts:836-842
  • [P2] Guard doctor bundle tools before policy filtering — src/flows/doctor-core-checks.runtime.ts:627-630
Review details

Best possible solution:

Land a version that reserves readable quarantined names across attempt and compaction, reports bundled doctor blockers before policy can throw, and has explicit maintainer approval for the quarantine default.

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

Yes, by source inspection: current main paths send active tools into provider/runtime projection before the new quarantine guard, and the PR tests model unreadable parameters getters that would throw. I did not run tests in this read-only review.

Is this the best way to solve the issue?

No as submitted; the quarantine direction is plausible, but the implementation needs readable quarantined names reserved before bundled runtimes and doctor bundle handling before it is the narrow maintainable fix.

Full review comments:

  • [P1] Reserve quarantined active tool names — src/agents/embedded-agent-runner/run/attempt.ts:1418-1424
    This filters provider-unreadable active tools before building tools, but bundled MCP reservations later use only the surviving normalized tools. A malformed tool with a readable name can be quarantined and then a bundled tool with the same name can register for the same turn, changing fail-closed behavior into a different callable tool under the blocked name. Carry readable quarantined names into the reservation set before materializing bundled runtimes.
    Confidence: 0.88
  • [P1] Reserve quarantined names during compaction — src/agents/embedded-agent-runner/compact.ts:836-842
    The compaction path has the same gap: filterProviderNormalizableRuntimeTools removes readable-but-bad active tools before createBundleMcpToolRuntime and createBundleLspToolRuntime build their reserved-name lists. Preserve those quarantined readable names here too so compaction cannot expose a bundled replacement under a blocked active tool name.
    Confidence: 0.86
  • [P2] Guard doctor bundle tools before policy filtering — src/flows/doctor-core-checks.runtime.ts:627-630
    collectBundleMcpRuntimeToolSchemaFindings still sends params.bundleRuntime.tools through applyFinalEffectiveToolPolicy before the new provider-normalizable inspection. That policy pipeline reads tool.name, so an unreadable bundled row/name can still abort doctor instead of producing a core/doctor/runtime-tool-schemas finding.
    Confidence: 0.78

Overall correctness: patch is incorrect
Overall confidence: 0.88

AGENTS.md: found and applied where relevant.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 1af4c035e4bc.

Label changes

Label justifications:

  • P2: This is a normal-priority runtime hardening PR with limited blast radius but meaningful pre-merge correctness and policy blockers.
  • merge-risk: 🚨 compatibility: The PR can change malformed active tool schemas from fail-closed session creation to quarantine-and-continue behavior for existing setups.
  • merge-risk: 🚨 security-boundary: If a quarantined readable tool name is not reserved, a bundled MCP/LSP tool can be exposed under a name that was blocked for the turn.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦞 diamond lobster and patch quality is 🧂 unranked krab.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The author is a repository member and supplied targeted test plus AWS Crabbox changed-gate evidence, so the external-contributor real behavior proof gate does not apply.
Evidence reviewed

PR surface:

Source +315, Tests +413. Total +728 across 12 files.

View PR surface stats
Area Files Added Removed Net
Source 7 368 53 +315
Tests 5 416 3 +413
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 12 784 56 +728

Security concerns:

  • [medium] Blocked tool names can be reused — src/agents/embedded-agent-runner/run/attempt.ts:1454
    The new quarantine flow can remove an active tool before MCP/LSP reservation, allowing another bundled tool to appear under the same readable name in the same turn.
    Confidence: 0.86

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs src/agents/tool-schema-projection.test.ts src/agents/tool-schema-quarantine.test.ts src/agents/embedded-agent-runner/run/attempt.spawn-workspace.context-engine.test.ts src/agents/embedded-agent-runner/compact.hooks.test.ts src/flows/doctor-core-checks.runtime.test.ts --reporter=verbose.
  • [P1] ./node_modules/.bin/oxfmt --check src/agents/embedded-agent-runner/compact.ts src/agents/embedded-agent-runner/compact.hooks.test.ts src/agents/embedded-agent-runner/run/attempt.ts src/agents/embedded-agent-runner/run/attempt.spawn-workspace.context-engine.test.ts src/agents/tool-schema-projection.ts src/agents/tool-schema-quarantine.ts src/flows/doctor-core-checks.runtime.ts src/flows/doctor-core-checks.runtime.test.ts.
  • [P1] node scripts/run-oxlint.mjs src/agents/embedded-agent-runner/compact.ts src/agents/embedded-agent-runner/compact.hooks.test.ts src/agents/embedded-agent-runner/run/attempt.ts src/agents/embedded-agent-runner/run/attempt.spawn-workspace.context-engine.test.ts src/agents/tool-schema-projection.ts src/agents/tool-schema-quarantine.ts src/flows/doctor-core-checks.runtime.ts src/flows/doctor-core-checks.runtime.test.ts.
  • [P1] git diff --check @{u}...HEAD.

What I checked:

  • Protected maintainer-owned PR: The provided GitHub context shows authorAssociation MEMBER and the protected maintainer label, so this workflow must keep the PR open rather than cleanup-close it.
  • Attempt path filters before bundle reservation: At PR head, provider-non-normalizable active tools are filtered before tools is built; later bundled MCP reservations use only the surviving tools.map((tool) => tool.name), leaving readable quarantined names out of the reservation set. (src/agents/embedded-agent-runner/run/attempt.ts:1418, 2dae8979791f)
  • Compaction path has the same reservation gap: The compaction path filters active tools before provider normalization, then creates bundled MCP/LSP runtimes with reservations derived from normalized survivors only. (src/agents/embedded-agent-runner/compact.ts:836, 2dae8979791f)
  • Doctor bundled MCP still reaches policy before quarantine: The new doctor inspection happens after applyFinalEffectiveToolPolicy receives params.bundleRuntime.tools; that policy pipeline reads tool names, so unreadable bundled rows can still throw before a health finding is produced. (src/flows/doctor-core-checks.runtime.ts:627, 2dae8979791f)
  • Codex dependency contract inspected: Codex builds Responses API request tools by serializing prompt.tools, and ResponsesApiTool requires a concrete JSON-schema parameters value, so malformed schema projection is on the model-request boundary. (../codex/codex-rs/core/src/client.rs:745)
  • Stacked base evidence: The local PR commits exist against base commit c41dae8, and the PR body says it must be retargeted after test(agents): use neutral tool schema fixtures #88649 lands. (2dae8979791f)

Likely related people:

  • Vincent Koc: Blame and PR commits show recent ownership of the tool-schema quarantine helpers plus the embedded attempt and compaction changes under review. (role: recent area contributor; confidence: high; commits: b334e7ef29ba, ac357841a22c, 071a01bd46a0; files: src/agents/tool-schema-projection.ts, src/agents/tool-schema-quarantine.ts, src/agents/embedded-agent-runner/run/attempt.ts)
  • Peter Steinberger: Recent history shows the bundled runtime shadowing/reservation area in the embedded attempt runner was touched by the runtime-shadowing fix immediately before this PR stack. (role: adjacent owner; confidence: medium; commits: 4ef141d5255c; files: src/agents/embedded-agent-runner/run/attempt.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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 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.

@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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. labels May 30, 2026
@vincentkoc
vincentkoc force-pushed the fuzz-tool-schema-runtime-20260530 branch from 6c5bafa to e36867a Compare May 30, 2026 16:36
@openclaw-barnacle openclaw-barnacle Bot added size: L and removed app: web-ui App: web-ui gateway Gateway runtime commands Command implementations extensions: codex size: XL labels May 30, 2026
@vincentkoc
vincentkoc force-pushed the fuzz-tool-schema-runtime-20260530 branch from e36867a to 28e6a02 Compare May 30, 2026 17:33
@clawsweeper clawsweeper Bot added 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. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. and removed 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 May 30, 2026
@vincentkoc
vincentkoc force-pushed the fuzz-tool-schema-runtime-20260530 branch from 28e6a02 to 8851e71 Compare May 30, 2026 18:52
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels May 30, 2026
@vincentkoc
vincentkoc force-pushed the fuzz-tool-schema-runtime-20260530 branch from 51d36ab to e8ec779 Compare May 31, 2026 00:55
@vincentkoc vincentkoc changed the title fix(agents): harden runtime tool schema diagnostics fix(agents): quarantine invalid runtime tool schemas May 31, 2026
@vincentkoc
vincentkoc force-pushed the fuzz-tool-schema-runtime-20260530 branch from e8ec779 to de4cd13 Compare May 31, 2026 02:05
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 31, 2026
@vincentkoc
vincentkoc force-pushed the fuzz-tool-schema-runtime-20260530 branch 4 times, most recently from d5f3dda to ff09f56 Compare May 31, 2026 02:54
@vincentkoc
vincentkoc force-pushed the fuzz-tool-schema-runtime-20260530 branch from ff09f56 to ae817fa Compare May 31, 2026 05:49
@clawsweeper clawsweeper Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 31, 2026
@vincentkoc
vincentkoc force-pushed the fuzz-tool-schema-runtime-20260530 branch 2 times, most recently from 206d9a7 to 1e07df0 Compare May 31, 2026 07:22
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 31, 2026
@vincentkoc
vincentkoc force-pushed the fuzz-tool-schema-runtime-20260530 branch 2 times, most recently from 72bafda to c6fa290 Compare May 31, 2026 07:50
@steipete

Copy link
Copy Markdown
Contributor

Land-ready proof for 4be0a8aa8b7:

  • Fixed the review finding by preserving readable names from pre-normalization quarantined active tools and passing them into bundled MCP/LSP reservedToolNames in both normal attempts and compaction runs.
  • Added regression coverage for attempt and compaction reservation, plus quarantine helper coverage for readable vs unreadable diagnostic names.
  • Local proof:
    • node scripts/run-vitest.mjs src/agents/tool-schema-quarantine.test.ts src/agents/embedded-agent-runner/run/attempt.spawn-workspace.context-engine.test.ts src/agents/embedded-agent-runner/compact.hooks.test.ts --reporter=verbose passed, 126 tests.
    • ./node_modules/.bin/oxfmt --check src/agents/tool-schema-quarantine.ts src/agents/tool-schema-quarantine.test.ts src/agents/embedded-agent-runner/run/attempt.ts src/agents/embedded-agent-runner/run/attempt.spawn-workspace.context-engine.test.ts src/agents/embedded-agent-runner/compact.ts src/agents/embedded-agent-runner/compact.hooks.test.ts src/agents/embedded-agent-runner/compact.hooks.harness.ts passed.
    • node scripts/run-oxlint.mjs src/agents/tool-schema-quarantine.ts src/agents/tool-schema-quarantine.test.ts src/agents/embedded-agent-runner/run/attempt.ts src/agents/embedded-agent-runner/run/attempt.spawn-workspace.context-engine.test.ts src/agents/embedded-agent-runner/compact.ts src/agents/embedded-agent-runner/compact.hooks.test.ts src/agents/embedded-agent-runner/compact.hooks.harness.ts passed.
    • git diff --check passed.
    • .agents/skills/autoreview/scripts/autoreview --mode branch --base origin/test-neutral-tool-schema-fixtures-refresh-20260531 returned clean: no accepted/actionable findings.
  • GitHub checks for 4be0a8aa8b7 are green.

Known proof gap: no separate live provider run; this was validated with focused runtime regression tests and the PR CI matrix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR 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. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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.

2 participants