fix: prevent user echo and duplicate snapshots in message:stream#73
Merged
liujuanjuan1984 merged 6 commits intomainfrom Feb 14, 2026
Merged
fix: prevent user echo and duplicate snapshots in message:stream#73liujuanjuan1984 merged 6 commits intomainfrom
liujuanjuan1984 merged 6 commits intomainfrom
Conversation
5 tasks
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.
模块变更
流通道架构 (Channeling)
reasoning、tool_call、final_answer。final_answer沿用原本的task_id:stream作为 artifact id,其余通道附带:<channel>后缀进行隔离。artifact.metadata.opencode元数据,包含 channel、source、event_type、message_id 和 role。回显过滤与状态管理
ROLE_USER、ROLE_SYSTEM等变体)。_StreamOutputState状态机,专门用于聚合、追踪流内已产生的文本块。去重与幂等闭环
execute的收尾阶段,如果流式处理已经输出了等价的final_answer,则不再补发末尾的全量快照 (final snapshot)。send_message返回了有效内容时,才补发一次 final snapshot 以兜底。并发安全
session_id级别的asyncio.Lock,确保同一会话的多次连续请求会排队串行进入send_message阶段,从物理上杜绝交叉并发造成的串流污染。测试用例
tests/test_streaming_output_contract.py契约测试,全面覆盖用户回显、去重快照、多通道分类与会话锁并发场景。关联
Closes #72