Skip to content

fix(responses): strip unsupported prompt cache retention - #2091

Closed
luvs01 wants to merge 1 commit into
lidge-jun:devfrom
luvs01:agent/filter-unsupported-prompt-cache-retention
Closed

fix(responses): strip unsupported prompt cache retention#2091
luvs01 wants to merge 1 commit into
lidge-jun:devfrom
luvs01:agent/filter-unsupported-prompt-cache-retention

Conversation

@luvs01

@luvs01 luvs01 commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Prevent long Codex turns and subagents from failing when the ChatGPT Responses backend rejects prompt_cache_retention with invalid_parameter.
  • Remove the field only from authMode: "forward" requests through the existing ChatGPT compatibility sanitizer.
  • Preserve prompt_cache_retention for OpenAI API-key Responses requests, where supported models can still use extended retention.
  • Add regressions for both the stripped forward path and the preserved API-key path.

Verification

  • Pre-fix regression: the new forward-path assertion failed because prompt_cache_retention: "24h" reached the wire.
  • Bun 1.3.14: bun test --timeout 60000 tests/openai-responses-passthrough.test.ts — 69 passed, 0 failed.
  • Bun 1.4.0 canary: the same focused test — 69 passed, 0 failed.
  • Bun 1.3.14 and Bun 1.4.0 canary: bun x tsc --noEmit — passed.
  • bun run privacy:scan and git diff --check — passed.
  • bun run test became non-green on three Windows Log Guard assertions returning the existing unsafe_path result. Those tests and their direct implementation paths are byte-identical to dev and do not call the Responses adapter; the run was stopped after the unrelated failures were established.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • All CI tests are green on my local testing.

  • I pushed my PR to the latest dev commit.

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

Summary by CodeRabbit

  • Bug Fixes
    • Improved request handling for prompt-cache retention settings.
    • OpenAI API-key requests now preserve supported prompt-cache retention values.
    • ChatGPT-forwarded requests now exclude unsupported prompt-cache retention parameters.

@coderabbitai

coderabbitai Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: b29734c9-72f9-4fa1-9bd3-48770092ec6f

📥 Commits

Reviewing files that changed from the base of the PR and between f2e5e76 and deda6fa.

📒 Files selected for processing (2)
  • src/adapters/openai-responses.ts
  • tests/openai-responses-passthrough.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

Changes

Responses parameter forwarding

Layer / File(s) Summary
Sanitize and verify prompt cache retention
src/adapters/openai-responses.ts, tests/openai-responses-passthrough.test.ts
stripUnsupportedForwardParams removes prompt_cache_retention from forward-mode requests. API-key requests preserve the parameter. Tests cover both behaviors at lines 807–847.

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

Merge Risk: ⚪ Minimal · up to deda6

The change removes unsupported prompt-cache retention only for forwarded requests while preserving the API-key path, with focused regressions covering both behaviors. No actionable merge-blocking risk remains after normal checks and review.

Possibly related PRs

Suggested reviewers: ingwannu

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes stripping unsupported prompt cache retention from Responses requests.
✨ Finishing Touches
🧪 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.

@github-actions

Copy link
Copy Markdown
Contributor

Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Aug 19, 2026
@github-actions

github-actions Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

✅ READY

  • all PR quality gates passed; the review readiness checklist is complete.

Review readiness checklist

  • ✅ All CI tests are green on my local testing.
  • ✅ I pushed my PR to the latest dev commit.
  • ✅ I resolved all correct Codex and CodeRabbit findings.
  • ✅ My PR is ready for review.

4/4 boxes ticked.

This pull request is already Ready for Review.
The review-ready label marks this PR as ready; review automation runs independently.
Maintainers: @lidge-jun @Ingwannu @Wibias

