Skip to content

fix: respect --allowedTools when building disallowed tools list#1033

Open
MaxwellCalkin wants to merge 1 commit intoanthropics:mainfrom
MaxwellCalkin:fix/respect-allowed-tools-in-disallowed-list
Open

fix: respect --allowedTools when building disallowed tools list#1033
MaxwellCalkin wants to merge 1 commit intoanthropics:mainfrom
MaxwellCalkin:fix/respect-allowed-tools-in-disallowed-list

Conversation

@MaxwellCalkin
Copy link

Summary

Fixes #690

  • In agent mode, WebSearch and WebFetch were not being explicitly disabled via --disallowedTools, inconsistent with tag mode's security behavior
  • When users specified --allowedTools WebSearch in claude_args, it had no effect on the disallowed tools list because buildDisallowedToolsString() was never called in agent mode
  • This PR calls buildDisallowedToolsString([], allowedTools) in prepareAgentMode() so that WebSearch/WebFetch are disabled by default, but respected when the user explicitly allows them

Changes

  • src/modes/agent/index.ts: Import and call buildDisallowedToolsString() with the parsed allowedTools from claude_args, adding --disallowedTools to claudeArgs when tools need to be disabled
  • test/modes/agent.test.ts: Updated existing test and added two new tests:
    • --allowedTools WebSearch removes only WebSearch from the disallowed list (WebFetch remains)
    • --allowedTools WebSearch,WebFetch removes both, resulting in no --disallowedTools flag

Test plan

  • Existing agent mode tests updated and passing
  • New test: --allowedTools WebSearch removes WebSearch from disallowed list
  • New test: --allowedTools WebSearch,WebFetch removes both from disallowed list
  • All 62 tests across agent, parse-tools, and create-prompt test files pass
  • Manual verification: deploy with claude_args: '--allowedTools "WebSearch"' and confirm WebSearch is available

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

In agent mode, WebSearch and WebFetch are now properly disabled by
default via --disallowedTools, consistent with tag mode's security
posture. When users explicitly allow these tools via --allowedTools
in claude_args, they are removed from the disallowed list.

Fixes anthropics#690

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

--allowedTools in claude_args doesn't prevent default disabling of WebSearch and WebFetch

1 participant