mirror of
https://github.com/justlovemaki/AIClient-2-API.git
synced 2026-04-26 18:05:48 +03:00
[GH-ISSUE #328] [Bug] Claude Code -> Codex 的会话缓存隔离与跨模型缓存命中问题 #237
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/AIClient-2-API-justlovemaki#237
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ylqgithubylq on GitHub (Feb 14, 2026).
Original GitHub issue: https://github.com/justlovemaki/AIClient-2-API/issues/328
(我有几个使用上的疑问,所以让让ai分析了代码,然后让ai生成的如下内容,不一定对,供参考)
简版总结
当前
Claude Code -> openai-codex-oauth路径存在两类问题:Claude -> Codex转换未透传metadata.user_id,导致缓存键退化为model-default,不同会话可能共享缓存会话。model,同一会话切换模型时会生成新缓存键,缓存命中中断。metadata透传给上游 Codex 请求,建议仅本地使用后剥离。当前 commit:a6778ce66d2d70d50c2339e876bf9f47cd0baed8
背景
本项目在
openai-codex-oauth下,会为每次请求生成并复用prompt_cache_key,并写入Conversation_id/Session_id。问题出在缓存键构造所依赖的会话字段在不同转换路径中的保留不一致。
影响范围
metadata透传上游,存在不必要字段外发。实际行为(代码定位)
1)
Claude -> Codex未透传metadatasrc/converters/strategies/ClaudeConverter.js:18662) 缓存键依赖
model + metadata.user_id,缺失时回退defaultsrc/providers/openai/codex-core.js:3043)
prompt_cache_key作为会话头发送src/providers/openai/codex-core.js:320src/providers/openai/codex-core.js:285src/providers/openai/codex-core.js:2864) 模型可能在链路中被映射(影响缓存键稳定性)
src/utils/common.js:853src/utils/common.js:8765) 其他转换路径会保留
metadata,并可能透传上游src/converters/strategies/CodexConverter.js:85src/providers/openai/codex-core.js:317复现建议
MODEL_PROVIDER=openai-codex-oauth。metadata.user_id回退default。期望行为
metadata若仅用于本地缓存,应避免透传上游。建议修复
codex-core中提取metadata.user_id仅用于本地缓存键,发送前移除metadata。default造成共享)。model作为缓存键组成:@ylqgithubylq commented on GitHub (Feb 15, 2026):
看到作者更新了,扫了一眼代码,对这一部分的改动存疑:
src\providers\openai\codex-core.js的prepareRequestBody里:
这个else里是不是不应该再有model被拼进去了?
@justlovemaki commented on GitHub (Feb 20, 2026):
为什么呢?
@ylqgithubylq commented on GitHub (Feb 20, 2026):
因为一个对话内部会切换model吧,如果这个model的含义是用户指定的model的话(比如第一个问题用gpt 5.3 codex,ai回复后切换到gpt 5.2继续对话这种)。不过我不确定是不是这个机制,如果不是的话那就是我理解错了。