Skip to content

fix(sdk): pass [] instead of None for allowed/disallowed tools (NoneType crash)#206

Open
Aispotlightlab wants to merge 1 commit into
RichardAtCT:mainfrom
Aispotlightlab:fix/none-allowed-tools-crash
Open

fix(sdk): pass [] instead of None for allowed/disallowed tools (NoneType crash)#206
Aispotlightlab wants to merge 1 commit into
RichardAtCT:mainfrom
Aispotlightlab:fix/none-allowed-tools-crash

Conversation

@Aispotlightlab
Copy link
Copy Markdown

Problem

When DISABLE_TOOL_VALIDATION=true is set, every Telegram message produces Claude integration failed and the SDK crashes before the CLI even starts:

{"error": "'NoneType' object is not iterable", "error_type": "TypeError",
 "event": "Unexpected error in Claude SDK", "logger": "src.claude.sdk_integration"}

Root cause

ClaudeSDKManager.run_command (src/claude/sdk_integration.py:314) passes None for sdk_allowed_tools / sdk_disallowed_tools when disable_tool_validation is true.

Downstream, claude-agent-sdk (verified on both 0.1.81 and the latest 0.2.82) calls list(self._options.allowed_tools) unconditionally inside subprocess_cli.py::_apply_skills_defaults. list(None)TypeError.

This is a real bug in the SDK (no None-guard on a documented-as-optional field), but the fix here is trivial on the Cct side and unblocks every user who enables MCP with DISABLE_TOOL_VALIDATION=true (the standard recipe for adding third-party MCP servers like MemPalace, Mem0, etc.).

Fix

Pass [] instead of None. The CLI treats an empty list as "no --allowedTools flag" → no restriction, which matches the intent of DISABLE_TOOL_VALIDATION=true.

if self.config.disable_tool_validation:
    sdk_allowed_tools = []      # was: None
    sdk_disallowed_tools = []   # was: None

Reproduction

  1. .env: DISABLE_TOOL_VALIDATION=true + ENABLE_MCP=true + valid MCP_CONFIG_PATH
  2. Send any message to the bot
  3. Without this fix: Claude integration failed on every turn
  4. With this fix: bot responds normally; MCP tools are accessible

Verified end-to-end with a 27-tool MemPalace MCP server (Python mempalace-mcp binary) on claude-agent-sdk 0.1.81 + Cct 1.6.0.

Upstream

Will file matching issue/PR upstream at anthropics/claude-agent-sdk-python so the SDK adds or [] on the list() call. Until that lands, this Cct-side guard is the practical fix.


🤖 Generated with Claude Code

When DISABLE_TOOL_VALIDATION=true, ClaudeSDKManager was passing None
for allowed_tools and disallowed_tools. The downstream claude-agent-sdk
(versions 0.1.x through at least 0.2.82) calls
`list(self._options.allowed_tools)` unconditionally in
`subprocess_cli.py:_apply_skills_defaults` and crashes with
"TypeError: 'NoneType' object is not iterable" before the CLI process
even starts.

Symptom: every Telegram message produces "Claude integration failed".

This patches the symptom in Cct by passing empty lists. The CLI treats
an empty list the same as "no --allowedTools flag" → no restriction,
which is the intent of DISABLE_TOOL_VALIDATION=true. Filed upstream as
well: https://github.com/anthropics/claude-agent-sdk-python (pending).

Repro: set DISABLE_TOOL_VALIDATION=true + ENABLE_MCP=true in .env, send
any message. SDK never returns past ClaudeSDKClient.connect().

Co-Authored-By: Claude Opus 4.7 (1M context) <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.

1 participant