Skip to content

Remove Claude Code's subagent tools when bb disables them - #6475

Merged
ymichael merged 2 commits into
mainfrom
bb/3959-standalone
Oct 28, 2026
Merged

ymichael merged 2 commits into
mainfrom
bb/3959-standalone

Conversation

@ymichael

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Issue #3959 remains reproducible in main's provider boundary: disabling subagents only registers a PreToolUse deny hook, so no disallowedTools reaches Claude. The supplied commit removes Agent/Task but leaves ListAgents visible. A real Claude Code 2.1.312 process against a local mock Messages API confirmed ListAgents remains with only Agent/Task disallowed.

What changed

Disabled sessions pass Agent, Task, and ListAgents as disallowedTools, removing their tool definitions and embedded agent catalog from the model's offered tools. Retained the hook as a backstop, including ListAgents, for settings changed through steering during an active turn. Unchanged settings keep the process; changed settings restart it before the next new turn and resume the same provider session ID. The default remains false. The setting description, provider overview, skill and configuration reference document this behavior. Workflow behavior is unchanged and is not claimed fixed.

Why toggling restarts Claude (visible change):

SDK 0.3.245 exposes disallowedTools only as a query construction option. Its live applyFlagSettings({permissions: {deny: [Agent, Task, ListAgents]}}) call succeeds but leaves the tools in the next model request. Captured actual HTTP requests for enabled → disabled → enabled in a single process. Tested both installed Claude Code 2.1.312 and the SDK's bundled CLI: live deny settings do not change the offered tool definitions; launch-time disallowedTools does. No supported live tool-list replacement API exists in the installed Query contract. setMcpServers changes MCP tools, not built-in tools.

The process restart may add latency and clears process-local/background work, but resumes the persisted conversation. Steering does not interrupt the current turn: the deny backstop applies immediately when disabling, with tool-list replacement deferred to the next new turn. Re-enabling similarly restores the offered tools on the next new turn.

How you verified

  • Regression against main production files: two parameterized cases fail. Initially disabled fails because disallowedTools is undefined; initially enabled fails because no replacement occurs on toggling. Source restored byte-for-byte afterward.
  • Final pnpm exec turbo run test lint typecheck --filter=bb-plugin-provider-claude-code: 410 tests in 28 files pass, lint and typecheck pass.
  • Tests cover initial disabled/enabled states, unchanged settings without restart, both toggle directions, steering without interrupting the process, hook denial/allowance, and resume with the same provider conversation ID.
  • pnpm parity --old /tmp/bb3959-main --new . --provider claude-code --allowlist /tmp/bb3959-empty-allowlist.json: 13 passed, 0 failed, 1 process-scoped recording skipped. Empty allowlist intentionally used because the repository's default historical allowlist reports stale entries when comparing two current revisions; no event/row differences are suppressed.
  • Real CLI request probes used a local mock API, fake API credentials, isolated working directories and no project/user settings. These prove tool payload behavior without an LLM self-report or external model request; they do not measure token savings or execute a real subagent.
  • Independent mutation proof: removing the deny hook and making it always deny both fail the old live-settings test and both new parameterized cases at their intended assertions. Temporary files restored byte-for-byte.
  • oxfmt, git diff --check, and review against docs/CODE_REVIEW.md / deslop completed.

Fixes #3959

🤖 Generated with Claude Code

AGENT GENERATED

ymichael and others added 2 commits October 28, 2026 13:11
"Disable provider subagents" only denied Agent/Task calls in a PreToolUse
hook, so every thread still carried the tool definition and agent list
(~2.6k tokens) and the model kept trying a tool it could not use. The
session now starts with disallowedTools [Agent, Task], which removes
them from the model's context, and flipping the setting restarts the
resident session before the next turn. The deny hook is gone.

Fixes #3959

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit 1f31987 into main Oct 28, 2026
51 checks passed
@ymichael
ymichael deleted the bb/3959-standalone branch October 28, 2026 21:30
lukes-clanker Bot pushed a commit to banjerluke/bb that referenced this pull request Oct 29, 2026
AskUserQuestion, ScheduleWakeup and ReportFindings only pay off when a
human is watching, or drive a host-side loop bb does not run, yet every
Claude Code thread carries their schemas. ScheduleWakeup alone is the
largest schema in the array once Workflow is off, bigger than Bash, Read,
Edit and Write combined.

"Disable interactive tools" removes them from the model's context through
the SDK's disallowedTools, the same launch option upstream now uses for
"Disable provider subagents" (get-bb#6475). Both settings feed one disallowed
list, so toggling either restarts Claude before the next turn without
dropping the other's tools. Off by default.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
lukes-clanker Bot pushed a commit to banjerluke/bb that referenced this pull request Nov 4, 2026
AskUserQuestion, ScheduleWakeup and ReportFindings only pay off when a
human is watching, or drive a host-side loop bb does not run, yet every
Claude Code thread carries their schemas. ScheduleWakeup alone is the
largest schema in the array once Workflow is off, bigger than Bash, Read,
Edit and Write combined.

"Disable interactive tools" removes them from the model's context through
the SDK's disallowedTools, the same launch option upstream now uses for
"Disable provider subagents" (get-bb#6475). Both settings feed one disallowed
list, so toggling either restarts Claude before the next turn without
dropping the other's tools. Off by default.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
lukes-clanker Bot pushed a commit to banjerluke/bb that referenced this pull request Nov 12, 2026
AskUserQuestion, ScheduleWakeup and ReportFindings only pay off when a
human is watching, or drive a host-side loop bb does not run, yet every
Claude Code thread carries their schemas. ScheduleWakeup alone is the
largest schema in the array once Workflow is off, bigger than Bash, Read,
Edit and Write combined.

"Disable interactive tools" removes them from the model's context through
the SDK's disallowedTools, the same launch option upstream now uses for
"Disable provider subagents" (get-bb#6475). Both settings feed one disallowed
list, so toggling either restarts Claude before the next turn without
dropping the other's tools. Off by default.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
lukes-clanker Bot pushed a commit to banjerluke/bb that referenced this pull request Dec 1, 2026
AskUserQuestion, ScheduleWakeup and ReportFindings only pay off when a
human is watching, or drive a host-side loop bb does not run, yet every
Claude Code thread carries their schemas. ScheduleWakeup alone is the
largest schema in the array once Workflow is off, bigger than Bash, Read,
Edit and Write combined.

"Disable interactive tools" removes them from the model's context through
the SDK's disallowedTools, the same launch option upstream now uses for
"Disable provider subagents" (get-bb#6475). Both settings feed one disallowed
list, so toggling either restarts Claude before the next turn without
dropping the other's tools. Off by default.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

Claude Code provider: "Disable provider subagents" denies the Agent call but still sends the tool and agent list (~2.6k tokens per thread)

1 participant