[BUG] 20-70% of concurrently ran chats fail to provide usage data and stream events

Resolved 💬 4 comments Opened Dec 22, 2025 by MarvellousBee Closed Feb 14, 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?

I'm using the python sdk to useclaude-code in several concurrent sessions.
I'm posting here since i think the issue is unlikely to be caused by the python sdk.

In the "Steps to reproduce" script, sometimes chats fail with two issues:

  • No StreamEvent objects are returned
  • All usage data is set to 0
Session 7: ❌ ZERO TOKENS
  Response text: '7 + 8 = **15**...' (14 chars)
  Usage: {'input_tokens': 0, 'cache_creation_input_tokens': 0, 'cache_read_input_tokens': 0, 'output_tokens': 0, 'server_tool_use': {'web_search_requests': 0, 'web_fetch_requests': 0}, 'service_tier': 'standard', 'cache_creation': {'ephemeral_1h_input_tokens': 0, 'ephemeral_5m_input_tokens': 0}}
  Message types: AssistantMessage: 1, ResultMessage: 1, SystemMessage: 1
  Messages received:
    [0] SystemMessage
    [1] AssistantMessage
    [2] ResultMessage: is_error=False, output_tokens=0

What Should Happen?

I expected chats to return usage data and StreamEvent objects, 100% of the time.
StreamEvent is expected since I passed include_partial_messages=true.
Here are some exaples of this happening, from the script:

Session 2: ✔️ (output_tokens=13) | Message types: AssistantMessage: 1, ResultMessage: 1, StreamEvent: 7, SystemMessage: 1
Session 3: ✔️ (output_tokens=13) | Message types: AssistantMessage: 1, ResultMessage: 1, StreamEvent: 7, SystemMessage: 1
Session 4: ✔️ (output_tokens=13) | Message types: AssistantMessage: 1, ResultMessage: 1, StreamEvent: 7, SystemMessage: 1
Session 5: ✔️ (output_tokens=13) | Message types: AssistantMessage: 1, ResultMessage: 1, StreamEvent: 7, SystemMessage: 1
Session 6: ✔️ (output_tokens=13) | Message types: AssistantMessage: 1, ResultMessage: 1, StreamEvent: 7, SystemMessage: 1

Error Messages/Logs

There's a full log of the issue happening in this repo:
'https://github.com/MarvellousBee/claude_agent_sdk_bug_report'

Steps to Reproduce

  1. clone this repo: https://github.com/MarvellousBee/claude_agent_sdk_bug_report
  2. add a .env file with ANTHROPIC_API_KEY=YOUR_KEY
  3. pip install python-decouple claude-agent-sdk
  4. python script.py

Claude Model

Not sure / Multiple models

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.0.75 (I checked both the bundled version in the python sdk and 2.0.75, no difference)

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Other

Additional Information

_No response_

View original on GitHub ↗

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