claude-code - 💡(How to fix) Fix [BUG] CLI returns empty responses: Model generates <thinking> block but output_tokens is 0 (Opus 4.7 & Sonnet 4.6) [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#51890Fetched 2026-04-23 07:42:10
View on GitHub
Comments
2
Participants
2
Timeline
3
Reactions
0
Author
Timeline (top)
commented ×2labeled ×1

Error Message

The system should never silently fail with output_tokens: 0 after a successful <thinking> phase. There should be an error catch or a fallback mechanism to inform the user what went wrong, rather than displaying an empty prompt.

Error Messages/Logs

Root Cause

{ "type": "assistant", "uuid": "[REDACTED_UUID]", "timestamp": "2026-04-22T08:15:12.705Z", "entrypoint": "cli", "cwd": "/Users/[REDACTED_USER]/Workdir/[REDACTED_PROJECT_PATH]", "version": "2.1.117", "message": { "model": "claude-sonnet-4-6", "id": "msg_bdrk_[REDACTED_ID]", "type": "message", "role": "assistant", "content": [ { "type": "thinking", "thinking": "The user is frustrated because my responses keep getting cut off/interrupted... Looking back at the conversation, I can see several instances where my response shows "(no content)" - this means my response was empty/cut off... I should always include text alongside tool calls, and the instruction is clear that I need to state what I'm about to do before invoking anything... I was sending entirely tool-focused responses without any accompanying text, which would appear as silence to the user...", "signature": "[REDACTED_SIGNATURE]" } ], "stop_reason": null, "stop_sequence": null, "usage": { "input_tokens": 3, "cache_creation_input_tokens": 35117, "cache_read_input_tokens": 0, "output_tokens": 0 } } }

Code Example

{
  "type": "assistant",
  "uuid": "[REDACTED_UUID]",
  "timestamp": "2026-04-22T08:11:50.266Z",
  "entrypoint": "cli",
  "cwd": "/Users/[REDACTED_USER]/Workdir/[REDACTED_PROJECT_PATH]",
  "version": "2.1.117",
  "message": {
    "model": "claude-opus-4-7",
    "id": "msg_bdrk_[REDACTED_ID]",
    "type": "message",
    "role": "assistant",
    "content": [
      {
        "type": "thinking",
        "thinking": "[REDACTED_LONG_THINKING_PROCESS]",
        "signature": "[REDACTED_SIGNATURE]"
      }
    ],
    "stop_reason": null,
    "stop_sequence": null,
    "stop_details": null,
    "usage": {
      "input_tokens": 6,
      "cache_creation_input_tokens": 36412,
      "cache_read_input_tokens": 10477,
      "output_tokens": 0,
      "service_tier": "standard"
    }
  }
}

{
  "type": "assistant",
  "uuid": "[REDACTED_UUID]",
  "timestamp": "2026-04-22T08:15:12.705Z",
  "entrypoint": "cli",
  "cwd": "/Users/[REDACTED_USER]/Workdir/[REDACTED_PROJECT_PATH]",
  "version": "2.1.117",
  "message": {
    "model": "claude-sonnet-4-6",
    "id": "msg_bdrk_[REDACTED_ID]",
    "type": "message",
    "role": "assistant",
    "content": [
      {
        "type": "thinking",
        "thinking": "The user is frustrated because my responses keep getting cut off/interrupted... Looking back at the conversation, I can see several instances where my response shows \"(no content)\" - this means my response was empty/cut off... I should always include text alongside tool calls, and the instruction is clear that I need to state what I'm about to do before invoking anything... I was sending entirely tool-focused responses without any accompanying text, which would appear as silence to the user...",
        "signature": "[REDACTED_SIGNATURE]"
      }
    ],
    "stop_reason": null,
    "stop_sequence": null,
    "usage": {
      "input_tokens": 3,
      "cache_creation_input_tokens": 35117,
      "cache_read_input_tokens": 0,
      "output_tokens": 0
    }
  }
}
RAW_BUFFERClick to expand / collapse

Preflight Checklist

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

What's Wrong?

When interacting with the CLI, the AI occasionally gets stuck in a state where it processes the user's prompt and generates a lengthy <thinking> block, but completely fails to generate any visible output or tool calls. The response terminates with output_tokens: 0.

From the user's perspective, the CLI appears to be interrupted, frozen, or silently ignoring the prompt, leading to a highly frustrating experience.

What Should Happen?

If the model uses a tool, it should output mandatory explanatory text alongside the tool call to ensure the UI/CLI renders it correctly.

The system should never silently fail with output_tokens: 0 after a successful <thinking> phase. There should be an error catch or a fallback mechanism to inform the user what went wrong, rather than displaying an empty prompt.

Error Messages/Logs

{
  "type": "assistant",
  "uuid": "[REDACTED_UUID]",
  "timestamp": "2026-04-22T08:11:50.266Z",
  "entrypoint": "cli",
  "cwd": "/Users/[REDACTED_USER]/Workdir/[REDACTED_PROJECT_PATH]",
  "version": "2.1.117",
  "message": {
    "model": "claude-opus-4-7",
    "id": "msg_bdrk_[REDACTED_ID]",
    "type": "message",
    "role": "assistant",
    "content": [
      {
        "type": "thinking",
        "thinking": "[REDACTED_LONG_THINKING_PROCESS]",
        "signature": "[REDACTED_SIGNATURE]"
      }
    ],
    "stop_reason": null,
    "stop_sequence": null,
    "stop_details": null,
    "usage": {
      "input_tokens": 6,
      "cache_creation_input_tokens": 36412,
      "cache_read_input_tokens": 10477,
      "output_tokens": 0,
      "service_tier": "standard"
    }
  }
}

{
  "type": "assistant",
  "uuid": "[REDACTED_UUID]",
  "timestamp": "2026-04-22T08:15:12.705Z",
  "entrypoint": "cli",
  "cwd": "/Users/[REDACTED_USER]/Workdir/[REDACTED_PROJECT_PATH]",
  "version": "2.1.117",
  "message": {
    "model": "claude-sonnet-4-6",
    "id": "msg_bdrk_[REDACTED_ID]",
    "type": "message",
    "role": "assistant",
    "content": [
      {
        "type": "thinking",
        "thinking": "The user is frustrated because my responses keep getting cut off/interrupted... Looking back at the conversation, I can see several instances where my response shows \"(no content)\" - this means my response was empty/cut off... I should always include text alongside tool calls, and the instruction is clear that I need to state what I'm about to do before invoking anything... I was sending entirely tool-focused responses without any accompanying text, which would appear as silence to the user...",
        "signature": "[REDACTED_SIGNATURE]"
      }
    ],
    "stop_reason": null,
    "stop_sequence": null,
    "usage": {
      "input_tokens": 3,
      "cache_creation_input_tokens": 35117,
      "cache_read_input_tokens": 0,
      "output_tokens": 0
    }
  }
}

Steps to Reproduce

  1. The user interacts with the CLI normally (e.g., analyzing a Confluence document).
  2. The user asks a follow-up question.
  3. The model processes the request and enters the <thinking> phase.
  4. The generation ends abruptly without producing any text output.

Claude Model

Not sure / Multiple models

Is this a regression?

Yes, this worked in a previous version

Last Working Version

No response

Claude Code Version

2.1.117

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

No response

extent analysis

TL;DR

The issue can be addressed by modifying the model's response generation to include mandatory explanatory text alongside tool calls and implementing a fallback mechanism to handle cases where the model fails to generate output.

Guidance

  • Review the model's code to ensure it includes explanatory text with tool calls, as implied by the model's own analysis in the provided log.
  • Implement a fallback mechanism to catch cases where the model generates no output, providing an error message or a default response to the user instead of silently failing.
  • Investigate the difference in behavior between the current version (2.1.117) and the previous version where this issue did not occur, to identify potential regressions.
  • Consider testing with different models (e.g., "claude-opus-4-7" and "claude-sonnet-4-6") to see if the issue is model-specific.

Example

No specific code example can be provided without more details on the model's implementation, but the model's own log suggests it is aware of the need to include explanatory text with tool calls, indicating a potential starting point for investigation.

Notes

The issue seems to be related to a regression in version 2.1.117, as it worked in a previous version. However, the last working version is not specified, which could be crucial for pinpointing the exact cause.

Recommendation

Apply a workaround by modifying the model's response generation to include explanatory text and implementing a fallback for silent failures, as the root cause of the regression is not immediately clear and may require further investigation.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING