Severe input lag (~5s per keystroke) when conversation history contains large tool outputs

Resolved 💬 3 comments Opened Jan 19, 2026 by heathdutton Closed Jan 19, 2026

GitHub Issue for anthropics/claude-code

Title

Severe input lag (~5s per keystroke) when conversation history contains large tool outputs

Body

Summary

When Bash commands produce large stdout (multi-MB), the full untruncated output is stored in the session JSONL file. After accumulating ~50MB of tool output across multiple commands, claude --continue becomes nearly unusable:

  • Typing a single character takes ~5 seconds to appear
  • CPU spikes to 100%
  • System becomes unresponsive

Root Cause Analysis

Examined a problematic session file (~/.claude/projects/.../session.jsonl):

| Component | Size | Count |
|-----------|------|-------|
| toolUseResult.stdout | ~3 MB each | 7 instances |
| progress messages | 23.67 MB | 11,329 messages |
| Total session file | ~50 MB | |

The largest individual lines were 3+ MB each - full stdout from long-running scripts that produced continuous log output.

Example of stored output (3MB single entry):
11:23 - Low-activity detector running, temp: 267G
11:28 - Low-activity detector running, temp: 279G
11:33 - Low-activity detector running, temp: 284G
... (thousands of lines)

Steps to Reproduce

  1. Create a script that generates large output:
mkdir -p /tmp/claude-lag-test && cd /tmp/claude-lag-test
git init && echo "# test" > README.md && git add . && git commit -m "init"

cat > generate_output.sh << 'SCRIPT'
#!/bin/bash
for i in $(seq 1 50000); do
    echo "$(date +%H:%M:%S) - Processing item $i, status: running, memory: ${RANDOM}MB"
done
SCRIPT
chmod +x generate_output.sh
  1. Start Claude and run the script multiple times:
cd /tmp/claude-lag-test && claude

Ask Claude: "Run ./generate_output.sh" (repeat 3-4 times to accumulate ~15MB of output)

  1. Exit Claude and restart with --continue:
claude --continue
  1. Type slowly and observe the lag between keypress and character display

Expected Behavior

  • Large tool outputs should be truncated before being stored in session history
  • Or session files should be lazily loaded / streamed
  • Input should remain responsive regardless of conversation history size

Actual Behavior

  • Full multi-MB stdout stored in toolUseResult.stdout field
  • Session JSONL files grow unbounded
  • ~50MB session file causes ~5 second input lag per keystroke
  • CPU maxes out during typing

Environment

  • macOS (Darwin 25.2.0)
  • Claude Code CLI (latest)

Suggested Fixes

  1. Truncate large tool outputs before storing (e.g., keep first/last 10KB with "[truncated]" marker)
  2. Stream/lazy-load session history instead of parsing entire file upfront
  3. Cap progress message storage - 11,329 progress messages for one session is excessive
  4. Add warning when session file exceeds a size threshold

Workaround

Delete the bloated session file:

rm ~/.claude/projects/<project-path>/<session-id>.jsonl

---

Command to create this issue:

gh issue create --repo anthropics/claude-code \
  --title "Severe input lag (~5s per keystroke) when conversation history contains large tool outputs" \
  --body-file /tmp/claude-code-issue.md

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