-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Custom LLM API timeout instead of default 10 minutes for self-hosted LLMs #4076
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
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.
The label translation key here is settings:providers.openAiApiTimeout, but this is in the LMStudio component and the value comes from lmStudioApiTimeout. Consider renaming the translation key to be consistent (e.g., lmStudioApiTimeout).
| <label className="block font-medium mb-1">{t("settings:providers.openAiApiTimeout")}</label> | |
| <label className="block font-medium mb-1">{t("settings:providers.lmStudio.apiTimeout")}</label> |
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.
Since the LMStudio, Ollama, and OpenAI-Compatible providers all use the OpenAI API library, the timeout name, description, and behavior are identical. Therefore, a common translation key is intentionally used for all three providers.
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.
The placeholder text is using the translation key settings:placeholders.numbers.maxTokens, which doesn't seem appropriate for a timeout field. Consider using a key that matches the timeout setting for consistency.
| placeholder={t("settings:placeholders.numbers.maxTokens")} | |
| placeholder={t("settings:providers.openAiApiTimeout")} |
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.
The label is using the translation key settings:providers.openAiApiTimeout, but this file is for Ollama. It looks like a copy-paste error. Consider updating this to a key that reflects Ollama (e.g., settings:providers.ollamaApiTimeout).
| <label className="block font-medium mb-1">{t("settings:providers.openAiApiTimeout")}</label> | |
| <label className="block font-medium mb-1">{t("settings:providers.ollamaApiTimeout")}</label> |
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.
Typo / copy-paste issue: The placeholder translation key in this field is set to settings:placeholders.numbers.maxTokens, which doesn't match the field's purpose (API timeout). Consider using a more appropriate translation key (e.g. one related to timeout) for clarity.
| placeholder={t("settings:placeholders.numbers.maxTokens")} | |
| placeholder={t("settings:placeholders.numbers.timeout")} |
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.
This seems like a valid feedback, would using openAiApiTimeout here make more sense?
|
Hey @Belerafon, can you take another look at the translations? It seems that you could use translations that are more relevant. |
src/api/providers/lmstudio.ts
Outdated
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.
Isn't the OpenAI class timeout in seconds though? https://github.com/openai/openai-python?tab=readme-ov-file#timeouts
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.

