Skip to content

fix: prompt_cache_key openai chat -> openai responses - #6861

Merged
seefs001 merged 1 commit into
QuantumNous:mainfrom
seefs001:fix/openai-chat-to-responses-prompt_cache_key
Aug 15, 2026
Merged

fix: prompt_cache_key openai chat -> openai responses#6861
seefs001 merged 1 commit into
QuantumNous:mainfrom
seefs001:fix/openai-chat-to-responses-prompt_cache_key

Conversation

@seefs001

@seefs001 seefs001 commented Aug 15, 2026

Copy link
Copy Markdown
Collaborator

⚠️ 提交说明 / PR Notice

Important

  • 请提供人工撰写的简洁摘要,避免直接粘贴未经整理的 AI 输出。

📝 变更描述 / Description

(简述:做了什么?为什么这样改能生效?请基于你对代码逻辑的理解来写,避免粘贴未经整理的内容)

补充 chat转responses prompt_cache_key

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix) - 请关联对应 Issue,避免将设计取舍、理解偏差或预期不一致直接归类为 bug
  • ✨ 新功能 (New feature) - 重大特性建议先通过 Issue 沟通
  • ⚡ 性能优化 / 重构 (Refactor)
  • 📝 文档更新 (Documentation)

🔗 关联任务 / Related Issue

✅ 提交前检查项 / Checklist

  • 人工确认: 我已亲自整理并撰写此描述,没有直接粘贴未经处理的 AI 输出。
  • 非重复提交: 我已搜索现有的 IssuesPRs,确认不是重复提交。
  • Bug fix 说明: 若此 PR 标记为 Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。
  • 变更理解: 我已理解这些更改的工作原理及可能影响。
  • 范围聚焦: 本 PR 未包含任何与当前任务无关的代码改动。
  • 本地验证: 已在本地运行并通过测试或手动验证,维护者可以据此复核结果。
  • 安全合规: 代码中无敏感凭据,且符合项目代码规范。

📸 运行证明 / Proof of Work

(请在此粘贴截图、关键日志或测试报告,以证明变更生效)

Summary by CodeRabbit

  • Bug Fixes

    • Preserved prompt cache keys when converting chat completion requests to responses requests.
    • Correctly handles escaped and Unicode prompt cache key values.
    • Omits the prompt cache key when no value is provided.
  • Tests

    • Added coverage for prompt cache key preservation and JSON serialization.

@seefs001
seefs001 merged commit 7d09c69 into QuantumNous:main Aug 15, 2026
2 of 4 checks passed
@coderabbitai

coderabbitai Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2d09f626-2e77-4114-9ef3-181e22a60dd6

📥 Commits

Reviewing files that changed from the base of the PR and between 47ba9d2 and c1838f7.

📒 Files selected for processing (2)
  • relaykit/relayconvert/internal/oai_chat/to_oai_responses_req.go
  • relaykit/relayconvert/internal/oai_chat/to_oai_responses_req_test.go

Walkthrough

The request conversion now preserves non-empty PromptCacheKey values in OpenAIResponsesRequest. Tests cover escaped, Unicode, serialized, and unset values.

Changes

Prompt cache key conversion

Layer / File(s) Summary
Convert and validate prompt cache keys
relaykit/relayconvert/internal/oai_chat/to_oai_responses_req.go, relaykit/relayconvert/internal/oai_chat/to_oai_responses_req_test.go
The converter serializes and assigns non-empty PromptCacheKey values. Tests verify escaped and Unicode values, JSON serialization, and omission when unset.

Estimated code review effort: 2 (Simple) | ~5 minutes

Suggested reviewers: wans10

Poem

A rabbit hops through JSON bright,
Carrying cache keys left and right.
Escapes, Unicode, all pass through,
Empty keys fade from output too.
Conversion lands with tests in flight.

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

0401lucky pushed a commit to 0401lucky/new-api that referenced this pull request Aug 16, 2026
junjundesk pushed a commit to junjundesk/new-api that referenced this pull request Aug 17, 2026
DayFliggy pushed a commit to DayFliggy/Ren2Hub that referenced this pull request Aug 17, 2026
jerzygao pushed a commit to jerzygao/new-api that referenced this pull request Aug 18, 2026
Sync fork with upstream Calcium-Ion/new-api (6 commits):
- test(web): standardize frontend tests on Vitest (QuantumNous#6569)
- fix(oauth): align custom binding response fields in frontend (QuantumNous#6818)
- fix(relay): stop injecting empty tools into Claude requests
- feat: add field passthrough controls for gateway channels (QuantumNous#6847)
- fix: prompt_cache_key openai chat -> openai responses (QuantumNous#6861)
- fix(topup): guard wallet quota during recharge

Conflict resolved: web/bun.lock regenerated via 'bun install' to
reconcile the Vitest toolchain with fork dependencies.
330079598 pushed a commit to 330079598/new-api that referenced this pull request Aug 19, 2026
kk66615 pushed a commit to kk66615/new-api that referenced this pull request Aug 22, 2026
上游 253a74d(QuantumNous#6654) 与 7d09c69(QuantumNous#6861) 新增的测试用例调用
ResponsesRequestToChatCompletionsRequest / ChatCompletionsRequestToResponsesRequest
时使用的是旧签名,而本地 PR QuantumNous#6655 补丁已为这两个函数引入
convmeta.Meta 首参(reasoning_content 跨转换保留的核心机制)。
合并后函数定义取本地版本、测试取上游版本,导致 relaykit 模块
vet 失败。为 5 处新增用例补上 nil meta。

受影响用例:
- to_oai_chat_req_test.go: penalty 转换 2 处
- to_oai_responses_req_test.go: prompt_cache_key 2 处 / penalty 1 处

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014AZbTUCaSkfaTLkrfzKGSP
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.

1 participant