[BUG] Compaction is failing due to API returning invalid content

Resolved 💬 8 comments Opened Dec 20, 2025 by supertaz Closed Feb 24, 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?

As some other users have mentioned in bug reports, for the last week or so (but theirs claim infinite compaction loops, and my experience has been >1, but a finite number of compactions) I'm having issues where there are repeated compactions (auto and manual both trigger this intermittently, for a varying number of cycles) necessary to move a session forward - as many as 8 in a row! This started happening perhaps a week or so ago, and it doesn't happen every time, as I'll get several in a row that work just fine - until they don't, and then it will take anywhere from 2-8 compactions until the context window actually gets compacted. When running a manual compaction, I got actual feedback as to what the error was (although it's vague), and I've included a piece of the debug log below:

/compact

⎿ Error: Error during compaction: Error: Failed to generate conversation summary - response did not contain valid text content

What Should Happen?

Claude code should only compact a single time, after which the context window should have a significantly larger amount of usable space.

Error Messages/Logs

2025-12-20T09:39:39.882Z [ERROR] Error: Error: Failed to generate conversation summary - response did not contain valid text content
    at KQ$ (/$bunfs/root/claude:1703:1377)
    at async call (unknown)
    at async PL1 (unknown)
    at async G3D (unknown)
    at async y41 (unknown)
    at async Au (unknown)
    at async v41 (unknown)
    at async c6$ (unknown)
    at unknown
    at unknown
    at processTicksAndRejections (native:7:39)
2025-12-20T09:39:39.882Z [ERROR] Error: Error: Error during compaction: Error: Failed to generate conversation summary - response did not contain valid text content
    at call (/$bunfs/root/claude:3455:189)
    at async PL1 (unknown)
    at async G3D (unknown)
    at async y41 (unknown)
    at async Au (unknown)
    at async v41 (unknown)
    at async c6$ (unknown)
    at unknown
    at unknown
    at processTicksAndRejections (native:7:39)
2025-12-20T09:39:39.883Z [DEBUG] FileHistory: Making snapshot for message 55569e6c-dab6-42ce-be0b-037eb29f6a6e
2025-12-20T09:39:39.884Z [DEBUG] FileHistory: Added snapshot for 55569e6c-dab6-42ce-be0b-037eb29f6a6e, tracking 3 files
2025-12-20T09:39:39.887Z [DEBUG] UserCommandMessage rendering: "compact" (args: "none")
2025-12-20T09:39:39.887Z [DEBUG] isSkillFormat: false
2025-12-20T09:39:40.686Z [DEBUG] Stream started - received first chunk
2025-12-20T09:40:39.915Z [DEBUG] Getting matching hook commands for Notification with query: idle_prompt
2025-12-20T09:40:39.915Z [DEBUG] Found 0 hook matchers in settings
2025-12-20T09:40:39.915Z [DEBUG] Matched 0 unique hooks for query "idle_prompt" (0 before deduplication)
2025-12-20T09:41:29.994Z [DEBUG] LSP Diagnostics: getLSPDiagnosticAttachments called
2025-12-20T09:41:29.994Z [DEBUG] LSP Diagnostics: Checking registry - 0 pending
2025-12-20T09:41:29.995Z [DEBUG] Hooks: Found 0 total hooks in registry
2025-12-20T09:41:29.995Z [DEBUG] Hooks: checkForNewResponses returning 0 responses
2025-12-20T09:41:30.023Z [DEBUG] Getting matching hook commands for UserPromptSubmit with query: undefined
2025-12-20T09:41:30.023Z [DEBUG] Found 2 hook matchers in settings
2025-12-20T09:41:30.023Z [DEBUG] Matched 2 unique hooks for query "no match query" (2 before deduplication)
2025-12-20T09:41:30.055Z [DEBUG] FileHistory: Making snapshot for message 53bd38c8-4762-4024-bb1b-9a48282a6d1f
2025-12-20T09:41:30.056Z [DEBUG] FileHistory: Added snapshot for 53bd38c8-4762-4024-bb1b-9a48282a6d1f, tracking 3 files
2025-12-20T09:41:30.071Z [DEBUG] Total plugin output styles loaded: 0
2025-12-20T09:41:30.076Z [DEBUG] Getting matching hook commands for PreCompact with query: auto
2025-12-20T09:41:30.076Z [DEBUG] Found 2 hook matchers in settings
2025-12-20T09:41:30.076Z [DEBUG] Matched 2 unique hooks for query "auto" (2 before deduplication)
2025-12-20T09:41:30.100Z [DEBUG] PreCompact:auto [callback] completed successfully
2025-12-20T09:41:30.785Z [DEBUG] Stream started - received first chunk
2025-12-20T09:41:32.460Z [DEBUG] Stream started - received first chunk
2025-12-20T09:41:45.610Z [DEBUG] Writing to temp file: /home/<USER_REDACTED>/.claude.json.tmp.3335757.1766223705610
2025-12-20T09:41:45.610Z [DEBUG] Preserving file permissions: 100600
2025-12-20T09:41:45.618Z [DEBUG] [SLOW OPERATION DETECTED] fs.writeFileSync (8.5ms)
2025-12-20T09:41:45.618Z [DEBUG] Temp file written successfully, size: 65926 bytes
2025-12-20T09:41:45.618Z [DEBUG] Applied original permissions to temp file
2025-12-20T09:41:45.618Z [DEBUG] Renaming /home/<USER_REDACTED>/.claude.json.tmp.3335757.1766223705610 to /home/<USER_REDACTED>/.claude.json
2025-12-20T09:41:45.619Z [DEBUG] File /home/<USER_REDACTED>/.claude.json written atomically
2025-12-20T09:42:00.003Z [ERROR] Error: Error: Failed to generate conversation summary - response did not contain valid text content
    at KQ$ (/$bunfs/root/claude:1703:1377)
    at async DUD (unknown)
    at processTicksAndRejections (native:7:39)
2025-12-20T09:42:05.597Z [DEBUG] Stream started - received first chunk
2025-12-20T09:42:15.594Z [DEBUG] executePreToolHooks called for tool: Bash
2025-12-20T09:42:15.595Z [DEBUG] executePreToolHooks called for tool: Grep
2025-12-20T09:42:15.601Z [DEBUG] Getting matching hook commands for PreToolUse with query: Bash
2025-12-20T09:42:15.601Z [DEBUG] Found 2 hook matchers in settings
2025-12-20T09:42:15.601Z [DEBUG] Matched 2 unique hooks for query "Bash" (2 before deduplication)
2025-12-20T09:42:15.601Z [DEBUG] Getting matching hook commands for PreToolUse with query: Grep
2025-12-20T09:42:15.601Z [DEBUG] Found 2 hook matchers in settings
2025-12-20T09:42:15.601Z [DEBUG] Matched 2 unique hooks for query "Grep" (2 before deduplication)
2025-12-20T09:42:15.676Z [DEBUG] tree-sitter: loaded from embedded
2025-12-20T09:42:15.735Z [DEBUG] No session environment scripts found
2025-12-20T09:42:15.769Z [DEBUG] Getting matching hook commands for PostToolUse with query: Bash
2025-12-20T09:42:15.769Z [DEBUG] Found 2 hook matchers in settings
2025-12-20T09:42:15.769Z [DEBUG] Matched 2 unique hooks for query "Bash" (2 before deduplication)
2025-12-20T09:42:16.069Z [DEBUG] Getting matching hook commands for PostToolUse with query: Grep
2025-12-20T09:42:16.069Z [DEBUG] Found 2 hook matchers in settings
2025-12-20T09:42:16.069Z [DEBUG] Matched 2 unique hooks for query "Grep" (2 before deduplication)
2025-12-20T09:42:16.103Z [DEBUG] LSP Diagnostics: getLSPDiagnosticAttachments called
2025-12-20T09:42:16.103Z [DEBUG] LSP Diagnostics: Checking registry - 0 pending
2025-12-20T09:42:16.103Z [DEBUG] Hooks: Found 0 total hooks in registry
2025-12-20T09:42:16.103Z [DEBUG] Hooks: checkForNewResponses returning 0 responses
2025-12-20T09:42:16.119Z [DEBUG] Getting matching hook commands for PreCompact with query: auto
2025-12-20T09:42:16.119Z [DEBUG] Found 2 hook matchers in settings
2025-12-20T09:42:16.119Z [DEBUG] Matched 2 unique hooks for query "auto" (2 before deduplication)
2025-12-20T09:42:16.142Z [DEBUG] PreCompact:auto [callback] completed successfully
2025-12-20T09:42:16.555Z [DEBUG] Stream started - received first chunk
2025-12-20T09:42:18.754Z [DEBUG] Stream started - received first chunk
2025-12-20T09:43:01.707Z [ERROR] Error: Error: Failed to generate conversation summary - response did not contain valid text content
    at KQ$ (/$bunfs/root/claude:1703:1377)
    at async DUD (unknown)
    at processTicksAndRejections (native:7:39)

Steps to Reproduce

Work until the auto-compact buffer is full and auto-compact triggers. Watch it fail (maybe). Watch it fail again (maybe). Rinse, repeat.

-OR-

Work until the auto-compact buffer is full and auto-compact triggers. Watch it fail (possibly multiple times). Hit ESC, because you want to try to help it along. Use /compact. Watch it fail again. Get a vague error message (better than no error message). Let it take 1-2 more turns. Auto-compact triggers again. Watch it fail (maybe, or maybe this is the time that it doesn't!)

-OR-

Use /compact. Watch it fail (if the stars don't align). Use /compact again. Watch it fail again (if that's what's fated this day).

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

2.0.6?

Claude Code Version

2.0.74

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

Other

Additional Information

This is on a closed-source project, but there are pre- and post-compaction hooks, along with several other hooks. That said, I've checked them, and so has Opus, and neither of use sees anything that could interfere (the compaction-related hooks only put content into systemMessage, to cue the agent to keep on track and not do silly things). In theory, I suppose that could exceed the maximum message size, but I highly doubt it, as that should trigger an error, not a problem validating the returned message from the API.

Also, I forgot to sacrifice a chicken. Maybe that's the problem. Does Claude prefer other fowl? Or, perhaps small, furry animals instead? I don't think I have any tungsten cubes. I might object to animal sacrifices, unless it's a swan. Swans are jerks. (No, really, they're pretty, but they're mean, territorial, and super aggressive!) </comedic relief>

View original on GitHub ↗

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