Repository navigation
fix(relay): Claude 准备和重试期间持续保活(#191) - #199
Merged
Merged
Conversation
Port upstream 25372e3 (QuantumNous#7857) while retaining fork request routing, redirect controls and stream write budgets. Closes #191
This was referenced Nov 5, 2026
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.
本变更由 Codex AI 辅助生成,已完成作者自检;独立人工审查待进行。
🔗 关联任务 / Related Issue
Closes #191
上游提交: QuantumNous@25372e3 (QuantumNous#7857)
🚀 变更类型 / Type of change
📝 变更描述 / Description
Claude 流式请求从图片准备阶段开始保活,跨上游重试复用心跳;写入业务数据或 scanner 接管前停止并等待心跳退出。心跳提交响应头后的最终错误以 SSE 返回,并标记失败;快速失败仍保留原 HTTP 状态与 JSON 响应。
仅手工移植指定上游提交的六个文件。api_request.go 保留 fork 的重定向控制、请求体重放、上下文与任务请求路径;沿用 StreamWriteBudget,不恢复上游旧版固定写入 deadline。OAuth 路由校验、日志脱敏、会话新鲜度和依赖文件未修改。
将凭据路由后的既有处理主体提取为包内 relayRequest,供定向回归测试调用;公开 Relay 的凭据校验保留。测试使用隔离 SQLite 准入数据,未改变生产数据库行为。仅新增一个回归文件。
📸 运行证明 / Proof of Work
环境:Go 1.27.2 linux/amd64;以下命令均设置
GOMAXPROCS=2 RAYON_NUM_THREADS=2 GOWORK=off。结果:两组测试的三个包全部通过,竞态检测无报告,diff 检查通过。覆盖准备期连续心跳、重试、快速失败、流式失败结果、取消、响应头交接,以及 fork HTTP/2 重放和写入预算。
负向验证:临时移除控制器提前保活块后,
go test -p=2 -parallel=1 -timeout=30s ./controller -count=1 -run '^TestRelayKeepAliveDuringImagePreparation$'按预期因等待响应头超时失败;原始字节恢复后同一用例通过。初次上游测试因缺少 fork 凭据/准入 fixture 失败,已适配,未弱化断言。范围限制:没有运行全矩阵、真实外部 Claude、OAuth 集成或部署验证;本次不改变数据库行为或独立模块。
✅ 提交前检查项 / Checklist