@luvs01
luvs01 marked this pull request as ready for review August 19, 2026 04:42
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@luvs01
luvs01 force-pushed the agent/filter-unsupported-prompt-cache-retention branch from deda6fa to 61ee2e9 Compare August 19, 2026 04:45
@github-actions
github-actions Bot marked this pull request as draft August 19, 2026 04:46
@luvs01
luvs01 marked this pull request as ready for review August 19, 2026 05:03
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@lidge-jun

Copy link
Copy Markdown
Owner

Closing decision on the prompt_cache_retention collision (#2092): we are going with #2102 instead.

Not a quality judgment on this diff — the collision is real and only one of the three can land. The deciding evidence is that the ChatGPT backend's cache handling is account-level and has provably varied by deployment: one deployment accepted "24h" and echoed it back. This PR strips the field for every forward-mode model, so it fixes the reported 400 by removing a parameter that some accounts still honor. #2102's model-scoped strip (gpt-5.6 exact or gpt-5.6- prefixed) fixes the same report without that cost.

Thanks for the fast turnaround on this one — the analysis in the description is what made the three-way comparison quick.

@lidge-jun

Copy link
Copy Markdown
Owner

리뷰 · 우선순위 46 / 80

forward 경로의 stripUnsupportedForwardParams()prompt_cache_retention을 넣어, ChatGPT 백엔드가 invalid_parameter로 긴 턴을 죽이는 일을 막는다. API 키 Responses는 필드를 유지한다. hygiene 통과, review-ready, 체크리스트 4/4, 두 파일이다. 실행 품질은 괜찮다. 점수를 46에 둔 이유는 범위다. 모든 forward 모델에서 스트립해서, 배포에 따라 "24h"를 받던 gpt-5.5 경로까지 바꾼다. 메인테이너는 이미 #2102를 골랐다.

코드는 src/adapters/openai-responses.ts의 기존 sanitizer다. hasPromptCacheRetentionmax_output_tokens/metadata와 같이 보고, 하나라도 있으면 rest로 다시 만든다. 모델 id를 보지 않는다. forward면 gpt-5.5도 빠진다. 주석은 “ChatGPT backend”라고 쓰지만 조건은 authMode === "forward"다. 비정규 forward도 같이 스트립된다.

테스트가 그 계약을 고정한다. API 키 어댑터는 "24h"를 남기고, 기본 forward 픽스처는 gpt-5.5에서도 필드를 지운다. 기존 “raw passthrough는 보존” 테스트가 API 키 케이스로 바뀌었다. 회귀는 분명하다. 다만 그 회귀가 #2092가 증명한 불변(“gpt-5.6에만 보내지 마라”)보다 넓다.

#2099는 prefix 스코프, #2102는 정규 ChatGPT + gpt-5.6/gpt-5.6-*다. 세 개 중 하나만 랜다. 이 PR은 제일 단순하고, 그래서 제일 많이 지운다. Windows Log Guard 실패는 이 diff와 무관하다고 저자가 적었다. 보안 서피스는 아니다.

해결방안

머지하지 마라. #2102가 랜 뒤 close하면 된다. 전체 forward 스트립을 더 밀지 마라. 계정/배포별 캐시 동작이 그 범위를 이미 반박했다. 테스트 패턴(API 키 보존)은 #2102 쪽이 이미 더 좁게 가지고 있다.

이 댓글은 grok-bot이 작성했습니다

@lidge-jun

Copy link
Copy Markdown
Owner

Thanks for raising this, @luvs01 — closing as superseded by #2138, which fixes #2092.

Your diagnosis was right and your patch was the simplest of the three. The reason #2138 follows @lilinxiong's narrower contract instead: extending stripUnsupportedForwardParams strips the field for every forward provider and every model, and tests/openai-responses-passthrough.test.ts:807 pins that a gpt-5.5 forward request keeps it. The issue reporter also corrected their own initial "never send it anywhere" claim — some deployments still accept and echo "24h". The 400 is specific to gpt-5.6 on the ChatGPT backend, so that is where the strip lives.

@lidge-jun lidge-jun closed this Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working review-ready

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants