Skip to content

fix: allowed_tools=[] treated as falsy instead of disabling all tools#524

Open
drillan wants to merge 1 commit intoanthropics:mainfrom
drillan:fix/allowed-tools-empty-list-523
Open

fix: allowed_tools=[] treated as falsy instead of disabling all tools#524
drillan wants to merge 1 commit intoanthropics:mainfrom
drillan:fix/allowed-tools-empty-list-523

Conversation

@drillan
Copy link

@drillan drillan commented Jan 28, 2026

Summary

  • allowed_tools=[] (explicitly empty) and allowed_tools=None (unset) were indistinguishable due to Python's truthiness check on empty lists
  • --allowedTools controls which tools execute without prompting for permission (auto-allow list), not which tools are available (that's --tools)
  • allowed_tools=[] should mean "no tools are auto-allowed (all require permission prompting)", but was silently ignored, leaving the default permission behavior unchanged

Changes

  • Changed allowed_tools default from [] to None in ClaudeAgentOptions to distinguish "unset" from "explicitly empty"
  • Updated truthiness check to is not None in subprocess_cli.py so allowed_tools=[] correctly passes --allowedTools "" to the CLI
  • Added tests for both empty-list and default (None) cases

Clarification

This fix addresses the None vs [] conflation bug. Note that --allowedTools is about permission prompting behavior, not tool availability:

Value Meaning CLI flag
None Unset (use defaults) --allowedTools omitted
[] No tools auto-allowed (all require permission) --allowedTools ""
["Read", "Bash(git *)"] These tools run without prompting --allowedTools "Read,Bash(git *)"

To restrict which tools are available to the model, use the tools option (--tools) instead.

Fixes #523

Test plan

  • python -m pytest tests/test_transport.py -k allowed_tools — 2 new tests pass
  • python -m pytest tests/test_types.py — updated default assertion passes
  • python -m pytest tests/ — all tests pass
  • python -m mypy src/ — no errors

🤖 Generated with Claude Code

…ll tools

`allowed_tools=[]` was treated as falsy and ignored, causing all tools
to remain available instead of none. Change the default from `[]` to
`None` and use `is not None` check to correctly pass `--allowedTools ""`
to the CLI when an empty list is explicitly provided.

Fixes anthropics#523

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@drillan drillan force-pushed the fix/allowed-tools-empty-list-523 branch from 1489baa to 97caff9 Compare February 15, 2026 02:12
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.

allowed_tools=[] (empty list) is treated as falsy, conflating "no auto-allowed tools" with "unset"

1 participant