ToolSearch:optimistic polling loop causes 100% CPU usage
Resolved 💬 10 comments Opened Jan 23, 2026 by srdjanr-oa Closed Mar 13, 2026
Bug Description
Claude Code sessions running with --dangerously-skip-permissions get stuck in a tight CPU loop due to aggressive polling in the ToolSearch:optimistic feature.
Environment
- Claude Code Version: 2.1.17
- OS: Linux (WSL2 Ubuntu)
- Platform: linux
Symptoms
- Two concurrent Claude Code sessions consuming 100% and 97% CPU each
- Combined ~10GB RAM usage (4.5GB + 5.1GB)
- Debug logs filled with identical messages (84% of log content)
Debug Log Evidence
2026-01-23T10:30:24.836Z [DEBUG] [ToolSearch:optimistic] mode=tst-auto, ENABLE_TOOL_SEARCH=undefined, result=true
2026-01-23T10:30:24.836Z [DEBUG] [ToolSearch:optimistic] mode=tst-auto, ENABLE_TOOL_SEARCH=undefined, result=true
... (63,604 identical lines in one session)
Statistics from affected sessions:
- Session 1: 63,604 ToolSearch spam messages out of 75,281 total lines (84%)
- Session 2: 7,083 ToolSearch spam messages
Root Cause Analysis
The polling loop appears to trigger when:
ENABLE_TOOL_SEARCH=undefined(not explicitly configured)mode=tst-auto(automatic detection mode)- Running with
--dangerously-skip-permissions
The ToolSearch eligibility check runs continuously without rate limiting, causing CPU spin.
Workaround
Setting export ENABLE_TOOL_SEARCH=false in shell environment prevents the issue.
Steps to Reproduce
- Start Claude Code with
claude --dangerously-skip-permissions - Work in a project for extended period
- Observe CPU usage spike to 100%
- Check debug log at
~/.claude/debug/<session-id>.txtfor ToolSearch spam
Expected Behavior
ToolSearch eligibility checks should:
- Have rate limiting / debouncing
- Not poll continuously when result doesn't change
- Cache the result for a reasonable period
Actual Behavior
Continuous tight loop polling consuming 100% CPU per session.
This issue has 10 comments on GitHub. Read the full discussion on GitHub ↗