Contact Information
No response
MaxKB Version
v2.8.1
Problem Description
简易智能体在发布后的对话页面中,如果用户发送问题后,在 AI 流式回答过程中刷新浏览器页面,当前这轮问答记录会丢失。
具体表现:
- 刷新后左侧历史会话中可以看到刚才创建的会话;
- 但进入该会话后,右侧没有刚才的问题和 AI 回答内容;
- 等待很久后再次刷新或重新进入该会话,内容也不会恢复;
- 高级智能体同样操作表现正常。
Steps to Reproduce
- 创建并发布一个简易智能体。
- 打开发布后的智能体对话页面。
- 发送一个问题,并等待 AI 开始流式回答。
- 在 AI 回答过程中刷新浏览器页面。
- 刷新完成后查看左侧历史会话和右侧对话内容。
- 等待一段时间后再次刷新或重新进入该会话。
The expected correct result
No response
Related log output
Additional Information
可能原因:
简易智能体流式回答的持久化时机过晚,目前是在流式输出完整结束后才调用 post_response_handler.handler(...) 写入 ChatRecord。浏览器刷新会中断当前 StreamingHttpResponse/SSE 连接,导致保存逻辑没有执行。
相关代码链路:
ChatSerializers.chat_simple() 中调用 chat_info.set_chat(message),只会创建 Chat 会话;
BaseChatStep.execute_stream() 返回 StreamingHttpResponse;
event_content() 中只有在 for chunk in response 正常结束后,才会调用 post_response_handler.handler(...);
post_response_handler.handler(...) 里才会构造 ChatRecord 并调用 chat_info.append_chat_record(...);
append_chat_record(...) 中才会通过 QuerySet(ChatRecord).update_or_create(...) 持久化问答记录。
Contact Information
No response
MaxKB Version
v2.8.1
Problem Description
简易智能体在发布后的对话页面中,如果用户发送问题后,在 AI 流式回答过程中刷新浏览器页面,当前这轮问答记录会丢失。
具体表现:
Steps to Reproduce
The expected correct result
No response
Related log output
Additional Information
可能原因:
简易智能体流式回答的持久化时机过晚,目前是在流式输出完整结束后才调用
post_response_handler.handler(...)写入ChatRecord。浏览器刷新会中断当前 StreamingHttpResponse/SSE 连接,导致保存逻辑没有执行。相关代码链路:
ChatSerializers.chat_simple()中调用chat_info.set_chat(message),只会创建Chat会话;BaseChatStep.execute_stream()返回StreamingHttpResponse;event_content()中只有在for chunk in response正常结束后,才会调用post_response_handler.handler(...);post_response_handler.handler(...)里才会构造ChatRecord并调用chat_info.append_chat_record(...);append_chat_record(...)中才会通过QuerySet(ChatRecord).update_or_create(...)持久化问答记录。