fix: 修复缓存统计和 WebSearch 转换#392
Merged
icebear0828 merged 2 commits intoicebear0828:masterfrom Apr 17, 2026
Merged
Conversation
修复 Claude / Anthropic 请求经过 Codex proxy 时的缓存统计问题,并补齐 hosted WebSearch 工具到 Codex web_search 的转换。 - 补齐 Anthropic 响应中的缓存创建用量字段 - 使用请求内容派生稳定的 prompt_cache_key - 加强 session affinity 和 previous_response 续链稳定性 - 支持 OpenAI、Anthropic、Gemini 与 Claude Code WebSearch 的 hosted web_search 转换 - 增加缓存统计、稳定会话 key、隐式续链和工具转换相关单测
Collaborator
|
审查结论:目前 不建议直接合并,我这边看到了 2 个需要先处理的问题。
其他方面:
|
Contributor
Author
|
已按 review 意见追加修复,提交: 处理内容:
验证: npx vitest run tests/unit/translation/tool-format.test.ts tests/unit/translation/anthropic-to-codex.test.ts tests/unit/routes/upstream-auth-bypass.test.ts
# 3 个测试文件通过,103 个测试通过
npx tsc --noEmit
# 通过
npm run build
# 通过另外我也跑了默认测试集: npm test结果是业务相关测试通过,但 Electron 打包相关有 3 个既有资源失败,原因是当前 PR worktree 根目录没有
我没有在这个修复里补无关打包资源目录,避免把 review 修复范围扩大。 |
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.
说明
这个 PR 主要修复两个问题:
web_search工具。这部分修改是我通过 AI 辅助整理和实现的。我已经在自己的分支上连续测试了几天,目前缓存统计和 WebSearch 使用都没有发现问题。
主要修改
cache_creation_input_tokens等统计缺失的问题。prompt_cache_key,提升 prompt cache 命中稳定性。web_search_preview-> Codexweb_searchweb_searchgoogleSearch-> Codexweb_searchWebSearch-> Codex hostedweb_searchweb_searchfunction tool 的语义,避免误判为 hosted web search。验证情况
我已经在自己的分支上连续测试了几天,重点验证了:
自动化测试
已通过:
结果:
也已通过: