fix(oracle): route maxTokens to maxCompletionTokens for GPT-5 family#1635
Open
fede-kamel wants to merge 1 commit into
Open
fix(oracle): route maxTokens to maxCompletionTokens for GPT-5 family#1635fede-kamel wants to merge 1 commit into
fede-kamel wants to merge 1 commit into
Conversation
OCI's chat endpoint rejects `maxTokens` for GPT-5+ models with `Use 'maxCompletionTokens' instead`, so requests through the gateway fail with a 400 unless the caller knows the OCI-specific quirk. Detect the GPT-5 family inline (`/^openai\.gpt-5/i`) and rewrite the parameter on the OCI chat request envelope. All other model families (gpt-4o, Llama, Cohere, Grok, Gemini) continue to use `maxTokens` unchanged. Tests cover gpt-5, gpt-5-mini, gpt-4o (negative), and the Llama / Cohere / Grok / Gemini families.
Author
|
@roh26it @narengogi @VisargD — companion to #1537. Rebased on main, mergeable, e2e-verified live against |
This was referenced May 17, 2026
Author
|
Friendly review ping @narengogi — this is the GPT-5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
OCI's chat endpoint rejects
maxTokensfor the GPT-5 family withUse 'maxCompletionTokens' instead, so any GPT-5 request through the gateway currently fails with a 400 unless the caller already knows the OCI quirk and works around it.This PR detects the GPT-5 family inline (
/^openai\.gpt-5/i) and rewrites the parameter on the OCI chat request envelope. Everything else (gpt-4o, Llama, Cohere, Grok, Gemini) continues to usemaxTokensunchanged.Split out from #1537 per @narengogi's review.
What changed
src/providers/oracle/chatComplete.ts:usesMaxCompletionTokens(model)helper (no separatemodelConfig.tsmodule — kept tight).chatRequesttransform, after building the OCI envelope, swapmaxTokens→maxCompletionTokenswhen the model is in the GPT-5 family.src/providers/oracle/chatComplete.test.ts:openai.gpt-5andopenai.gpt-5-miniroute tomaxCompletionTokens.openai.gpt-4o,meta.llama-3.3-70b-instruct,cohere.command-r-plus-08-2024,xai.grok-3-mini,google.gemini-2.5-flashkeepmaxTokens.Diff: +63 / −1, two files.
Verified
npm run build✓npm run format:check✓tsc --noEmitno errors insrc/providers/oracle/)inference.generativeai.us-chicago-1.oci.oraclecloud.com/20231130/actions/chatforopenai.gpt-5(now succeeds; previously returned400 "Use 'maxCompletionTokens' instead").Related
/^openai\.gpt-5/i) instead of feat(oracle): Add rerank and guardrails support #1540's separatemodelConfig.tsmodule — same behaviour, smaller surface area.