Skip to content

fix: 剥离 Codex cache_control 并完善 Responses 工具调用展示#625

Merged
fawney19 merged 3 commits into
fawney19:mainfrom
stabey:pr/responses-call-items-cache-control-20260604
Jun 4, 2026
Merged

fix: 剥离 Codex cache_control 并完善 Responses 工具调用展示#625
fawney19 merged 3 commits into
fawney19:mainfrom
stabey:pr/responses-call-items-cache-control-20260604

Conversation

@stabey
Copy link
Copy Markdown
Contributor

@stabey stabey commented Jun 4, 2026

背景

这组改动包含两类修复:

  • Claude Messages 转 OpenAI Responses/Codex 时,Claude 侧的 cache_control 会被带入 Codex Responses 请求体;当前上游会返回未知参数错误。
  • Usage 会话页对 OpenAI Responses 响应的解析和渲染不完整:部分 *_call item 没有展示,流式工具调用参数也可能在 response.completed 兜底解析时被默认 {} 覆盖。

改动

  • 在 Codex Responses special body edits 中继续用 cache_control 派生稳定的 prompt_cache_key,但在发给上游前递归移除所有 cache_control 字段。
  • 为 Usage 会话解析和渲染补充 Responses *_call item 的通用支持。
  • 修复流式 Responses 工具调用解析:response.completed 只有在最终 item 确实带输入时才覆盖已收集的增量参数,并复用流式阶段的 key 避免重复渲染。
  • 增加对应回归测试。

验证

  • cargo test -p aether-ai-formats
  • npm run test:run -- src/features/usage/conversation/__tests__/stream.spec.ts
  • fork 的 personal 分支 DockerHub Image 构建已通过。

stabey and others added 3 commits June 4, 2026 11:06
The response.completed fallback rebuilt every call item with responsesCallInput(), which returns '{}' for a function_call lacking arguments. Since '{}' is truthy, ensureToolCall overwrote arguments already collected from streamed delta events. Guard the completed branch with responsesCallHasInput (matching the output_item.done branch) so empty/default inputs no longer clobber streamed args, and align its dedupe key with the streaming phase to avoid duplicate tool-call rendering when an item has no id. Drop the now-dead '工具调用' fallbacks since responsesCallName never returns empty.
@stabey stabey marked this pull request as ready for review June 4, 2026 05:33
@stabey stabey changed the title fix: 修复 Codex Responses cache_control 和工具调用展示 fix: 剥离 Codex cache_control 并完善 Responses 工具调用展示 Jun 4, 2026
@fawney19 fawney19 merged commit 69b8b96 into fawney19:main Jun 4, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants