Sonnet 5.5 / Opus 5.5: streamed text after a tool_result arrives in one burst at the end of the turn
还没有人认领这个 Issue。
评估
调研方向
Start with the messages.stream event handling and tests for content_block_delta in this SDK, then compare the captured event timings for Sonnet 5.5 and Sonnet 5. The reproduction script and request IDs are provided in the issue. Done means determining whether the SDK changes or delays these events and documenting or fixing the behavior supported by the evidence.
由索引模型根据 Issue 内容生成。
描述
Summary
With claude-sonnet-5-5 (and claude-opus-5-5), when a turn follows a tool_result, all of its text_delta events arrive within a few milliseconds of each other at the end of the turn. They are not streamed while the text is generated. The same turn on claude-sonnet-5 streams normally, and so does Sonnet 5.5 when no tool result precedes the turn. For a chat interface this means several seconds of blank screen before every answer that uses a tool.
We couldn't find a setting in the docs that changes this. Anthropic's support chat could neither confirm whether it is intended nor pass it on, so we're raising it here. If this repo is the wrong place for API behaviour, please point us to the right one.
Environment
anthropicPython SDK 1.8.0, Python 3.12, macOSmessages.streamwith one client tool,output_config.effort: "medium", adaptive thinking (the default)
Measurements
Timings are from the request start to each text_delta, for a ~150-word answer:
| Request | Text deltas | First text | First to last |
|---|---|---|---|
| Sonnet 5.5, no tools in the request | 120 | 0.93 s | 4.1 s |
| Sonnet 5.5, tools present, answered without a tool | 80 | 1.03 s | 2.7 s |
Sonnet 5.5, turn after a tool_result |
78-105 | 3.2-4.3 s | 3-6 ms |
... with thinking.display: "updates" (beta) |
95 | 3.8 s | 5 ms |
... with thinking: {type: "between_tools"} |
86 | 3.8 s | 6 ms |
... with tool_choice: {type: "none"} |
88 | 5.6 s | 6 ms |
... through beta.messages.tool_runner(..., stream=True) |
107 | 6.3 s | 5 ms |
Opus 5.5, turn after a tool_result |
65 | 5.2 s | 5 ms |
Sonnet 5, turn after a tool_result |
71-83 | 0.47-0.72 s | 3.5-4.1 s |
Request IDs (26 Nov 2026, about 13:12 UTC; same prompt, tool and tool result):
- Sonnet 5.5, burst: answer turn
req_011ChRbaHRkLM7bHj6jPWq36(78 deltas, first at 3.21 s, all within 5 ms); tool turnreq_011ChRbaEF1ZaodZwXc15MKu. - Sonnet 5, streams: answer turn
req_011ChRbaaj4ibt2FetmyJ9iG(71 deltas, first at 0.72 s, spread over 3.54 s); tool turnreq_011ChRbaXFhozQVeET8t265a.
Our guess is that the API holds post-tool text until it knows whether the text is a progress update (returned as a thinking block on these models) or the final answer. If so, it would be useful to stream the text once that is decided, or to have a request setting for interfaces where a person watches the answer arrive.
Reproduction
import json, time, anthropic
c = anthropic.Anthropic()
tools = [{"name": "get_rate", "description": "Induction of labour rate for an NHS trust.",
"input_schema": {"type": "object", "properties": {"trust": {"type": "string"}}, "required": ["trust"]}}]
Q = "What is Southampton's induction of labour rate? Use the tool, then explain it in about 150 words."
def run(model, msgs):
t0, marks = time.monotonic(), []
with c.messages.stream(model=model, max_tokens=4000, output_config={"effort": "medium"},
tools=tools, messages=msgs) as s:
for ev in s:
if ev.type == "content_block_delta" and ev.delta.type == "text_delta":
marks.append(round((time.monotonic() - t0) * 1000))
return s.get_final_message(), marks
for model in ("claude-sonnet-5-5", "claude-sonnet-5"):
msgs = [{"role": "user", "content": Q}]
m, _ = run(model, msgs)
tu = next(b for b in m.content if b.type == "tool_use")
msgs += [{"role": "assistant", "content": m.content},
{"role": "user", "content": [{"type": "tool_result", "tool_use_id": tu.id,
"content": json.dumps({"rate": 25.8, "births": 5550})}]}]
m2, marks = run(model, msgs)
print(model, "deltas", len(marks), "first_ms", marks[0], "spread_ms", marks[-1] - marks[0])
Expected: the deltas on the answer turn are spread over the generation time (as on claude-sonnet-5).
Actual on claude-sonnet-5-5: the spread is about 5 ms, at the end of the turn.
Questions
- Is this intended on Sonnet 5.5 and Opus 5.5?
- Is a setting planned, or available, that streams the final answer's text as it is generated after a tool call?
- 主要语言
- Python
- 星标
- 4.1k
- 派生
- 915
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
anthropics/anthropic-sdk-python 的其他 Issue
-
beta_tool validation errors reach the model as "Invalid arguments for function X" with no detail可能已有人在做 @mangeshraut712 于 32 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
anthropics/anthropic-sdk-python#2033 · 3 条评论 ·
-
`AnthropicBedrock` 2.x sends `anthropic_version: 2026-10-21`, which Bedrock rejects for Claude Sonnet 4.5, Opus 4.5 and Opus 4.6可能已有人在做 @charan-rathore 于 36 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 70/100
anthropics/anthropic-sdk-python#2031 · 1 条评论 ·
-
Three symlink tests in test_agent_toolset.py are missing the needs_symlinks marker可能已有人在做 @okxint 于 82 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 92/100
anthropics/anthropic-sdk-python#1915 · 3 条评论 ·
-
Messages.parse (and AsyncMessages.parse) don't take cache_control?可能已有人在做 @AlphaFDE 于 86 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
anthropics/anthropic-sdk-python#1907 · 2 条评论 ·
-
Windows: os.fchmod in credential write-back bricks the OAuth refresh token可能已有人在做 @OllieinCanada 于 99 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
anthropics/anthropic-sdk-python#1868 · 1 条评论 ·
查看 anthropics/anthropic-sdk-python 的全部 Issue
相似的 Issue
-
bug harness
难度 2/5 1-3 小时 新手友好度 72/100
mruangutai/harness#2687 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
modal-labs/modal-client#4158 ·
-
good first issue
难度 1/5 1 小时以内 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 半天 新手友好度 72/100
The-Swarm-Corporation/swarms-rs#168 ·
维护者通常 1 天内回复
-
[BUG] SMTP listener now binds to EMAIL_PORT instead of 2525 since the gunicorn switch 5.0.3-ls373未关闭
难度 2/5 1-3 小时 新手友好度 72/100
linuxserver/docker-healthchecks#137 · 1 条评论 ·