Skip to content

fix(agents): isolate network-backed dynamic tool results and errors - #118729

Merged
steipete merged 3 commits into
mainfrom
codex/qa0803-dynamic-tool-network-boundary
Aug 3, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/qa0803-dynamic-tool-network-boundary

Conversation

@steipete

@steipete steipete commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Prevent hostile network-backed dynamic-tool results and exceptions from escaping their external-content boundary through structured tool calls, legacy code mode, or suspended QuickJS exec/wait.
  • Preserve raw structured values, output schemas, trusted cancellation, provider-visible error classes/codes, and sibling-call isolation.

Canonical owner and dependency contract

The shared dynamic tool runtime previously erased network provenance before outer control results were projected into model-visible text. Its canonical invocation owner now tracks network observation through suspension/resume and wraps only model-facing content. Protected replacement errors preserve safe name/code/status while excluding hostile inherited causes, getters and Proxy traps; pre-execution policy failures and true aborts remain trusted.

Personally inspected the mandatory sibling Codex source: ../codex/codex-rs/protocol/src/dynamic_tools.rs:58-75, ../codex/codex-rs/app-server/src/dynamic_tools.rs:37-46, ../codex/codex-rs/core/src/tools/handlers/dynamic.rs:150-160, and ../codex/codex-rs/core/src/tools/context_tests.rs:235-268. The Codex wire carries only contentItems plus success, so protection belongs in OpenClaw's model-facing projection owner.

Actual production runtime proof: zero external network

Executed complete production Tool Search, embedded adapter, actual Codex app-server bridge, actual Copilot SDK bridge, and real QuickJS/WASI suspend/resume worker against a synthetic in-memory network-marked plugin. No external network, provider, credential, mocked runtime adapter, or real user content was used.

DIRECT_PRODUCTION_TOOL_CALL {"securityNotice":true,"externalBoundary":true,"specialTokenRemoved":true,"rawStructuredValuePreserved":true}
ACTUAL_PUBLIC_EMBEDDED_ADAPTER {"securityNotice":true,"externalBoundary":true,"specialTokenRemoved":true,"rawStructuredValuePreserved":true}
ACTUAL_CODEX_APP_SERVER_ADAPTER {"success":true,"contentItemType":"inputText","securityNotice":true,"externalBoundary":true,"specialTokenRemoved":true}
ACTUAL_COPILOT_SDK_ADAPTER {"resultType":"success","securityNotice":true,"externalBoundary":true,"specialTokenRemoved":true}
CODEX_PRODUCTION_ERROR_FORMATTER {"securityNotice":true,"externalBoundary":true,"specialTokenRemoved":true,"errorClassPreserved":true,"timeoutCodePreserved":true}
ACTUAL_QUICKJS_SUSPENDED_EXEC {"status":"waiting","externalBoundary":false}
ACTUAL_QUICKJS_RESUMED_WAIT {"status":"completed","securityNotice":true,"externalBoundary":true,"specialTokenRemoved":true,"rawStructuredValuePreserved":true}

Suspended exec correctly stays unwrapped before network observation; only resumed wait gains the boundary.

Verification

  • 263/263 focused tests passed, including 36 adversarial network-result, inherited-cause, throwing-getter and Proxy boundary cases.
  • Exact-head check-test-types SUCCESS; formatting and type-aware lint pass.
  • Independent structured Sol/high/P1 review clean, confidence 0.99, after direct independent upstream Codex-source inspection.
  • Production +185/-51 = +134 lines across five runtime owners; remaining lines are adversarial regressions.
  • The currently failing hosted compact shard is an independently reproduced pre-existing Windows background-launch timeout owner race, unrelated to this patch; a dedicated root-cause repair is being prepared.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: L maintainer Maintainer-authored PR labels Aug 3, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Aug 3, 2026
@clawsweeper

clawsweeper Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 3, 2026, 1:09 PM ET / 17:09 UTC.

ClawSweeper review

What this changes

The PR records network-backed dynamic-tool execution and wraps only model-visible results or errors across direct Tool Search calls, legacy Code Mode, and resumed Code Mode executions while preserving structured values and trusted cancellation.

Merge readiness

⚠️ Ready for maintainer review - 5 items remain

