Skip to content

fix(agent): keep computer-use tools under a subagent whitelist and log misses - #10463

Open
he-yufeng wants to merge 3 commits into
AstrBotDevs:masterfrom
he-yufeng:fix/subagent-toolset-builtin-tools
Open

he-yufeng wants to merge 3 commits into
AstrBotDevs:masterfrom
he-yufeng:fix/subagent-toolset-builtin-tools

Conversation

@he-yufeng

@he-yufeng he-yufeng commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Fixes #10456.

With a persona tool whitelist on a subagent, builtin execution tools disappear, and an unresolvable or empty selection can leave the subagent running toolless without a useful warning.

The main agent applies runtime computer-use tools after persona whitelist narrowing. The subagent handoff instead built its selected ToolSet only from the whitelist. The Dashboard checkbox UI lists plugin tool names, so builtin tool names need not appear in that whitelist.

Current master #11335 also moved runtime tools out of the shared builtin registry and into the active run context. This update preserves that architecture rather than restoring the removed registry.

Changes

astrbot/core/astr_agent_runtime/tool_executor.py:

  • Seed the whitelist-built toolset with the runtime computer-use tools, including an empty whitelist, matching the main agent's capability order.
  • Resolve explicitly selected tools from run_context.tools first, preserving the executable parent-run instances introduced by fix: resolve executable builtin tools for delegated sessions #11335. The existing plugin manager remains the fallback for callers without a run-scoped toolset.
  • Include the Shipyard Neo browser tools under the same session capability gate as the main agent: present before the first boot or when the booted profile lists browser, absent otherwise.
  • Warn about unknown or inactive plugin selections and about an empty final toolset.
  • Keep direct runtime tool construction from fix: resolve executable builtin tools for delegated sessions #11335. No builtin registry or removed runtime-tool activation API is reintroduced.

astrbot/core/utils/media_utils.py:

  • Preserve remote file URI authorities on POSIX instead of passing them through the Windows-oriented url2pathname conversion. Windows UNC handling is unchanged.

Tests

On merged head 167a617c24fb486b8af1eb4de0262e405ccb5735, with current master 841295fa938d2cd028b9e0cb832f293c5c5c0d4b as the second parent:

  • Seven selected whitelist, empty-selection, and browser-gate regressions fail against the unmodified current-master tool_executor.py and pass with this change.
  • tests/unit/test_astr_agent_tool_exec.py: 62 passed.
  • That file plus tests/unit/subagent and tests/unit/test_astr_main_agent.py: 309 passed.
  • Full tests/unit: 2397 passed with one failure in test_wakeup_pipeline.py::test_wakeup_output_policy_preserves_explicit_sends_and_history[plugin]. Unmodified current master reports the same failure with 2389 passes, and the case passes in isolation on both trees. No unrelated failure is hidden or rewritten.
  • Ruff check passes on all three touched files. Ruff format check passes on both production files, and the PR-scoped git diff --check passes. Unrelated pre-existing formatting elsewhere in the test file is left untouched.

No real WebUI persona save, external sandbox, model request, or live subagent task was run.

To verify

  • pytest tests/unit/test_astr_agent_tool_exec.py
  • pytest tests/unit/subagent tests/unit/test_astr_main_agent.py
  • pytest tests/unit with the same pre-existing wakeup failure also reproduced on current master
  • WebUI persona whitelist save plus a subagent task on an install with computer-use runtime enabled

Summary by Sourcery

Preserve runtime computer-use tools and improve diagnostics when building subagent handoff toolsets.

Bug Fixes:

  • Keep runtime computer-use capabilities available to subagents when persona whitelists are applied, including empty selections.
  • Resolve whitelisted tools from the active run context and warn when selections are unknown, inactive, or produce no tools.
  • Align Shipyard Neo browser-tool availability with the main agent's sandbox capability gating.
  • Preserve remote file URI authorities on POSIX systems while retaining existing Windows UNC handling.

Tests:

  • Add regression coverage for whitelisted, empty, invalid, inactive, and browser-gated subagent tool selections, plus POSIX remote file URI conversion.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 4 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="astrbot/core/astr_agent_tool_exec.py" line_range="303" />
<code_context>
+        # plugin tools, so builtin tool names never appear in `tools`).
         toolset = ToolSet()
+        for runtime_tool in runtime_computer_tools.values():
+            toolset.add_tool(runtime_tool)
+        unknown_names: list[str] = []
+        inactive_names: list[str] = []
</code_context>
<issue_to_address>
**Whitelist grants extra capabilities**

