Skip to content

修复 Qwen 上下文丢失问题#106

Open
fumorn wants to merge 5 commits into
xiaoY233:mainfrom
fumorn:main
Open

修复 Qwen 上下文丢失问题#106
fumorn wants to merge 5 commits into
xiaoY233:mainfrom
fumorn:main

Conversation

@fumorn
Copy link
Copy Markdown

@fumorn fumorn commented May 2, 2026

本次修复内容摘要

  • Qwen 国内版 (qwen.ts):使用 messagesToPrompt() 传递完整对话历史,修正 enableWeb 变量错误
  • Qwen 国际版 (qwen-ai.ts):同样改为传递完整历史,确保多轮对话上下文不丢失

Z.ai上下文暂未完全修复

leisvip and others added 5 commits May 4, 2026 03:06
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)
@xiaoY233
Copy link
Copy Markdown
Owner

@codex review and check it

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4cd8376f6d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +156 to +157
session.providerSessionId = providerSessionId || session.providerSessionId
session.parentMessageId = parentMessageId || session.parentMessageId
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Persist provider session updates in SQLite

When a streamed/non-streamed response returns the provider conversation IDs, this only mutates the object returned by storeManager.getSessionById. With the new SQLite store, getSessionById parses JSON and returns a detached copy, so providerSessionId, parentMessageId, historyHash, and lastActiveAt are never written back via storeManager.updateSession. On the next turn the route reads the old row and sends no provider parent/session IDs, so Qwen multi-turn context is still lost after the first request.

Useful? React with 👍 / 👎.

Comment thread src/main/store/sqlite.ts
await this.migrateFromElectronStore()
}

this.db = new Database(this.dbPath)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Create the storage directory before opening SQLite

On a fresh install where ~/.chat2api does not already exist, new Database(this.dbPath) attempts to create store.db inside a missing parent directory and fails with SQLITE_CANTOPEN, aborting storage initialization before the later request-log manager has a chance to mkdir anything. This only works for users who already have the legacy storage directory, so new users cannot start the app.

Useful? React with 👍 / 👎.

Comment thread src/main/store/sqlite.ts
Comment on lines +177 to +178
const encrypted = safeStorage.encryptString(value)
encryptedCreds[key] = encrypted.toString('base64')
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Do not re-encrypt migrated credentials

During migration, account credential values read from the old data.json are already the per-field safeStorage ciphertext written by the previous addAccount path, but this loop encrypts those ciphertext strings again. After upgrade, getAccounts(true) decrypts only the outer layer and providers receive the old base64 ciphertext instead of the real token, so existing accounts fail authentication until users re-enter every credential.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants