fix: 用后端 sessionId 作为 threadId 修复多轮对话不工作的问题 (#535)#536
Open
zxz0415 wants to merge 3 commits into
Open
Conversation
…rsations Previously, threadId was managed by the frontend in-memory sessionState, causing each browser tab to generate a different threadId. Multi-turn context was effectively broken across tabs. Now the backend sessionId (from ChatSession) is used as the threadId, making the backend the source of truth. Same session = same threadId, regardless of browser tab.
1431819 to
c42e319
Compare
Collaborator
|
有修复前,修复后的展示截图吗? |
Author
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.





Summary
Fixes #535
Root Cause
多轮对话上下文
multi_turn始终为空。threadId由前端内存中的sessionState.lastRequest?.threadId管理,每个浏览器标签页拥有独立的 Vue ref 实例,导致同一 session 在不同标签页中 threadId 不一致。后端收到的 threadId 要么为 null(新标签页),要么是不同标签页各自缓存的值。Fix
后端已有完整的 ChatSession 体系,将 sessionId 作为多轮对话的唯一标识:
Backend
GraphRequest.java: 加sessionId字段GraphController.java: 接收sessionId参数GraphServiceImpl.java: 如果传了 sessionId,用它覆盖 threadId,保证同一 session 内 threadId 一致Frontend
graph.ts: GraphRequest 接口加sessionId,拼到 URL 参数AgentRun.vue: 发请求时传currentSession.value.idChanges
GraphRequest.javaGraphController.javaGraphServiceImpl.javagraph.tsAgentRun.vueTest
编译通过:
./mvnw compile -pl data-agent-management手动验证: