feat(chat): stream messages - #43
Merged
Merged
Conversation
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.
feat(chat)/stream-messages,本批次包含b1fdf19、7817336、f8c8378三个提交,覆盖 Agent 流式事件、SSE 传输、聊天时间线展示和对应测试。LangGraphEventAdapter将 LangGraph v2tasks、updates、messages、custom多流转换为稳定的公开事件协议。node_start/node_end,同名节点重复进入时根据 job、attempt 和 task 生成不同的阶段实例,避免重试或循环阶段互相覆盖。route_decision、fold_decision生成progress/decision事件;不根据展示消息内容推断路由。mcp/rag阶段,工具事件只保留工具名、参数字段名和“调用完成/调用失败”摘要,不输出参数值、完整工具结果、原始 Prompt、ToolMessage、文件正文或内部 attempt。custom事件表达真实 attempt 开始/失败;只有失败后确实再次开始时才生成node_retry,最终失败不会被误报为重试。OrderedEventWriter,每个 job 使用一个事件队列和单一消费协程,保证阶段、文字和终态事件按源顺序写入analysis_job_events。text_delta刷新;切换文字流、阶段结束、重试和终态事件前先刷新未落库文字。stream_id和数据库序号,重试时只废弃失败流,不影响新流;终态继续沿用当前 worker/attempt fencing 和聊天保存事务边界。Last-Event-ID断线续传;发送给普通用户前移除内部attempt字段。POST /api/agent/jobs创建任务,再通过GET /api/agent/jobs/<job_id>/events建立 EventSource;支持节点开始、阶段详情、工具摘要、重试、文字增量、终态、失败和重连状态。stream_state.js按数据库事件 ID 去重,并按step_id + stream_id + sequence去重文字批次;普通文字使用草稿节点流式渲染,终态到达后校正草稿,报告和因果图结果仍只渲染一次。20pxflex 间距在“已处理”入口和第一个阶段之间产生的额外空白;点击父级展开符号后滚动到聊天末端,并在布局更新后再次校正。tests/unit/agent/test_stream_events.py覆盖阶段实例、公开文字节点过滤、重试语义、显式 State 路由、工具字段脱敏、SSE 公开 payload 以及真实 LangGraph v2 tasks/custom 流。tests/unit/agent/test_ordered_event_writer.py覆盖 150ms 刷新、384 字符阈值、阶段/终态前刷新、流独立序号和事件顺序。tests/unit/frontend/chat_stream_state.test.cjs覆盖 SSE ID 去重、文字批次去重、失败流丢弃和终态草稿校正。AGENTS.md已同步更新 worker 多流协议、用户可见事件边界和敏感内容过滤说明。script.jsNode 语法检查、前端 4 项单元测试和git diff --check;后端测试应在仓库要求的 Docker 测试环境中继续执行,以补足真实依赖链验证。analysis_job_events已保存任务事件,可供 SSE 断线续传和管理员任务详情读取;但/api/load_session当前只恢复chat_messages,前端刷新或重新打开历史会话时尚未按session_id -> analysis_jobs -> analysis_job_events重建聊天时间线,因此思考阶段会消失。该问题属于历史时间线恢复功能,尚未在本批次实现。