[BUG] Prompt hooks cause exponential payload growth and infinite retry loop, generating 800MB+ debug logs

Status Closed — not planned
Reported on v2.1.3
Maintainer reply None cached
Activity 11 comments · opened Jan 10, 2026 · closed Feb 28, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

When using a type: "prompt" hook in UserPromptSubmit, Claude Code enters an infinite retry loop that generates 800MB+ debug logs within minutes. The hook's ARGUMENTS payload grows exponentially because each retry includes the previous invocation's full payload nested inside it.

A single user message triggers this sequence:

  1. Main API request fails with 413 "Request too large" (context exceeded limit)
  2. UserPromptSubmit prompt hook fires and calls Haiku API
  3. Hook's API call fails/gets aborted
  4. Hook retries immediately (no backoff, no max retry limit)
  5. Each retry logs the full ARGUMENTS, which now includes the previous ARGUMENTS
  6. Payload doubles each time: 1KB → 2KB → 4KB → ... → 453MB per log line

Debug log analysis showed:

  • Only 920 lines in the debug file
  • But single lines contained 453 million characters (453MB)
  • 15 nested ARGUMENTS: blocks within a single log line
  • Retries happening every 4-6 milliseconds

What Should Happen?

  1. Hook retries should have exponential backoff
  2. Hook retries should have a maximum retry limit
  3. Hook ARGUMENTS should not be recursively included in subsequent invocations
  4. Debug logging should not log the full payload on each retry (or should truncate)

Error Messages/Logs

Initial error triggering the cascade:

2026-01-10T03:17:11.898Z [ERROR] Error streaming, falling back to non-streaming mode: 413 {"error":{"type":"request_too_large","message":"Request exceeds the maximum size"}}

Retry loop pattern (happening every 4-6ms):

2026-01-10T03:19:34.716Z [ERROR] Error: Error: Request was aborted.
    at U4R (/$bunfs/root/claude:1003:97493)
    at ynB (/$bunfs/root/claude:4288:1368)
    at processTicksAndRejections (native:7:39)
2026-01-10T03:19:34.717Z [DEBUG] Hooks: Querying model with 1 messages
2026-01-10T03:19:34.717Z [DEBUG] Tool search disabled for model 'claude-haiku-4-5-20251001': model does not support tool_reference blocks.
2026-01-10T03:19:34.722Z [ERROR] Error in non-streaming fallback: Request was aborted.
2026-01-10T03:19:34.722Z [ERROR] Error: Error: Request was aborted.
... (repeating hundreds of times)

Evidence of recursive nesting (single log line analysis):

$ awk 'length > 1000000' debug.txt | grep -o 'ARGUMENTS:' | wc -l
15   # 15 nested ARGUMENTS blocks in one line!

$ awk '{print length}' debug.txt | sort -rn | head -3
453012793   # 453MB single line
226519121   # 226MB single line  
113271657   # 113MB single line

Steps to Reproduce

  1. Create a type: "prompt" hook in settings.json:
{
  "hooks": {
    "UserPromptSubmit": [
      {
        "hooks": [
          {
            "type": "prompt",
            "prompt": "Any prompt text here - content doesn't matter",
            "timeout": 15000
          }
        ]
      }
    ]
  }
}
  1. Have a long conversation until context approaches API limits (or manually create a large context)
  1. Send a user message that triggers a 413 "Request too large" error
  1. Observe debug log growing rapidly:
watch -n 1 'du -sh ~/.claude/debug/*'
  1. Within minutes, debug folder will exceed 800MB+ and continue growing until process is killed

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.3 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Cursor

Additional Information

Additional model info:

  • Sonnet for main conversation
  • Haiku (claude-haiku-4-5-20251001) for prompt hooks

Root cause analysis:

The bug appears to be in how prompt hook invocations are logged and/or how the ARGUMENTS are constructed for retries. Each retry seems to include the full previous ARGUMENTS payload, causing exponential growth:

Call N: ARGUMENTS: {prompt: "...", ...}
Call N+1: ARGUMENTS: {prompt: "... ARGUMENTS: {...}", ...}
Call N+2: ARGUMENTS: {prompt: "... ARGUMENTS: {... ARGUMENTS: {...}}", ...}

Workaround:

Replace type: "prompt" hooks with type: "command" hooks that use bash scripts instead of making API calls. This completely avoids the retry loop.