This remains necessary: current main still projects dynamic-tool results without recording whether a network-backed invocation occurred, while the PR adds that missing owner-boundary state and applies the external-content wrapper only at model-visible control projections. No discrete correctness defect was found in the proposed patch, but this security-sensitive PR cannot receive a merge-ready verdict here because the repository-required sibling ../codex source checkout is unavailable for direct protocol verification; required checks are also still running.

Priority: P1
Reviewed head: 69171241e2606b89d16c874d06dc7f87bffd29ad
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch has strong focused runtime proof and targeted hostile-content coverage; its remaining merge gate is direct Codex contract review plus exact-head CI, not a demonstrated patch defect.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The PR body provides after-fix production runtime output for direct, embedded, Codex bridge, Copilot bridge, and suspended/resumed QuickJS paths; it also states that no external network, credentials, or provider were used.
Patch quality 🐚 platinum hermit (4/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body provides after-fix production runtime output for direct, embedded, Codex bridge, Copilot bridge, and suspended/resumed QuickJS paths; it also states that no external network, credentials, or provider were used.
Evidence reviewed 7 items Current-main gap: The current shared invocation owner executes a catalog tool, snapshots its result, and returns it without retaining resultContentSource provenance for later model-visible control projections; this is the behavior the PR addresses.
Canonical boundary implementation: The PR tracks observed network calls per parent invocation, then wraps only jsonResult text at the control-result boundary and protects error messages without returning hostile inherited causes.
Affected model-facing callers: The branch passes the same runtime through Code Mode exec and wait, and changes legacy Tool Search controls to format result and error projections after dynamic execution.
Findings None None.
Security Needs attention Verify the absent Codex bridge contract: The patch's placement depends on what the Codex app-server bridge projects to model-visible content; repository policy requires inspecting sibling Codex source before clearing this security boundary.

How this fits together

Dynamic plugin tools run through the shared Tool Search runtime for agent calls and Code Mode bridges. Their structured results remain available to runtime consumers, while control results and errors are projected into text consumed by the model and need an explicit external-content boundary when network-derived content was observed.

flowchart LR
  A[Dynamic plugin tool] --> B[Shared Tool Search runtime]
  B --> C[Network provenance state]
  C --> D[Direct call or Code Mode result]
  D --> E[Model-visible control projection]
  E --> F[External-content boundary]
  F --> G[Agent model]
  B --> H[Structured runtime value]
Loading

Decision needed

Question Recommendation
Should a reviewer with access to the sibling Codex checkout confirm the dynamic-tool bridge contract and approve this model-content boundary change once the rebased head passes its required checks? Complete contract review and merge: Inspect the exact Codex dynamic-tool protocol and runtime projection path, rebase onto current main, then merge if the required checks remain green.

Why: The patch appears to use the right OpenClaw owner boundary, but repository policy expressly requires direct Codex source inspection before a verdict on Codex-related behavior, and this protected security-boundary PR still has incomplete current-head CI.

Before merge

  • Resolve security concern: Verify the absent Codex bridge contract - The patch's placement depends on what the Codex app-server bridge projects to model-visible content; repository policy requires inspecting sibling Codex source before clearing this security boundary.
  • Resolve merge risk (P1) - The sibling ../codex source checkout is missing, so this review cannot independently verify the app-server and dynamic-tool wire contract required by repository policy for this model-content security boundary.
  • Resolve merge risk (P1) - The PR is behind current main and its required checks remain in progress; merge only after the exact rebased head has completed the relevant security and agent-runtime gates.
  • Complete next step (P2) - A protected security-boundary label, an unavailable mandatory Codex-source contract check, and incomplete exact-head CI require human security review rather than an automated repair lane.

Findings

  • [medium] Verify the absent Codex bridge contract
Agent review details

Security

Needs attention: The patch contains a focused defensive boundary and no supply-chain change, but a required direct Codex protocol/runtime inspection is unavailable in this environment.

PR surface

Source +134, Tests +683. Total +817 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 5 185 51 +134
Tests 3 683 0 +683
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 868 51 +817

Review metrics

Metric Value Why it matters
Production versus regression LOC production +134, tests +683 The production growth spans five runtime owners to carry provenance through direct and suspended paths; the larger test delta targets hostile-result and error regressions.

Merge-risk options

Maintainer options:

  1. Verify the upstream bridge before merge (recommended)
    Inspect the sibling Codex protocol and handler source, then run the required checks on a rebased exact head to confirm the external boundary is applied at the final model-visible projection.
  2. Pause if the bridge owns projection
    Hold this PR and move the fix only if Codex source proves that its bridge, rather than OpenClaw's projection owner, is responsible for the exposed model-visible content.

Technical review

Best possible solution:

Keep provenance at the shared dynamic invocation owner, project the external-content boundary only when a network-backed call was actually observed, and obtain a direct Codex-source review plus current-head green validation before merge.

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

Yes — the added focused tests construct resultContentSource: "network" tools and exercise direct calls, legacy Code Mode, and suspend/resume paths; this read-only review did not execute them.

Is this the best way to solve the issue?

Unclear — the shared runtime is the strongest apparent owner because it observes the tool invocation before the control projections, but a direct sibling Codex-source check is still mandatory before calling this the best final boundary.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: The change protects agent-visible dynamic-tool output on active direct and Code Mode execution paths.
  • merge-risk: 🚨 security-boundary: Merging changes how network-derived tool output and errors cross into model-visible text.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (terminal): The PR body provides after-fix production runtime output for direct, embedded, Codex bridge, Copilot bridge, and suspended/resumed QuickJS paths; it also states that no external network, credentials, or provider were used.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides after-fix production runtime output for direct, embedded, Codex bridge, Copilot bridge, and suspended/resumed QuickJS paths; it also states that no external network, credentials, or provider were used.

Evidence

Security concerns:

  • [medium] Verify the absent Codex bridge contract
    The patch's placement depends on what the Codex app-server bridge projects to model-visible content; repository policy requires inspecting sibling Codex source before clearing this security boundary.
    Confidence: 0.99

What I checked:

  • Current-main gap: The current shared invocation owner executes a catalog tool, snapshots its result, and returns it without retaining resultContentSource provenance for later model-visible control projections; this is the behavior the PR addresses. (src/agents/tool-search-runtime.ts:607, 94f431417b25)
  • Canonical boundary implementation: The PR tracks observed network calls per parent invocation, then wraps only jsonResult text at the control-result boundary and protects error messages without returning hostile inherited causes. (src/agents/tool-search-runtime.ts:650, 69171241e260)
  • Affected model-facing callers: The branch passes the same runtime through Code Mode exec and wait, and changes legacy Tool Search controls to format result and error projections after dynamic execution. (src/agents/code-mode.ts:211, 69171241e260)
  • Focused sibling-path coverage: The branch adds regressions for direct and legacy code-mode calls, suspended wait/resume behavior, uncaught errors, structured-value preservation, and hostile text handling. (src/agents/code-mode.wait.test.ts:69, 69171241e260)
  • Feature provenance: The existing Tool Search invocation path appears to date to Peter Steinberger's current-main commit, making him the strongest routing candidate for this owner-boundary change. (src/agents/tool-search-runtime.ts:607, a9da10ea9ed6)
  • Current-main relationship: The PR base is an ancestor of current main; the branch is reported mergeable but behind, so it needs a current-head CI and merge refresh rather than closure as superseded. (94f431417b25)

Likely related people:

  • steipete: Peter Steinberger authored the current-main Tool Search invocation owner and the proposed repair, so the history points to the same area owner rather than a reporter-only association. (role: recent area contributor and canonical runtime owner; confidence: high; commits: a9da10ea9ed6, 8fd81a1c3e74; files: src/agents/tool-search-runtime.ts, src/agents/code-mode.ts, src/agents/tool-search.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Inspect the sibling Codex dynamic-tool protocol and handler source from an environment where ../codex is available.
  • Rebase onto current main and let the required current-head checks complete before merge.

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 (3 earlier review cycles)
  • reviewed 2026-08-03T15:34:34.376Z sha 8fd81a1 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-03T16:16:56.227Z sha 729bb3e :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-03T16:38:54.470Z sha 729bb3e :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 3, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. and removed 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 Aug 3, 2026
@clawsweeper clawsweeper Bot added 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. labels Aug 3, 2026
@steipete
steipete merged commit 8406cfe into main Aug 3, 2026
124 of 126 checks passed
@steipete
steipete deleted the codex/qa0803-dynamic-tool-network-boundary branch August 3, 2026 17:19
@steipete

steipete commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 4, 2026
…penclaw#118729)

* fix(agents): isolate network-backed dynamic tool results and failures

* test(agents): retain literal text result types in dynamic tool fixtures
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: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. 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: ⏳ 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.

1 participant