Skip to content

Fix subagent tool name normalization(#130)#131

Merged
frostming merged 2 commits intobubbuild:mainfrom
Andy963:fix/subagent-tool-name-normalization
Mar 22, 2026
Merged

Fix subagent tool name normalization(#130)#131
frostming merged 2 commits intobubbuild:mainfrom
Andy963:fix/subagent-tool-name-normalization

Conversation

@Andy963
Copy link
Contributor

@Andy963 Andy963 commented Mar 21, 2026

Fixes #130

Summary

This PR fixes tool-name handling for subagent.allowed_tools.

Previously, run_subagent() forwarded allowed_tools as raw strings. That meant
model-facing aliases such as schedule_list were not normalized back to runtime
registry names such as schedule.list, which could later surface as a confusing
runtime error like:

invalid_input: tools are required for this operation.

Root Cause

subagent was doing raw set filtering:

set(param.allowed_tools) - {"subagent"}

But Bub exposes tool names to models using underscore aliases, while the runtime
registry keeps dotted names. As a result:

  • model-facing aliases were not accepted
  • surrounding whitespace was not normalized
  • exclude did not go through the same canonical resolution path
  • unknown tool names were silently ignored instead of failing early

Changes

  • add shared tool-name normalization in src/bub/tools.py
  • accept both runtime names and model-facing aliases
  • normalize input with strip()
  • route exclude through the same canonical normalization path
  • fail fast on unknown tool names with an explicit ValueError
  • keep the default fallback behavior for allowed_tools=None / []
  • update run_subagent() to use the shared resolver before dispatch

Tests

Added/updated regression coverage for:

  • runtime names and model-facing aliases
  • whitespace normalization
  • exclude using the same canonical path
  • explicit rejection of unknown tool names
  • subagent fallback to all non-subagent tools
  • subagent alias resolution before agent.run(...)

Verification

uv run pytest -q tests/test_tools.py tests/test_subagent_tool.py

@frostming
Copy link
Collaborator

Please fix the lint error

@frostming frostming merged commit 3b4e4b4 into bubbuild:main Mar 22, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

subagent.allowed_tools does not normalize model-facing tool names and can fail with "tools are required for this operation"

2 participants