Node.js OpenAI library’s TypeScript definitions (see screenshot), the explicitly states:
“The maximum amount of time (in milliseconds) that the client should wait for a response from the server before timing out a single request.”
Moreover, the built-in default is set here:
timeout: options.timeout ?? 600000 /* 10 minutes */
—so here it’s definitely milliseconds, not seconds. May be a python library in seconds...
I’ve fixed the placeholder translation—it was clearly a bug. However, I’ve kept using By the way, I’ve noticed an issue with the tests for my PR: while npm test passes locally on my Windows 11 host, the platform-unit-test (ubuntu-latest) job on GitHub is failing. I’m not entirely sure what’s going wrong and would appreciate any help. |
|
Hey @Belerafon, can you try rebasing your branch against main? |
46ce635 to
9827fd3
Compare
Looks like I did it |
|
My guess is that you will also have to update the test. It probably fails because it doesn't expect a timeout parameter: Adding: I don't see this specific test for Ollama and LMStudio, so they should be fine. |
9827fd3 to
60c6926
Compare
|
@Belerafon is attempting to deploy a commit to the Roo Code Team on Vercel. A member of the Team first needs to authorize it. |
Thanks for your help, now the test passes! except [Vercel] - Requires authorization to deploy. I have no idea why I would need to deploy something somewhere with my small commit, but I guess it's beyond my capabilities. |
|
My guess is that you need to remove the "Draft / In Progress" label and assign the "Needs Preliminary Review" label. You can also check the "updated tests have been added to cover my changes." in the checklist in your first post. |
|
Hey @Belerafon you can ignore that vercel check, it's something we are setting up. Also you don't need to change the labels at all. |
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.
It seems like the Hindi translation for openAiApiTimeoutDescription is still in English.
|
Hey @Belerafon, I noticed that the timeout description mentions "min 5 min", but the input field accepts any positive number. Should we add validation to enforce the 5-minute minimum? Or perhaps use 10 minutes as the minimum since that's the OpenAI library's default timeout? |
I actually discovered this limitation (minimum 5 minutes) with my manual local tests. I didn't find any official information about it. Maybe the best way would be to just remove this information (min 5 min) from the description. But someone could potentially report a bug trying to set 1 minute and it won't work. |
|
@Belerafon What do you think? |
A shorter timeout is helpful for cloud providers that normally reply quickly but occasionally hang indefinitely and require a retry. 120 minutes isn't the best maximum either for my taste - I might want to run the new DeepSeek-R1-0528 on my laptop tonight and get something special and wonderful in the morning, but not Repeat 5... |
|
I understand, just trying to set this up in a way where the user doesn't accidentally set the timeout to an invalid value. |
In normal operation with standard providers, users can set any timeout value from 1 minute to infinity without affecting RooCode's functionality. In problematic cases, this timeout flexibility can be beneficial. |
fc449a0 to
ab23de9
Compare
|
I think I have implemented all fixes we discussed. Could you please let me know if there’s anything else that needs to be addressed so that I can mark this PR as “Ready for review” and request approval from the code owners? Thank you. |
Roo Code often emits API socket-timeout errors when using self-hosted, slow LLMs — either while reading a large file or even during the initial prompt phase. Yet these slow models can be usable in autonomous (e.g. overnight) scenarios for working on some private code source. It would be great to have a user-tunable setting to configure the API timeout for self-hosted providers (OpenAI-compatible, Ollama, LMStudio, etc.). The timeout can be up to 30 minutes to allow big file chunks or prompts to be fully processed. This way, even an older laptop could produce meaningful results overnight with roo code.
Update the test to verify that the OpenAI client is initialized with a timeout parameter, while maintaining the existing test structure and assertions for other configuration options.
ab23de9 to
f3237a6
Compare
| })(), | ||
| }} | ||
| className="w-full mt-4"> | ||
| <label className="block font-medium mb-1">{t("settings:providers.openAiApiTimeout")}</label> |
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.
The translation key used in this label is "settings:providers.openAiApiTimeout", which seems inconsistent with the LMStudio component (e.g., other keys use "lmStudio"). This might be a typographical error—please check if the key should be corrected to match the LMStudio naming, such as "settings:providers.lmStudioApiTimeout".
This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.
| })(), | ||
| }} | ||
| className="w-full mt-4"> | ||
| <label className="block font-medium mb-1">{t("settings:providers.openAiApiTimeout")}</label> |
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.
Typographical issue: The label text key here is "settings:providers.openAiApiTimeout" but given that this configuration is for Ollama (using ollamaApiTimeout), it seems like it might be a mistake. Please verify if this should be "settings:providers.ollamaApiTimeout" instead.
| <label className="block font-medium mb-1">{t("settings:providers.openAiApiTimeout")}</label> | |
| <label className="block font-medium mb-1">{t("settings:providers.ollamaApiTimeout")}</label> |
This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.
| <label className="block font-medium mb-1">{t("settings:providers.openAiApiTimeout")}</label> | ||
| </VSCodeTextField> | ||
| <div className="text-sm text-vscode-descriptionForeground -mt-2 mb-2"> | ||
| {t("settings:providers.openAiApiTimeoutDescription")} |
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.
Typographical issue: The description text key is "settings:providers.openAiApiTimeoutDescription" which may be unintended given the context of using Ollama. Confirm whether this key should refer to Ollama rather than OpenAI.
| {t("settings:providers.openAiApiTimeoutDescription")} | |
| {t("settings:providers.ollamaApiTimeoutDescription")} |
This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.
|
stale |
Related GitHub Issue
Closes: #3621
Description
Why: Roo Code often emits API socket-timeout errors when using self-hosted, slow LLMs — either while reading a large file or even during the initial prompt phase. Yet these slow models can be usable in autonomous scenarios for working on some private code source. It would be great to have a user-tunable setting to configure the API timeout for self-hosted providers (OpenAI-compatible, Ollama, LMStudio, etc.). The timeout can be up to 30 minutes to allow big file chunks or prompts to be fully processed. This way, even an older laptop could produce meaningful results overnight with roo code.
What This PR adds a timeout option to the settings for LMStudio, Ollama, and OpenAI-Сompatible providers, and forwards this value into the OpenAI class constructor. Translations for all supported languages have been included.
Test Procedure
Connected an OpenAI-compatible client to a local slow LLM and tested timeout settings of 5, 10, and 20 minutes.
Observed socket-timeout errors and retries occurring according to the configured timeout.
Repeated manual testing for LMStudio provider with the same timeout values.
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
Before

After

Documentation Updates
The UI guide should include:
Timeout for API requests to provider (min 5 min). If no response is received within this period, the request is retried. Increase this value for slower models.
Additional Notes
This is my first PR ever. So... do what you must.
Also, I am not a frontend developer, these code changes were done by LLM with my revisions.
Get in Touch
Important
Introduces customizable API timeout settings for self-hosted LLMs, updates UI components for user input, and adds translations in multiple languages.
provider-settings.ts.lm-studio.ts,ollama.ts, andopenai.tsby converting minutes to milliseconds.LMStudio.tsx,Ollama.tsx, andOpenAICompatible.tsxto include input fields for API timeout settings.settings.jsonforca,de,en,es,fr,hi,id,it,ja,ko,nl,pl,pt-BR,ru,tr,vi,zh-CN, andzh-TW.This description was created by
for 70e9ab6. You can customize this summary. It will automatically update as commits are pushed.