-
Notifications
You must be signed in to change notification settings - Fork 29
Description
Problem
When Ralph's Claude Code driver passes ALLOWED_TOOLS via --allowedTools to the CLI, certain valid tool names are denied by Claude Code, triggering the circuit breaker after 2 consecutive loops (CB_PERMISSION_DENIAL_THRESHOLD=2). Once open, the circuit breaker blocks all further execution with no easy recovery path from the monitor UI.
Root cause
The VALID_TOOL_PATTERNS whitelist in drivers/claude-code.sh only includes a narrow set of tools:
Write, Read, Edit, MultiEdit, Glob, Grep, Task, TodoWrite,
WebFetch, WebSearch, Bash, Bash(...), NotebookEdit
Important tools like Agent, Skill, LSP, AskUserQuestion, and all MCP tools (mcp__*) are missing from validation. While validation only runs for CLI flag usage (not .ralphrc), the Claude Code CLI itself may still deny tools that aren't properly formatted or recognized.
Observed behavior
- Ralph starts loop, Claude requests
BashandAskUserQuestiontools - Both denied (permission denied)
- After 2 loops, circuit breaker opens
--reset-circuitCLI flag resets state but monitor still shows OPEN (state file not properly synced)- User is stuck - has to manually edit
.circuit_breaker_state
Logs
[WARN] Permission denied for 2 command(s): Bash(node --version ...), AskUserQuestion
[WARN] Update ALLOWED_TOOLS in .ralphrc to include the required tools
Deeper issue: AskUserQuestion is fundamentally incompatible with Ralph
Beyond the validation whitelist problem, AskUserQuestion cannot work in Ralph's execution mode. Ralph runs Claude Code with -p (print/non-interactive mode) — there is no user session to receive or respond to questions. When Claude tries to use AskUserQuestion:
- The tool is denied because there's no interactive terminal
- The response analyzer detects the denial and halts the loop
- On retry, Claude asks the same questions again → same denial → circuit breaker opens
In testing, this caused 3 consecutive loops of $3+ each ($9 total) with zero files created and zero progress. Claude kept asking the same 2-3 setup questions (DB provider, Next.js version, Node version) every loop.
The generated PROMPT.md template should explicitly instruct Claude to never use AskUserQuestion and make autonomous decisions instead. When truly blocked, Claude should set STATUS: BLOCKED in the Ralph status report rather than attempting interactive questions.
Suggested improvements
- Expand
VALID_TOOL_PATTERNSto includeAgent,Skill,LSP,AskUserQuestion, and MCP wildcard patterns (mcp__*) - Default
ALLOWED_TOOLSshould be more permissive - the generated.ralphrcdefaults are too narrow for real-world usage. Consider including all core Claude Code tools by default - Support MCP wildcards in defaults -
mcp__github__*,mcp__context7__*,mcp__playwright__*are common and should be documented/suggested - Circuit breaker reset reliability -
--reset-circuitshould guarantee the state file is updated and the monitor reflects it - Better error message - when permission denied, log which specific tool was denied and suggest the exact
ALLOWED_TOOLSentry needed - Generated PROMPT.md should ban
AskUserQuestion- add an "Autonomous Mode" section telling Claude it runs non-interactively and must never attempt interactive tools. UseSTATUS: BLOCKEDfor genuine blockers instead.
Environment
- Platform: Windows 11 (bash via Git Bash)
- Claude Code CLI
- Ralph via bmalph integration