Skip to content

fix: forward toolsAllow through embedded runner call chain - #66710

Closed
KeWang0622 wants to merge 1 commit into
openclaw:mainfrom
KeWang0622:fix/embedded-runner-tools-allow
Closed

KeWang0622 wants to merge 1 commit into
openclaw:mainfrom
KeWang0622:fix/embedded-runner-tools-allow

Conversation

@KeWang0622

Copy link
Copy Markdown
Contributor

Summary

  • runEmbeddedPiAgent accepts a toolsAllow parameter but never forwarded it to runEmbeddedAttemptWithBackend, causing sub-agents to receive the full ~37k-token tool list instead of a filtered ~3k-token subset
  • Added the missing toolsAllow: params.toolsAllow to the params object in run.ts line 663
  • The attempt layer (attempt.ts) already handles toolsAllow correctly for both tool filtering (lines 542-544) and prompt mode optimization (lines 708-710) -- it just never received the value

The bug

When a caller sets toolsAllow: ["exec", "read"] on runEmbeddedPiAgent, the orchestration layer (run.ts) builds a ~90-field params object for runEmbeddedAttemptWithBackend but omits toolsAllow. The attempt layer has the filtering logic but always sees undefined, so every sub-agent gets ALL tools. This causes 10x token bloat and 30s timeouts on constrained runs.

Fix

One line: toolsAllow: params.toolsAllow, added to the params object at the call site.

Test plan

  • New test: toolsAllow is forwarded when set (non-empty array)
  • New test: toolsAllow remains undefined when not set (backward compat)
  • New test: empty toolsAllow array is forwarded without coercion
  • Existing overflow compaction tests pass (13/13)
  • Existing attempt tests pass (95/95)
  • Pre-commit hooks pass (type check, lint, import cycles, conflict markers)

Fixes #66581
Complementary to #60842 (config-level allowlist operates at a different layer)

🤖 Generated with Claude Code

…WithBackend

runEmbeddedPiAgent accepted a toolsAllow parameter but never included it
in the params object passed to runEmbeddedAttemptWithBackend. This caused
sub-agents to receive the full 37k-token tool list instead of a filtered
3k-token subset, leading to 10x token bloat and 30s timeouts.

The attempt layer (attempt.ts) already handles toolsAllow correctly for
both tool filtering and prompt mode optimization -- it just never received
the value from the orchestration layer.

Fixes openclaw#66581

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Apr 14, 2026
@greptile-apps

greptile-apps Bot commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Fixes a missing toolsAllow forwarding from runEmbeddedPiAgent down to runEmbeddedAttemptWithBackend (and ultimately runEmbeddedAttempt). The attempt layer already handled toolsAllow correctly for tool filtering (line 542) and prompt-mode optimization (line 709) — it just never received the value.

Confidence Score: 5/5

  • Safe to merge — targeted one-line fix with well-scoped tests and no side effects on existing behavior.
  • The change is a single-line omission fix. The call site is the only place runEmbeddedAttemptWithBackend is invoked in run.ts, so nothing is missed. The three new tests exercise set, unset, and empty-array semantics correctly. All remaining findings are P2 or lower.
  • No files require special attention.

Reviews (1): Last reviewed commit: "fix: forward toolsAllow from runEmbedded..." | Re-trigger Greptile

@steipete

Copy link
Copy Markdown
Contributor

Closing this as implemented after Codex review.

Current main already forwards toolsAllow through the embedded runner call chain, and the latest shipped release v2026.4.23 already contains that forwarding.

What I checked:

  • Current main forwards toolsAllow from runEmbeddedPiAgent: The embedded runner now passes toolsAllow: params.toolsAllow into runEmbeddedAttemptWithBackend, matching the PR's proposed fix. (src/agents/pi-embedded-runner/run.ts:930, cc0f3e0e4036)
  • Attempt layer still treats toolsAllow as authoritative: applyEmbeddedAttemptToolsAllow filters tools by the allow-list, prompt mode switches to minimal when toolsAllow is set, and the prompt payload includes toolsAllow, so the downstream behavior described in the PR is already wired up on current main. (src/agents/pi-embedded-runner/run/attempt.ts:461, cc0f3e0e4036)
  • Latest release already shipped the forwarding line: The v2026.4.23 release commit already contains toolsAllow: params.toolsAllow in the same call site, so this is not only fixed on unreleased main. (src/agents/pi-embedded-runner/run.ts:783, a9797214338b)

So I’m closing this as already implemented rather than keeping a duplicate issue open.

Review notes: reviewed against cc0f3e0e4036; fix evidence: release v2026.4.23, commit a9797214338b.

@steipete steipete closed this Apr 25, 2026
kiranvk-2011 added a commit to kiranvk-2011/openclaw that referenced this pull request Apr 27, 2026
When active-memory plugin invokes sub-agents with toolsAllow, the tools
get filtered to [] in the embedded runner context. Strict OpenAI-compatible
providers (DashScope/GLM, Kimi, vLLM) reject tools: [] with HTTP 400.

Adds wrapStreamFnStripEmptyTools() as a payload interceptor that:
- Strips tools entirely when array is empty
- Strips tool_choice when tools is absent

Consolidates openclaw#59898, openclaw#66710, openclaw#47947 into a single guard.
Fixes openclaw#53174.
kiranvk-2011 added a commit to kiranvk-2011/openclaw that referenced this pull request May 4, 2026
When active-memory plugin invokes sub-agents with toolsAllow, the tools
get filtered to [] in the embedded runner context. Strict OpenAI-compatible
providers (DashScope/GLM, Kimi, vLLM) reject tools: [] with HTTP 400.

Adds wrapStreamFnStripEmptyTools() as a payload interceptor that:
- Strips tools entirely when array is empty
- Strips tool_choice when tools is absent

Consolidates openclaw#59898, openclaw#66710, openclaw#47947 into a single guard.
Fixes openclaw#53174.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

toolsAllow parameter not forwarded to runEmbeddedAttemptWithBackend

3 participants