anthropics / anthropics/claude-agent-sdk-python

20-70% of concurrently ran chats fail to provide usage data and StreamEvents

未關閉
#435 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
bug
主要語言
Python
星號
8.1k
分支
1.3k
平均合併
2 天 31 分鐘
30 天內合併 PR
1

描述

## Minimal example

This is a small script that spawns 10 chats and monitors their output.

`https://github.com/MarvellousBee/claude_agent_sdk_bug_report`

## Expected behavior

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
```

## Actual behavior
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
```

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。