Skip to content

feat: preserve historical images in multi turn conversations - #537

Merged
chenyme merged 1 commit into
devfrom
conversations
Jul 29, 2026
Merged

feat: preserve historical images in multi turn conversations#537
chenyme merged 1 commit into
devfrom
conversations

Conversation

@chenyme

@chenyme chenyme commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

支持在多轮对话中按原始用户消息传递历史图片,使模型能够继续分析、比较或追问此前上传的图片。

  • 将历史用户图片恢复到其原始消息位置,避免图片与消息上下文错位。
  • 保留最近 10 张历史图片,并预留相应的上下文 Token 预算。
  • 历史图片上下文总大小限制为 20 MiB。
  • 图片缺失、读取失败或超过限制时返回明确错误,不再静默忽略。
  • 修复图片缩放后实际编码与 MIME 类型不一致的问题。
  • 增加有界 LRU 缓存,减少历史图片的重复读取和缩放。
  • 保持 OpenAI Responses previous_response_id 的上下文指纹稳定。
  • 不预判模型的视觉能力;不支持图片时保留上游的正常错误行为。

Change type

  • Bug fix
  • Feature
  • Documentation
  • Refactor
  • Configuration / deployment
  • Security hardening
  • Other

Affected areas

  • Frontend / UI
  • Backend / API
  • Authentication / authorization
  • Conversations / streaming
  • Files / RAG / extraction
  • Model routing / providers
  • MCP / tools
  • Billing / payments
  • Admin console
  • Deployment / Docker / configuration
  • Documentation

Verification

  • cd backend && env GOCACHE=/Users/project/DEEIX-Chat/.gocache go test ./...
  • git diff --check

Screenshots, API examples, or logs

Not applicable. This change affects backend conversation context construction.

Configuration, migration, and compatibility notes

  • No database migration or public API change is required.
  • Historical image context retains the most recent 10 images.
  • Prepared historical images are limited to 20 MiB per request.
  • The in-process prepared-image cache is bounded to 64 entries and 64 MiB.
  • Models without image support will continue to return their normal upstream error.

Documentation

  • Documentation is not needed for this change.
  • Documentation was updated.
  • Documentation still needs to be updated.

Security and privacy

  • No secrets, tokens, credentials, local config, or personal data are included.
  • User data access remains scoped by authenticated user context unless an admin-only path explicitly requires broader access.
  • Security-sensitive behavior was reviewed, including file ownership, object storage access, and image context limits.

Checklist

  • I searched existing issues and pull requests.
  • Changes are focused and do not include unrelated refactors.
  • Tests or static verification were run where practical.
  • User-facing behavior, deployment steps, API contracts, or configuration changes are documented.
  • Generated artifacts are included only when this project explicitly requires them.
  • Caches, build output, .pyc files, .env files, and local storage data are not committed.

@chenyme chenyme self-assigned this Jul 29, 2026
@chenyme chenyme linked an issue Jul 29, 2026 that may be closed by this pull request
3 tasks
@chenyme
chenyme merged commit 7edbbb8 into dev Jul 29, 2026
11 checks passed
@chenyme
chenyme deleted the conversations branch July 29, 2026 08:40
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.

[Bug]: 无法同时进行多个对话

1 participant