-
Notifications
You must be signed in to change notification settings - Fork 2.4k
fix context length for lmstudio and ollama (#2462) #4314
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
Conversation
67812b2 to
d823b3d
Compare
daniel-lxs
left a comment
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.
Hey @thecolorblue Thanks for your contribution!
This is a solid implementation. I've left a few suggestions to help improve the robustness of the code, let me know what you think!
|
I am running into failed tests when running Here is one example: It looks like the tests assume there are only 5 providers but it is not clear to me how to add more. |
|
Hi @thecolorblue! I can help you fix the failing test. The issue is that your PR added two new providers ( Here's how to fix it: In Update the mock setup to handle 7 providers instead of 5: // Mock some providers to succeed and others to fail
mockGetModels
.mockResolvedValueOnce(mockModels) // openrouter
.mockRejectedValueOnce(new Error("Requesty API error")) // requesty
.mockResolvedValueOnce(mockModels) // glama
.mockRejectedValueOnce(new Error("Unbound API error")) // unbound
.mockRejectedValueOnce(new Error("LiteLLM connection failed")) // litellm
.mockRejectedValueOnce(new Error("Ollama connection failed")) // ollama - ADD THIS
.mockRejectedValueOnce(new Error("LMStudio connection failed")) // lmstudio - ADD THISAround line 187-193, update the expected routerModels: routerModels: {
openrouter: mockModels,
requesty: {},
glama: mockModels,
unbound: {},
litellm: {},
ollama: {}, // ADD THIS
lmstudio: {}, // ADD THIS
},Around line 216, add expectations for the new provider error messages: expect(mockClineProvider.postMessageToWebview).toHaveBeenCalledWith({
type: "singleRouterModelFetchResponse",
success: false,
error: "Ollama connection failed",
values: { provider: "ollama" },
})
expect(mockClineProvider.postMessageToWebview).toHaveBeenCalledWith({
type: "singleRouterModelFetchResponse",
success: false,
error: "LMStudio connection failed",
values: { provider: "lmstudio" },
})The test was failing because it expected 5 provider calls but received 7. With these changes, the test should pass! |
|
@daniel-lxs Thank you for walking me through it. I'll try again tonight and let you know how it goes. |
|
@daniel-lxs looks like that worked. Let me know if there is anything else I can do. |
|
@daniel-lxs checking in on this one... I see there are some conflicts. Should I take care of those now? Is there anything else I can do to keep this moving? |
|
Hey @thecolorblue , sorry I'll take a look soon, I can fix the conflicts if necessary, don't worry |
|
@mrubens I believe all of the conflicts have been resolved. Let me know if you see anything else that needs to be addressed. |
|
Thank you @thecolorblue, I'll be taking a look soon! |
daniel-lxs
left a comment
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.
Thank you @thecolorblue for addressing the review so quickly!
Looks good to me
mrubens
left a comment
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.
Looks good aside from @hannesrudolph's feedback on the fallback. Hannes want to make the call on whether to merge this or try to handle that case better first?
|
I added a check for models: It doesn’t prevent the user from saving, but it does let them know if the model doesn’t exist. |
|
Note sure if it was expected, but i access ollama via litellm, and the bug fix doesn t seems to work in this situation, i still get 200k context displayed , when it s in fact 24k. So roo won t condense, and context get truncated, functions forgotten, etc ... |
…Inc#4314) Co-authored-by: Daniel Riccio <[email protected]>
|
@ptempier are you running the ollama server locally? Did you select 'litellm' as the API provider? |
|
Hello |
Co-authored-by: Daniel Riccio <[email protected]>

Related GitHub Issue
Closes: #2462
Description
Fixing the context length viewable in the task header while using ollama and LM Studio models.
For both Ollama and LM Studio the correct context length is now being pulled from each service. No fields are needed in the settings page for setting the context length.
I decided to update the code to treat Ollama and LM Studio as model routers and take advantage of the model results caching already in use. There are some UI updates that could be made to make using Ollama and LM Studio more intuitive (for example, debugging an incorrect port or the service not online is difficult), but I did not include those changes in this PR. I can open up another issue for those changes.
I needed to use the
@lmstudio/sdkpackage to get the proper model details from LM Studio. If LM Studio adds the model context length to their API this can be removed.Test Procedure
I tested with 'devstral' and 'qwen2.5-coder' with both Ollama and LM Studio. I then shut off Ollama and LM Studio and tried to use Roo normally to see how it handles not connecting.
Type of Change
srcor test files.Pre-Submission Checklist
npm run lint).console.log) has been removed.npm test).mainbranch.npm run changesetif this PR includes user-facing changes or dependency updates.Screenshots / Videos
Documentation Updates
As described in the issue, the documentation here mentions configuring the context size.
That should be removed.
Get in Touch
discord: braddavis1008
Important
Fixes context length display for Ollama and LM Studio models by treating them as model routers and utilizing caching.
webviewMessageHandler.tsto handle Ollama and LM Studio model fetching.@lmstudio/sdktopackage.jsonfor fetching LM Studio model details.validateApiConfiguration()invalidate.tsto check for model IDs for Ollama and LM Studio.ollama.tsandlm-studio.ts.This description was created by
for 67812b2923994d58b9b6a9255b8f3396286f7fc8. You can customize this summary. It will automatically update as commits are pushed.