Repository navigation
[AISAGE-759] fix(ai-gateway): normalize ChatGPT-route Responses requests - #8555
Conversation
…es rejections Drop service_tier values other than auto/default and raise max_output_tokens below 16 to 16 on the delegated route, both of which OpenAI rejects with 400. Expire the stored delegated access token after an upstream 401 token_expired or token_revoked, so the next request refreshes it instead of replaying the dead token until its stored expiry.
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Executive SummaryThe incremental commit drops Assumptions: Verification Notes
Files Reviewed (2 files)
Previous Review Summaries (2 snapshots, latest commit df5b912)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit df5b912)Status: No Issues Found | Recommendation: Merge Executive SummaryThe incremental change narrows the PR to two files: Assumptions: Verification Notes
Files Reviewed (2 files)
Previous review (commit d16453c)Status: No Issues Found | Recommendation: Merge Executive SummaryThe three delegated-route fixes are small, well-scoped, and consistent with the existing ChatGPT connection handling; the token-expiry compare-and-set under the row lock correctly avoids clobbering a concurrent refresh or reconnect. Assumptions: Files Reviewed (6 files)
Reviewed by deepseek-flash-latest · Input: 36.5K · Output: 7.2K · Cached: 680.6K Review guidance: REVIEW.md from base branch |
Summary
On the "Sign in with ChatGPT" route (
openai-chatgptprovider onPOST /responses), OpenAI rejects some requests that the gateway could easily send in an accepted form. The delegated transform now fixes two of them:service_tier: subscription sharing accepts onlyautoanddefault, which behave the same as sending no tier. Any other value gets400 subscription_sharing_unsupported_capability. The transform now always drops the field.max_output_tokens: OpenAI rejects values below 16 with400 integer_below_min_value. The transform now raises them to 16.temperature/top_p: the recent reasoning models served on this route reject sampling parameters with400 unsupported_parameter. The transform now drops both.The token-refresh change that was originally part of this PR now lives in #8557, so it can be reviewed separately. The remaining error classes are tracked in AISAGE-759.
Verification
openai-chatgpt/suites andupstream-attempt.test.tsagainst local PostgreSQL; all pass.pnpm --filter @kilocode/web-shared typecheckand oxlint on the changed files; both are clean.Visual Changes
N/A
Reviewer Notes
temperatureandtop_punconditionally also affects older non-reasoning models (for examplegpt-4o) if they are served on this route. For those models it removes a caller preference rather than fixing an error.autoanddefaultassumes they behave the same as sending no tier on this route. Since subscription sharing allows no other tier, sending one gains nothing.