Suggested fixes:

  1. Add exponential backoff to hook retries
  2. Add maximum retry count (e.g., 3-5 retries)
  3. Don't nest previous ARGUMENTS in subsequent invocations
  4. Truncate debug log entries for ARGUMENTS (e.g., max 10KB per line)
  5. Consider adding a max debug file size limit with rotation

View original on GitHub ↗

11 Comments

brennenawana · 7 months ago

Related issue: #16093 also reports massive debug log growth, but from a different root cause (slow I/O triggering recursive "SLOW OPERATION DETECTED" logging).

This issue (#17249) is distinct because:

  • Trigger: Prompt hook API call failure after 413 error
  • Root cause: ARGUMENTS payload is recursively nested in each retry invocation
  • Pattern: Exponentially growing nested ARGUMENTS: blocks (15+ levels deep)

Both issues point to a need for:

  1. Debug log size limits / rotation
  2. Circuit breakers on recursive logging patterns

But the specific fix for this issue would be in the hook retry logic, not the slow operation detector.

brennenawana · 7 months ago

@EthanJStark does any of this sound valid to you?

github-actions[bot] · 7 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/11453
  2. https://github.com/anthropics/claude-code/issues/16641
  3. https://github.com/anthropics/claude-code/issues/16093

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

EthanJStark · 7 months ago
@EthanJStark does any of this sound valid to you?

Hi @brennenawana

No, this bug that you reported is distinct and different from my #16093 that @ claude incorrectly suggested as a duplicate

brennenawana · 7 months ago

Reproduction Confirmed ✅

Successfully reproduced the bug using a sandbox environment with a minimal type: "prompt" hook.

Reproduction Results

| Metric | Value |
|--------|-------|
| Time to trigger | ~30 seconds of conversation |
| Debug file growth | 3.6MB → 817MB in 4 seconds |
| Largest single line | 419 million characters (419MB) |
| Nested ARGUMENTS levels | 300 deep |

Evidence

Line length analysis showing exponential doubling:

419439586 bytes (419MB)
209724001 bytes (209MB) 
104866016 bytes (104MB)
 52436831 bytes (52MB)
 26222046 bytes (26MB)

Growth rate observed:

01:22:44 | Size: 3696KB    | Growth: +3232KB
01:22:45 | Size: 205348KB  | Growth: +201652KB  ⚠️ RAPID GROWTH
01:22:46 | Size: 819768KB  | Growth: +614420KB  ⚠️ RAPID GROWTH
01:22:48 | Size: 836152KB  | Growth: +16384KB   ⚠️ RAPID GROWTH

Minimal Reproduction Setup

.claude/settings.json:

{
  "hooks": {
    "UserPromptSubmit": [
      {
        "hooks": [
          {
            "type": "prompt",
            "prompt": "Any text here - content doesn't matter",
            "timeout": 15000
          }
        ]
      }
    ]
  }
}

Then have a conversation that builds up context (read files, generate code, etc.) until the bug triggers.

brettimus · 7 months ago

we hit this in our plugin (https://fp.dev) as well, thanks for the bug report. was driving me nuts yesterday!

brennenawana · 7 months ago
we hit this in our plugin (https://fp.dev) as well, thanks for the bug report. was driving me nuts yesterday!

no problem! I'll have to set aside all prompt hooks until this gets fixed.

VishalJ99 · 7 months ago

I have no hooks in my settings json yet also have constant population of large files in ~/.claude/debug?

brennenawana · 7 months ago

Do you notice any patterns in the debug logs that indicate some recursive
loop?

On Wed, Jan 14, 2026 at 9:52 AM Vishal Jain @.***>
wrote:

VishalJ99 left a comment (anthropics/claude-code#17249) <https://github.com/anthropics/claude-code/issues/17249#issuecomment-3749659856> I have no hooks in my settings json yet also have constant population of large files in ~/.claude/debug? — Reply to this email directly, view it on GitHub <https://github.com/anthropics/claude-code/issues/17249#issuecomment-3749659856>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AD6S6QOJJMH52IVEHGSHQEL4GZCYXAVCNFSM6AAAAACRH5RIICVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTONBZGY2TSOBVGY> . You are receiving this because you were mentioned.Message ID: @.***>
github-actions[bot] · 6 months ago

Closing for now — inactive for too long. Please open a new issue if this is still relevant.

github-actions[bot] · 5 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.