When computer-use runtime is enabled and a subagent has a non-empty whitelist that intentionally omits runtime tools, the whitelist-built handoff toolset receives every runtime computer-use tool before checking the selected names, so a user who triggers a subagent configured with only a benign plugin can still have it use runtime capabilities such as sandbox file access; the configured whitelist no longer limits those tools.

Keep runtime tools available only when explicitly permitted by the subagent policy, or introduce a separate setting that clearly opts a subagent into them.
</issue_to_address>

### Comment 2
<location path="astrbot/core/astr_agent_tool_exec.py" line_range="302-303" />
<code_context>
+        # even when the whitelist cannot name them (the dashboard only lists
+        # plugin tools, so builtin tool names never appear in `tools`).
         toolset = ToolSet()
+        for runtime_tool in runtime_computer_tools.values():
+            toolset.add_tool(runtime_tool)
+        unknown_names: list[str] = []
+        inactive_names: list[str] = []
</code_context>
<issue_to_address>
**Disabled builtin tools stay callable**

When a runtime computer-use builtin is deactivated and a subagent has a non-empty whitelist, `_build_handoff_toolset` adds each runtime tool without checking `active`; the full-schema path advertises it and the runner can execute it. A deactivated builtin therefore remains available to the subagent despite the whitelist path’s inactive-tool handling.

Only seed active runtime tools into the whitelist toolset.
</issue_to_address>

### Comment 3
<location path="astrbot/core/astr_agent_tool_exec.py" line_range="294" />
<code_context>
         if not tools:
             return None

</code_context>
<issue_to_address>
**Empty whitelist skips tool setup**

When the subagent whitelist is empty, `_build_handoff_toolset` returns at `if not tools` before seeding runtime tools or reaching the empty-toolset warning, so the caller gets no tools and the missing capabilities are not logged.

Let an empty whitelist continue through toolset construction so runtime tools are seeded and an empty result reaches the warning.

Also at `astrbot/core/astr_agent_tool_exec.py:297-303`, `astrbot/core/astr_agent_tool_exec.py:332-336`.
</issue_to_address>

### Comment 4
<location path="astrbot/core/astr_agent_tool_exec.py" line_range="302-303" />
<code_context>
+        # even when the whitelist cannot name them (the dashboard only lists
+        # plugin tools, so builtin tool names never appear in `tools`).
         toolset = ToolSet()
+        for runtime_tool in runtime_computer_tools.values():
+            toolset.add_tool(runtime_tool)
+        unknown_names: list[str] = []
+        inactive_names: list[str] = []
</code_context>
<issue_to_address>
**Whitelisted subagents still lose browser tools**

When a subagent uses a non-empty persona whitelist and its sandbox runtime supports browser tools, `_get_runtime_computer_tools` omits the sandbox browser tools, so this seed loop never adds them to a whitelisted subagent. Browser tasks then have no browser tools to call, even when the sandbox supports them.

Include the browser tools in the subagent runtime tool set when the sandbox supports them, matching the main agent's capability check.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 4 findings to address first, and this changes the subagent permission boundary by making configured computer-use tools available even when the persona whitelist omits them, potentially enabling shell or code execution that the whitelist was intended to prevent. Reverting stops future access but cannot undo commands, data exposure, or other side effects that occurred while the broader toolset was active.

Blocking findings: astrbot/core/astr_agent_tool_exec.py:303, astrbot/core/astr_agent_tool_exec.py:303, astrbot/core/astr_agent_tool_exec.py:294, astrbot/core/astr_agent_tool_exec.py:303


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread astrbot/core/astr_agent_tool_exec.py Resolved
Comment thread astrbot/core/astr_agent_tool_exec.py Resolved
Comment thread astrbot/core/astr_agent_tool_exec.py Resolved
Comment thread astrbot/core/astr_agent_tool_exec.py Resolved
…g misses

A persona tool whitelist on a subagent silently stripped the builtin
execution tools. The main agent applies the runtime computer-use tools
after the persona whitelist narrowing and never routes them through the
whitelist, so a whitelist only narrows plugin/MCP tools there. The
subagent handoff built its toolset from the whitelist alone, and since
the dashboard checkbox UI only lists plugin tools, builtin names never
appear in the list and the subagent lost shell, python and file access
entirely.

Seed the whitelist-built toolset with the runtime computer-use tools so
both paths agree. The seed now covers the shipyard_neo browser tools
under the same capabilities gate the main agent uses, skips and logs
runtime tools that were deactivated, and an empty whitelist now flows
through the same construction instead of returning early, so it keeps
the runtime tools and an empty result still reaches the warning.
Unknown and inactive whitelist entries keep their warnings too.

