fix: bypass 20% context limit for OpenAI Compatible providers #8834
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.
Related GitHub Issue
Closes: #8833
Roo Code Task Context (Optional)
This PR was created with assistance from Roo Code to address the context limit issue.
Description
This PR fixes an issue where OpenAI Compatible API providers were incorrectly limited to 20% of their context window, causing operations to fail when the context exceeded 128k tokens.
Key changes:
getModelMaxOutputTokens()to bypass the 20% context window cap for OpenAI Compatible providersapiProvider: 'openai'with a customopenAiBaseUrl(not the default OpenAI API URL)maxTokensvalue, similar to the existing GPT-5 models exceptionImplementation details:
Test Procedure
How I tested:
src/shared/__tests__/api.spec.tscovering:cd src && npx vitest run shared/__tests__/api.spec.ts- all tests passHow to verify:
cd src && npx vitest run shared/__tests__/api.spec.tsPre-Submission Checklist
Screenshots / Videos
N/A - This is a backend fix with no UI changes.
Documentation Updates
Additional Notes
This fix ensures that OpenAI Compatible providers can utilize their full context window capacity, which is essential for users working with large context models through custom API endpoints (like local LLM servers, Groq, Together AI, etc.).
The implementation has been reviewed with 92% confidence and passes all quality checks including:
Get in Touch
Available for any questions about this PR.
Important
Bypass 20% context limit for OpenAI Compatible providers in
getModelMaxOutputTokens()to allow full use ofmaxTokens.getModelMaxOutputTokens()inapi.tsnow bypasses the 20% context window cap for OpenAI Compatible providers.apiProvider: 'openai'with a customopenAiBaseUrl.maxTokensfor these providers, similar to GPT-5 models.api.spec.tsto verify OpenAI Compatible providers bypass the 20% limit.openAiBaseUrl.This description was created by
for b15c90d. You can customize this summary. It will automatically update as commits are pushed.