Crash: Cannot read properties of undefined (reading 'command') in isSearchOrReadCommand with custom ANTHROPIC_BASE_URL
Resolved 💬 3 comments Opened Apr 4, 2026 by grsrzxgvmpg Closed May 15, 2026
Bug description
When using ANTHROPIC_BASE_URL pointed at a local llama-server (OpenAI/Anthropic-compatible), Claude Code crashes if the model emits a tool call with undefined/missing input parameters.
Stack trace
ERROR Cannot read properties of undefined (reading 'command')
Object.isSearchOrReadComma (cli.js:2976:2952)
JJ6 (cli.js:3971:593)
og8 (cli.js:3971:1214)
HYY (cli.js:3971:2411)
fZK (cli.js:3972:2435)
Steps to reproduce
- Set
ANTHROPIC_BASE_URLto a local llama-server (e.g., llama.cpp server with--reasoning-format deepseek) - Enable
CLAUDE_CODE_USE_POWERSHELL_TOOL=1in settings.json - Use a local model that occasionally emits malformed tool calls (e.g., PowerShell tool call with empty/missing input)
- Claude Code crashes in the TUI display layer while trying to render the pending tool call
Root cause
isSearchOrReadCommand(q) guards with if (!q.command) but crashes when q itself is undefined. The null check should be if (!q?.command).
The crash occurs in the TUI display layer (collapsible tool-use renderer), not in tool execution — Claude Code crashes while deciding how to display the tool call, before it even attempts to run it.
Workaround
Set CLAUDE_CODE_USE_POWERSHELL_TOOL=0 for local model sessions to remove the PowerShell tool entirely.
Environment
- Claude Code installed via npm (latest)
- Windows 11 Pro
- llama-server with Qwen3.5 models via
ANTHROPIC_BASE_URL=http://localhost:1237 - llama-server serves both
/v1/chat/completions(OpenAI) and/v1/messages(Anthropic) endpoints natively
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