Signed-off-by: Yufeng He <40085740+he-yufeng@users.noreply.github.com>
@ngc7331

ngc7331 commented Oct 20, 2026

Copy link
Copy Markdown

Hi, I've recently encountered issue #10456 as well. I then found this PR and built a test docker image base on this. I can confirm the issue is resolved.

I installed living memory plugin which provides recall_long_term_memory tool. The experiment group excludes this tool using whitelist and the control group can use all tools.

With latest v4.29.1 release, the control group reports that it can see all 8 tools (7 built-in + 1 living memory), and the experiment group does not answer the main agent's query but gives this instead:

[23:18:01.652] [Core] [INFO] [runners.tool_loop_agent_runner:1438]: Tool `transfer_to_test` Result: <tool_use>
<tool_name>web_search_tavily</tool_name>
<parameters>
<query>AstrBot issue 10456 tool whitelist regression</query>
</parameters>
</tool_use>

Seems like the web_search_tavily tool is not found so the original tool-call schema is returned.

With this PR, the control group still sees all 8 tools, and the experiment group reports that is can see 7 tools, as expected.

Can we push this forward?

@he-yufeng

Copy link
Copy Markdown
Contributor Author

Thanks for building the image and running the experiment/control split — that is exactly the confirmation this needed, and the two groups showing the whitelist takes effect on v4.29.1 closes the loop on the fix.

On the web_search_tavily echo: when the subagent's whitelist hides the tool the runner has nothing to execute, so it surfaces the original tool_use block back to the caller, which looks like a missing tool rather than a denied one. That naming is a separate contract question from the whitelist itself (a denial message versus an unfound tool), and it is pre-existing on main. Happy to take it as a follow-up that reports an excluded tool explicitly instead of echoing the call, if the maintainers want that distinction here.

…set-builtin-tools

# Conflicts:
#	astrbot/core/astr_agent_runtime/tool_executor.py
#	tests/unit/test_astr_agent_tool_exec.py
@he-yufeng

Copy link
Copy Markdown
Contributor Author

Merged current master in e880f7786 and restated the whitelist fix against the new astr_agent_runtime.tool_executor layout, including its browser-capability import path.

Verification on the merged head with a clean local Python 3.14.2 environment: tests/unit/test_astr_agent_tool_exec.py passes 54/54, and the tool-runner plus wakeup neighborhood passes 110/110. Ruff check and format pass. One pre-existing POSIX remote-file URI failure surfaced by the merged test is fixed and explicitly asserted in the same file.

Could a maintainer take another look at the current head? The earlier external whitelist experiment confirms the intended behavior.

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 97.05882% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
astrbot/core/utils/media_utils.py 66.66% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@he-yufeng

Copy link
Copy Markdown
Contributor Author

@Soulter @RC-CHN Could you review e880f778?

Computer-use tools should remain inside the subagent whitelist even when they are available to the main agent, and a rejected lookup should leave a useful miss log rather than silently exposing or dropping the tool.

@RC-CHN, you have recent changes in the same runtime executor. Could you check the whitelist and logging boundary for both foreground and background execution?

@he-yufeng

Copy link
Copy Markdown
Contributor Author

@Soulter @RC-CHN Current master #11335 is merged in 167a617c24fb486b8af1eb4de0262e405ccb5735, and all 7 hosted checks pass.

The whitelist fix now resolves explicit selections through run_context.tools and keeps direct runtime construction, so it does not restore the removed builtin registry. An empty whitelist retains computer-use tools, and Shipyard Neo browser tools follow the session capability gate.

Could you review that ownership boundary and the warning behavior? Seven selected regressions fail on unmodified current master. The tool executor, subagent, and main-agent suites pass 309 tests on this head. Full unit has 2397 passes and the same pre-existing wakeup failure as unmodified master. No live sandbox or WebUI run is claimed.

@sourcery-ai

sourcery-ai Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Linked issues

Checked at commit 167a617

#10456 [Bug] 工具白名单会一并关掉框架内置工具,且界面上无法选择内置工具 · 2 of 2 met

# Requirement Status Notes
1 Keep system tools independent of the plugin-tool whitelist. ✅ Met Whitelist handoffs are seeded with the runtime computer-use tools, including when the whitelist is empty.
2 Warn when the toolset is empty or selected tools are missing or inactive, listing the unmatched tool names. ✅ Met Unknown and inactive selections are logged with their names, and an empty final toolset gets a warning.

This branch has not been deployed

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

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

[Bug] 工具白名单会一并关掉框架内置工具,且界面上无法选择内置工具

3 participants