fix(responses): scope tool-field stripping per destination - #2267
fix(responses): scope tool-field stripping per destination#2267olddonkey wants to merge 1 commit into
Conversation
`tests/responses-routed-web-search-fields.test.ts` > "official OpenAI API-key traffic retains OpenAI web_search fields" fails on untouched `dev`: `external_web_access` is stripped from traffic bound for the official OpenAI API, which supports it. Two layers strip that field. The capability layer is gated correctly — it runs only when `supportsOpenAiWebSearchToolFields === false`, which xAI declares in the registry. `CANONICAL_ONLY_TOOL_FIELDS` applied its whole table under one outer gate, `!isCanonicalOpenAiForwardProvider`, and an official OpenAI API provider is not the canonical ChatGPT surface, so the table stripped it there too. The two fields in that table do not have the same scope: - `external_web_access` is understood by both OpenAI-operated surfaces — the canonical ChatGPT Codex backend and the official OpenAI API. Routed third-party gateways reject it (xAI: `Argument not supported`). - `defer_loading` is private to the canonical surface; the official OpenAI API rejects it, so it must keep being stripped there. Deleting the `external_web_access` row is the obvious fix and it is wrong — verified: it turns the failing test green and breaks three that correctly require the field stripped for routed providers, including the xAI namespace lowering case. Give each row its own `isSupportedDestination` predicate instead, and move the call outside the namespace-lowering gate so OpenAI API-key traffic is also covered, where only the canonical-only row applies. The table stays declarative: adding a field remains a data change, which is the property that made it worth having after each private bit previously arrived as its own bespoke traversal. A comment names the capability flag as the mechanism owning the routed web-search case, so the two layers are not later collapsed back together. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
✅ Deterministic PR hygiene checks passed. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughChangesResponses tool-field routing
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This is a narrowly scoped destination-specific field-sanitization change with targeted test coverage, and no actionable merge-blocking risk remains beyond normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1⚔️ Resolve merge conflicts 💡
🧪 Generate unit tests (beta)
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. Comment |
⏳ DRAFT
What to do
Review readiness checklist
0/4 boxes ticked. This PR stays in draft until every box above is ticked. |
리뷰 · 우선순위 40 / 80본문이 가리키는 실패는 이 PR은 테이블을 #2262 OWNERSHIP 주석이 unclassified는 필드를 받는다고 박음. 캐퍼빌리티가 명시로 거부할 때만 테이블이 #2188 L1–L9 사이드카는 이미 draft 체크리스트 0/4. 2.28 블로커 아님. 프리뷰 배포 아님. 사용자 체감 구멍은 #2262가 이미 닫음. 중복에 가까움. 리베이스 지옥 만들 가치 없음. 해결방안: 리베이스하지 말고 닫아라. official OpenAI keep은 #2262가 소유자임. unclassified keep 정책을 뒤집지 말 것. destination predicate가 정말 필요하면 #2262 위에 새 PR로 이 댓글은 grok-bot이 작성했습니다 |
|
Closing as superseded by #2262, which is already on current dev as 2b988b3. The current implementation capability-gates external_web_access, preserves it for official OpenAI API-key traffic, strips it for xAI when supportsOpenAiWebSearchToolFields is false, and still removes defer_loading from noncanonical destinations. I verified the exact current dev head after #2265: the focused web-search field suite passes 4/4 and typecheck passes. This branch now conflicts because it reimplements the same boundary with a different table shape, so merging it would add duplicate churn rather than a missing fix. If the two extra destination-scoping assertions are still desired, please recut those tests only on current dev. |
Fixes a test that fails on untouched
dev@6c928aace:tests/responses-routed-web-search-fields.test.ts> "official OpenAI API-key traffic retains OpenAI web_search fields" (3 pass / 1 fail).external_web_accesswas stripped from traffic bound for the official OpenAI API, which supports it.Cause — two layers, one of them too broad
stripOpenAiOnlyWebSearchFieldsis gated correctly: it runs only whenprovider.supportsOpenAiWebSearchToolFields === false, which xAI declares in the registry (src/providers/registry.ts:1011).CANONICAL_ONLY_TOOL_FIELDSapplied its whole table under one outer gate,!isCanonicalOpenAiForwardProvider. An official OpenAI API provider is not the canonical ChatGPT surface, so the table stripped the field there as well.The two fields in that table do not have the same scope:
external_web_accessArgument not supported)defer_loadingOne gate cannot express both, so the narrower field dragged the wider one down with it.
The obvious fix is wrong
Deleting the
external_web_accessrow looks right — xAI already declares the capability flag, so the capability layer covers the case the row was added for. Verified it is not: that turns the failing test green and breaks three that correctly require the field stripped for routed providers.Approach
Each row now carries its own
isSupportedDestinationpredicate, and the call moves outside the namespace-lowering gate so OpenAI API-key traffic is covered too — where only the canonical-only row applies.The table stays declarative: adding a field remains a data change rather than a new traversal. That property is why the table exists — before it, each Codex-private bit arrived as its own bespoke strip, and the traversals disagreed about which containers they covered.
A comment names the capability flag as the mechanism that owns the routed web-search case, so a later reader does not collapse the two layers back together.
Tests
bun run test: 14016 pass, 10 skip, 1 fail across 886 files.The single failure is
tests/key-login-live-update.test.ts> "notify after key login pushes the merged row and keeps modelCosts on live and disk" — pre-existing and unrelated, and it fails identically on untoucheddev.New coverage: an official OpenAI API-key provider keeps
external_web_accessand losesdefer_loading; a canonical ChatGPT forward provider keeps both. The three tests quoted above are unchanged and still pass.(Plain
bun testwith no arguments hangs on this tree with high CPU and no progress — usebun run test.)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
external_web_accesswhere supported while removing unsupported deferred-loading settings.Tests