Repository navigation
fix: 隐藏 Responses 回程中的历史恢复技术标记 - #1138
Merged
Merged
Conversation
(cherry picked from commit a7e4309)
Owner
Author
|
固定
|
8 of 12 tasks
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.
解决的问题与行为变化
Responses 上游可能把网关的历史恢复标记作为普通文本返回,客户端会直接显示
Historical reasoning context...和[Historical encrypted content omitted by the gateway...]。本 PR 在 HTTP JSON/SSE 与原生 WS 回程移除四个固定标记,保留其周围的实际摘要、回答和工具协议。流式匹配按输出项和文本部分隔离,支持标记跨多个 delta;done/terminal 的重复完整文本也处理。只似前缀而未完整匹配的正常文字在完成前释放。HTTP 展示写入位于既有语义输出/重试判定之后,不新增重放权限。
关联记录与来源
37cf38c70f68c07aa061265622fb52884370f704,先合并 fix: 保留加密恢复的历史摘要并接续可读旧压缩项 #1137,再合并本 PR;不包含 fix: 接续 WS 可恢复认证与完整历史换号(#1126) #1134 的 WS 认证/完整历史换号。production@33ccaf48cba0105de45db42999ed644d2959bd01,无外部提交引入。管理员新功能提示
复现与验收
openai_recovery_notice_display_test.go覆盖每种文本事件的每个分割位置、交错项、未完成相似前缀、sequence_number、JSON 字段边界、逐字节 SSE 写入、原生/透传 HTTP 流处理与真实 localhost WebSocket adapter。协议、调度或传输补充
只改 assistant output_text / reasoning 可读 summary/content 的指定固定文本。工具参数/结果、密文、错误消息/状态、usage、ID及未知输出项不改。请求内容、恢复开关、owner/交付校验、额度、重试预算保持现有行为。流式最多追踪128个文本部分,单SSE事件缓冲约1MiB,超限优先保留原数据。必要的补充 delta 在 done/terminal 之前发出,可用 sequence_number 维持单调。
展示层去掉标记不等于生成完成或上下文无损。需要补充信息的正常回答及真实失败照常可见。没有新上游调用、计费或账号切换。错误事件保留原有独立事件头写入边界,避免写失败时把未知502归成正文400;新增对应断线回归。
实际验证
最终候选
ed756f9f9c1ea374bd8bf787ee349a23da620f65:44个工作流、121项检查全部结束,结果 {'success': 109, 'skipped': 12},无失败、取消或待执行。Security Scan;Issue 917 initial SSE cooldown;Recovery notice display;Priority observation regression;CI。已核对当前 production 中 #1134 的 WS 恢复与本 PR 展示过滤整合无冲突,#1137 依赖已合并。下文旧头失败/待运行记录保留为历史,不代表当前状态。ed756f9f9当前头定向检查:在/Users/onefly/Desktop/project/sub2api-pr1138-merge-dec02/backend执行GOMAXPROCS=2 GOTOOLCHAIN=go1.27.4 go test -p 2 -race -tags=unit,recoverydisplay ./internal/service ./internal/handler -run '^Test(OpenAIRecoveryDisplay|OpenAIStreamingPassthrough|OpenAIResponseFlush_|OpenAIGatewayHandlerResponsesPassthroughKeepaliveFailoverAcrossAttempts)' -count=1 -timeout=5m,退出0,service 12.824s、handler 5.771s。覆盖本次心跳边界与既有数据行/空行断线、usage 排空、显示过滤;只使用隔离虚构输入。当前候选
bce3d3eebf2a92c74a87da00bb5712f63e18d794:上一提交 bce3d3e 的 Priority observation / seams 发现 keepalive 物理写入被拆分,原心跳通知夹具超时。当前修复仅让无 data 的 SSE 心跳保持整块写入,数据行仍保留逐行断线边界;复用原 handler 心跳换号回归,未放宽断言。当前头定向复查已通过,完整 CI 待完成,下列较早头结果仅保留历史证据。本次定向复查:目录
/Users/onefly/Desktop/project/sub2api-pr1138-merge-dec02/backend,命令GOMAXPROCS=2 GOTOOLCHAIN=go1.27.4 go test -p 2 -race -tags=unit,recoverydisplay ./internal/service -run '^Test(OpenAIRecoveryDisplay|OpenAIStreamingPassthrough|OpenAIResponseFlush_)' -count=1 -timeout=5m,退出 0,9.798s。虚构 HTTP/WS 输入;覆盖 display、逐行断线、usage 排空与刷新,未请求生产或真实供应商。2026-12-02 合并跟进:已读取
30c2d4aa4的 Issue917 失败日志,显示过滤器合并 SSE 行写入后,空行断线与终态用量排空回归失败。追加bce3d3eebf2a92c74a87da00bb5712f63e18d794,仅在透传路径保留逐行物理写入;继续复用既有断线、刷新和 usage 回归,未放宽断言。当前头完整 CI 待结果;本机针对已失败 CI 的定向复查已通过,旧头通过项不代替本头。git diff --checkgofmt -wbackend:`GOMAXPROCS=2 GOTOOLCHAIN=go1.27.4 go test -p 2 -race -tags=unit,recoverydisplay ./internal/service -run '^Test(OpenAIRecoveryDisplaybackend:GOMAXPROCS=2 GOTOOLCHAIN=go1.27.4 go test -p 2 -race -tags=unit,issue1085 ./internal/handler -run '^TestIssue1085DeliveryMiddleware$' -count=1 -timeout=5mbackend:`GOMAXPROCS=2 GOTOOLCHAIN=go1.27.4 go test -p 2 -race -tags=unit,recoverydisplay,issue1085 ./internal/service ./internal/handler -run '^Test(OpenAIRecoveryDisplay30c2d4aa436a4fcd87aff161c8c4ec0eb75218a6;局部通过不替代完整 CICI 发现已有峰时测试在 init 中改写 time.Local 与计时器并发读的竞态。仅将测试夹具改为使用当前配置时区、显式构造其他时区同一时刻;保留跨边界断言,不修改生产时区或计价。峰时计费测试改用配置时区,SQLite 租约夹具统一 UTC;洛杉矶定向 race 4.462s、上海定向 race 6.178s 通过。
补充CI失败定位:上海时区下支付/租约/计费定向race组通过(9.999s),命令为
GOMAXPROCS=2 GOTOOLCHAIN=go1.27.4 TZ=Asia/Shanghai go test -p 2 -race -tags=unit ./internal/service -run '^Test(Payment|RetryFulfillment|AlreadyProcessed|ExecuteSubscription|ExecuteBalance|FulfillmentLease|GatewayServiceRecordUsage|OpenAIGatewayServiceRecordUsage|ModelBillingGroupGenericRecordUsage)' -count=1 -timeout=5m,目录backend。不代表所有本地测试已执行。兼容性与运行影响
文档与用户可见变化
docs/recovery-notice-display.md列出精确匹配、支持协议、限制和回滚。后台诊断不因展示清理而删除。无前端组件改动;以真实协议夹具作为验收,不提供手写 UI 截图。合并不代表上线。Agent 使用声明
本次追加修复及合并核对:Codex,环境标识 GPT-6,具体变体与推理配置未知;范围为原始 CI 日志、透传写入修复、既有回归复查与正文更新,无子 Agent。
Codex:链路分析、实现、回归和说明;humanizer-cs:说明文字核对。无子 Agent。
模型:GPT-6;会话未暴露更具体型号 ID。
推理强度:未知,工具未提供可验证配置。
提交前自查