Skip to content

fix(codex): restore cached tool call fields#4160

Merged
farion1231 merged 2 commits into
farion1231:mainfrom
chen-985211:codex-chat-tool-call-history
Jun 16, 2026
Merged

fix(codex): restore cached tool call fields#4160
farion1231 merged 2 commits into
farion1231:mainfrom
chen-985211:codex-chat-tool-call-history

Conversation

@chen-985211

@chen-985211 chen-985211 commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Summary / 概述

  • Restore missing cached Codex tool call fields before converting Responses history to Chat Completions.
  • Preserve non-empty fields already present in the request, and only fill blank or missing fields from cached call history.
  • Avoid sending an empty function name to strict Chat upstreams when a follow-up request contains a partial function call item.

Related Issue / 关联 Issue

Fixes #4152

Screenshots / 截图

Before / 修改前 After / 修改后
N/A - backend proxy change N/A - backend proxy change

Checklist / 检查清单

  • pnpm typecheck passes / 通过 TypeScript 类型检查
  • pnpm format:check passes / 通过代码格式检查
  • cargo clippy passes (if Rust code changed) / 通过 Clippy 检查(如修改了 Rust 代码)
  • Updated i18n files if user-facing text changed / 如修改了用户可见文本,已更新国际化文件(N/A - no user-facing text changed)

Verification / 验证

  • pnpm typecheck
  • pnpm format:check
  • cargo fmt --check
  • cargo clippy
  • cargo test codex_chat_history

@chen-985211
chen-985211 force-pushed the codex-chat-tool-call-history branch from 846325e to da3510f Compare June 13, 2026 15:23
@farion1231

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: da3510f322

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@6639835 6639835 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感觉写法太复杂了

enrich_call_item_from_cache copied the fill-if-empty loop for
reasoning_content/reasoning. The two loops are identical and key
order is irrelevant, so fold both key sets into a single loop.

Pure refactor, no behavior change; codex_chat_history tests pass.

@farion1231 farion1231 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution!

@farion1231
farion1231 merged commit 36b557b into farion1231:main Jun 16, 2026
2 checks passed
gfunc pushed a commit to gfunc/cc-switch that referenced this pull request Jun 19, 2026
* fix(codex): restore cached tool call fields

* refactor(codex): merge duplicate enrich loops in chat history

enrich_call_item_from_cache copied the fill-if-empty loop for
reasoning_content/reasoning. The two loops are identical and key
order is irrelevant, so fold both key sets into a single loop.

Pure refactor, no behavior change; codex_chat_history tests pass.

---------

Co-authored-by: Jason <[email protected]>
char1eslu added a commit to char1eslu/cc-switch that referenced this pull request Jul 5, 2026
proxy 链路(3.16.4):
- farion1231#3817 转发前解压请求体(zstd):新增 content_encoding 模块,Codex Desktop
  登录态压缩请求体不再破坏代理 JSON 解析,压缩的错误响应体也一并解压
- farion1231#4583 Copilot/Codex OAuth 走全局代理:不再写死 Client::new() 绕过代理
- farion1231#4159 Chat 工具调用缺函数名则跳过(流式/非流式/legacy 三路,去掉 unknown_tool 回退)

凭据安全(3.16.4/3.16.5):
- 通用配置片段剥离全部凭据:extract_claude_common_config 改用
  is_sensitive_config_key 模式匹配,剥掉任意 *_API_KEY/*_AUTH_TOKEN/*secret*/*token*
- farion1231#4654 用量脚本凭据仅作显式覆盖:ProviderService add/update 归一化 + deeplink 导入 + 前端缓存失效
- codex_history_migration 探测 CODEX_SQLITE_HOME 环境变量

Claude MCP(3.16.4):
- farion1231#3431 自定义配置目录时 MCP 文件存到目录内(dir/.claude.json),
  默认 ~/.claude 仍用 ~/.claude.json;移除旧的"访问即拷贝"迁移

farion1231#4160/farion1231#4239/farion1231#4316 经核对 fork 3.16.3 基线已含,跳过。
farion1231#4654 provider/mod.rs 测试与 farion1231#3431 mcp_commands 集成测试因 fork
  UsageScript/McpApps 字段差异未移植,功能逻辑完整,待后续补测试。

Co-Authored-By: Claude Opus 4.8 <[email protected]>
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.

Local proxy 转发 /responses 时丢失 tool_calls 中的 function.name 导致上游 400

3 participants