流式输出(TALOS_STREAM=1,默认关):转圈那一行报模型在写什么、写了多少 - #3
Merged
Merged
Conversation
原来一次调用要么整份回来、要么什么都没有。单次 16s 到 235s 都有,屏幕上只有转圈和
每 30 秒一句「已等 Ns」,分不出慢和卡死,活着的调用被 Ctrl-C 掉过好几次。
开了之后,主循环那一次调用(子 agent 也走这里)边生成边收,转圈上显示
「模型在写 write_file(src\app.py) · 12,000 字」「在思考 · N 字」「在写回复 · N 字」;
老 Windows 控制台不开转圈,同一句进心跳那一行。最终回答照旧收完再出 Markdown 面板,
不逐字打 —— 边打边渲染要反复重绘,仓库记过那在老控制台上不可靠。
· _collect 把流拼回跟整份返回同一个形状(content / tool_calls / reasoning_content /
usage),下游一行没改。判据直接比下游结果:同一轮流式、整份各跑一遍,
返回值、历史、token 账逐项相同
· 工具调用按各家的拆法拼:有 index 按 index;Gemini 3 不给 index,按 id 分,
thought_signature 跟着 extra_content 留下;每片重复同一个 id 的还是一个调用;
没给 id 的补一个(None 发回去下一轮 400)
· 用量靠 include_usage 要:OpenAI / DeepSeek 在最后一块上,Kimi 在 choices[0] 里,
是 SDK 不认识的原样 dict
· 拼在 _chat 的重试里面:断流跟掉线同一套认法,整次重来,半截不带过来;
Ctrl-C 打断也关连接
· 进度里的 path 从 JSON 参数里抠,认转义(Windows 路径)、转义后才进 rich
· 判断器、压缩摘要、复盘不流 —— 看不见的地方流了也没用
· conftest 把 STREAM 钉成关:开着它的终端里跑 pytest 不会无关地红一片
用真 openai SDK + httpx.MockTransport 喂各家形状的 SSE 核对过:OpenAI 拆片、
Gemini 无 index 带签名、Kimi 思考 + choices 里的用量、流中途的 error 事件、断连。
手上没有 key,没真调用过 —— 所以默认关。
343 判据:341 过、5 skip、1 xfail(原有);TALOS_STREAM=1 下全套同样绿。
selfcheck 绿。
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014gdkHx6rLSMVsUmQiErVSn
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
为什么
原来一次调用要么整份回来、要么什么都没有。单次 16s 到 235s 都有,屏幕上只有转圈和每 30 秒一句「已等 Ns」,分不出慢和卡死,活着的调用被 Ctrl-C 掉过好几次。
开了之后看到什么
主循环那一次调用(子 agent 也走这里)边生成边收,转圈上实时显示:
模型在思考 · 3,400 字模型在写回复 · 1,240 字模型在写 write_file(src\app.py) · 12,000 字老 Windows 控制台不开转圈,同一句进每 30 秒那行心跳。最终回答照旧收完再出 Markdown 面板,不逐字打 —— 边打边渲染要反复重绘,仓库记过那在老控制台上不可靠。
怎么做的
_collect把流拼回跟整份返回同一个形状(content / tool_calls / reasoning_content / usage),下游一行没改index按 index;Gemini 3 不给 index,按 id 分,thought_signature跟着extra_content留下;每片重复同一个 id 的还是一个调用;没给 id 的补一个stream_options.include_usage要:OpenAI / DeepSeek 在最后一块上,Kimi 在choices[0].usage里_chat的重试里面:断流跟掉线同一套认法,整次重来,半截不带过来;Ctrl-C 也关连接conftest把STREAM钉成关,开着它的终端里跑 pytest 不会无关地红一片判据(6 条新的,都先看它红)
console_ui.progress进心跳行、模型给的 path 转义后才进 rich验证
TALOS_STREAM=1下全套同样绿httpx.MockTransport喂各家形状的 SSE 核对过:OpenAI 拆片、Gemini 无 index 带签名、Kimi 思考 + choices 里的用量、流中途的 error 事件、断连set TALOS_STREAM=1再跑平时的任务tool_stream=True时工具参数是一整块到的,所以 GLM 上写大文件时字数不会一点点涨(回复和思考照样涨);stream_optionsGLM 认不认没核对到🤖 Generated with Claude Code
https://claude.ai/code/session_014gdkHx6rLSMVsUmQiErVSn
Generated by Claude Code