fix: multi-turn conversation session reuse across providers (closes #86)#87
Open
bennylii wants to merge 2 commits intoxiaoY233:mainfrom
Open
fix: multi-turn conversation session reuse across providers (closes #86)#87bennylii wants to merge 2 commits intoxiaoY233:mainfrom
bennylii wants to merge 2 commits intoxiaoY233:mainfrom
Conversation
Contributor
Author
|
好了 |
Add providerSessionId, parentMessageId, historyHash to SessionRecord. Add providerSessionId, parentMessageId to ChatCompletionRequest. Sync renderer-side SessionRecord types. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Previously, every chat request created a new upstream session because providerSessionId (populated by each adapter) was never consumed by the session manager or routes. This broke multi-turn conversation for all providers. Changes: - sessionManager: add computeHistoryHash, 3-tier session lookup (hash match → active session → new), and updateProviderSession method - DeepSeek/Kimi/QwenAI adapters: accept and reuse existing session IDs instead of always creating new upstream sessions - forwarder: pass providerSessionId/parentMessageId to adapter calls - routes/chat: integrate sessionManager into request flow — create sessions before forwarding, update after response - Tests: 27 unit tests covering hash computation, session lifecycle, and multi-turn flow simulation Closes xiaoY233#86 Co-Authored-By: deepseek-v4-pro <noreply@deepseek.com>
e5eb9a0 to
9b9887d
Compare
Contributor
Author
需要人工测试
请先不要合并 |
leisvip
added a commit
to leisvip/Chat2API
that referenced
this pull request
May 3, 2026
Merged PRs from xiaoY233/Chat2API: - xiaoY233#74: DeepSeek V4 Pro/Flash model support - xiaoY233#92: Credential encryption toggle - xiaoY233#93: Kimi K2.6 upgrade - xiaoY233#84: Account weight-based load balancing - xiaoY233#83: Qwen silent content drop fix - xiaoY233#85: data.json performance optimization (log buffering) - xiaoY233#87: Multi-turn conversation session reuse - xiaoY233#77: Settings page draft mode with save button - xiaoY233#106: Qwen context loss fix (messagesToPrompt)
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
修复所有 provider 上多轮对话不可用的问题。Closes #86
根因: 每个 adapter 正确获取了
providerSessionId,但sessionManager和routes/chat.ts从未消费它 —— 每次请求都创建全新的上游会话。改动
store/types.ts,proxy/types.tsproviderSessionId,parentMessageId,historyHashsessionManager.tscomputeHistoryHash(), 3 级会话查找 (hash → active → new),updateProviderSession()deepseek.ts,kimi.ts,qwen-ai.tsforwarder.tsproviderSessionId/parentMessageId给 adapterroutes/chat.tstests/session-manager.test.ts测试
单元测试通过:
以下场景需要在真实环境中手动验证:
sessionTimeout分钟内无活动后,下次请求创建新会话🤖 Generated with Claude Code
Co-Authored-By: deepseek-v4-pro noreply@deepseek.com