-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
base: main
Are you sure you want to change the base?
Conversation
})(), | ||
}} | ||
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 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.
})} | ||
type="text" | ||
inputMode="numeric" | ||
placeholder={t("settings:placeholders.numbers.maxTokens")} |
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")} |
})(), | ||
}} | ||
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 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> |
})} | ||
type="text" | ||
inputMode="numeric" | ||
placeholder={t("settings:placeholders.numbers.maxTokens")} |
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. |
this.client = new OpenAI({ | ||
baseURL: (this.options.lmStudioBaseUrl || "http://localhost:1234") + "/v1", | ||
apiKey: "noop", | ||
timeout: timeoutMs, |
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. |
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.
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. |
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
src
or test files.Pre-Submission Checklist
npm run lint
).console.log
) has been removed.npm test
).main
branch.npm run changeset
if 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
This PR adds customizable API timeout settings for self-hosted LLMs, updating backend logic and frontend UI to support user-defined timeouts up to 30 minutes.
openAiApiTimeout
,ollamaApiTimeout
, andlmStudioApiTimeout
settings inprovider-settings.ts
for customizable API timeouts.LmStudioHandler
,OllamaHandler
, andOpenAiHandler
to use the new timeout settings.LMStudio.tsx
,Ollama.tsx
, andOpenAICompatible.tsx
for user configuration.This description was created by
for 55685aa. You can customize this summary. It will automatically update as commits are pushed.