Repository navigation
feat: 增加 OpenAI 旧版兼容模式 - #934
Merged
ranxi2001 merged 7 commits intoNov 18, 2026
Merged
Conversation
2 tasks done
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.
解决的问题与行为变化
开启 owner-binding opt-out 后,请求仍会冻结完整 input,后续工具、元数据或压缩兼容转换可能触发本地
encrypted_agent_recovery_wire_changed。新增默认关闭的gateway.openai_legacy_compatibility_mode(环境变量GATEWAY_OPENAI_LEGACY_COMPATIBILITY_MODE),供管理员显式选择普通转发与账号池策略。开启后,HTTP、三种 WS 模式、后续轮和原生压缩不建立新增的 agent 恢复上下文,不运行它的归属、input/controls 冻结及 no-replay 限制;兼容模式优先于 owner opt-out、400/409 历史省略、shadow 恢复和有损重启。普通鉴权、准入、额度、计费、取消及 HTTP 用户/Key response 指针所属校验保留。生图旧参数重编码改用 JSON Number 解码,避免损坏大整数。
本次实现 #914 接受的兼容方案,严格模式的 17 类转换冲突不在本 PR 逐项修复;真实供应商密文兼容及原客户端任务恢复仍需独立验收。
关联记录与来源
production/338f73dfa31032972d8860adab9c25016115c18d;已读取该分支贡献指南和 PR 模板。无外部 cherry-pick。合并前核对 production 已推进至a71bcd6238777630bb74f18106097689ce7a5836(v2.23.0 版本号及账号余额通知功能),与本 PR 无重叠文件;git merge-tree --write-tree HEAD origin/production无冲突。管理员新功能提示
NewFeatureBadge:不适用,本次只有进程启动配置和部署文档,没有后台设置页面或 UI 入口。复现与验收
backend/internal/{config,service,handler}/*issue914*test.go。尚未与 v2.20.0 官方运行产物进行完整同输入对照,也未复跑 issue 作者的私有采集。协议、调度或传输改动补充
/v1/responses;OAuth/API-key;HTTP JSON/SSE、WS 三种模式和原生压缩。agent_message+ user message,添加internal_chat_message_metadata_passthrough,或带工具 schema、历史配对、压缩项;测试源码保留完整夹具。实际验证
git diff --cached --checkgofmt -w本次修改的 Go 文件backend:go test -tags=unit ./internal/config ./internal/service ./internal/handler -run '^TestIssue914' -count=1 -timeout=5mbash -n .github/scripts/prepare-ws-owner-red-fixtures.sh32f8f4bda7f8a749aa10be4281d2cf538a3641a1CIpython3 -B -m unittest discover -s .github/scripts -p 'test_assert_ws_readable.py' -vpython3 -B -m unittest discover -s .github/ci -p 'test_*.py' -v94bb4a53/backend:go test -gcflags=-e -json -tags=unit ./internal/service -run '^TestOpenAI409WSTicketBoundEgress$' -count=1 -timeout=5m,随后assert-ws-readable.py RED 1 ... ws-ticket兼容性与运行影响
false,YAML/环境变量与四套 Compose 模板同步;无请求级覆盖。启用时恢复设置保存值不变,但新增恢复逻辑不执行。文档与用户可见变化
新增
docs/openai-legacy-compatibility.md,说明开关、覆盖范围、恢复选项优先级、残余边界和回滚;两份现有历史恢复文档加入入口。无 UI 改动,无截图适用项。为修复实际 CI 失败,补齐完整历史源码对照的独立测试版本清单,并将 CI 单元测试单包超时显式设为 20 分钟;保留全部测试和 job 的 40 分钟上限。Agent 使用声明
提交前自查