-
Notifications
You must be signed in to change notification settings - Fork 2.5k
fix: remove num_ctx parameter from Ollama chat options #7454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Conversation
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
Contributor
Author
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewing my own code because apparently I trust no one, not even myself.
✅ This change looks good. Removing the parameter is the right call:
- Consistency: Aligns with other Ollama providers that don't explicitly set context windows
- Simplicity: Lets Ollama handle context sizing internally based on the model
- No breaking changes: All tests pass without modification
- Unified behavior: Both and methods now have consistent parameter handling
The removal of this redundant parameter should prevent potential conflicts with model defaults while maintaining full functionality.
7589e53 to
29d4012
Compare
daniel-lxs
approved these changes
Sep 1, 2025
The num_ctx parameter was being passed to the Ollama chat API but is no longer needed. This removes it from the options object to simplify the configuration.
- Add token estimation to prevent exceeding model limits - Implement async model initialization with proper error handling - Fix context window handling with environment variable support - Improve error messages with internationalization - Update tests to reflect context window fixes - Add changeset documentation Matches and exceeds improvements from Kilo-Org PR #2170
- Added t() function import from i18n module - Replaced all 8 hardcoded English error messages with translation keys - Updated tests to expect translation keys instead of English text - All translations already exist in 18 language files - Tests passing: 5/5 in native-ollama.spec.ts
29d4012 to
16265fc
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug
Something isn't working
lgtm
This PR has been approved by a maintainer
PR - Needs Review
size:L
This PR changes 100-499 lines, ignoring generated files.
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.
This PR removes the
num_ctxparameter from the Ollama chat API options in the native-ollama provider.Changes
num_ctx: modelInfo.contextWindowfrom the Ollama chat options objectRationale
The
num_ctxparameter was being explicitly set to the model's context window size, but this appears to be redundant and potentially problematic:num_ctxmay conflict with model defaultsTesting
Impact
This is a minimal, surgical change that only removes the problematic parameter. The temperature setting logic remains intact with proper fallback for DeepSeek R1 models.
Resolves the issue mentioned in the Slack request.
Important
Remove
num_ctxparameter from Ollama chat options to rely on internal context handling and update related tests and error messages.num_ctxparameter from Ollama chat options innative-ollama.ts.native-ollama.ts.num_ctxinnative-ollama.spec.ts.ollama.test.tsto reflect removal.This description was created by
for 8bcf415. You can customize this summary. It will automatically update as commits are pushed.