feat: configurable LLM request timeout via LLM_REQUEST_TIMEOUT_SECS - #630
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a new feature that allows users to configure the HTTP request timeout for LLM API calls via the Highlights
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a configurable timeout for LLM API requests via the LLM_REQUEST_TIMEOUT_SECS environment variable. This addresses timeout issues experienced by users with local LLMs. The changes include updating the .env.example file, modifying the LlmConfig struct and its resolution logic, and adding corresponding unit tests. The timeout is applied across multiple LLM providers.
| pub fn new(config: NearAiConfig, session: Arc<SessionManager>) -> Result<Self, LlmError> { | ||
| Self::new_with_flatten(config, session, true) |
| fn build_http_client(timeout_secs: u64) -> Result<reqwest::Client, LlmError> { | ||
| reqwest::Client::builder() | ||
| .timeout(std::time::Duration::from_secs(timeout_secs)) | ||
| .build() | ||
| .map_err(|e| LlmError::RequestFailed { | ||
| provider: "http_client".to_string(), | ||
| reason: format!("Failed to build HTTP client: {e}"), | ||
| }) | ||
| } |
| None | ||
| }; | ||
|
|
||
| let request_timeout_secs = parse_optional_env("LLM_REQUEST_TIMEOUT_SECS", 120)?; |
e0213b6 to
35a1bdf
Compare
…615) Add LLM_REQUEST_TIMEOUT_SECS env var (default: 120) to configure the HTTP request timeout for LLM API calls. Primarily useful for local models (Ollama, vLLM, LM Studio) that need more time for prompt evaluation on consumer hardware. The timeout is applied to the NearAI provider's HTTP client. Other providers (Anthropic, OpenAI) use rig-core's default client. - Add request_timeout_secs field to LlmConfig - Thread timeout through create_llm_provider -> NearAiChatProvider - Add NearAiChatProvider::new_with_timeout constructor - Add .env.example documentation - 2 regression tests for default and custom timeout values Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
35a1bdf to
4eceb18
Compare
…earai#615) (nearai#630) Add LLM_REQUEST_TIMEOUT_SECS env var (default: 120) to configure the HTTP request timeout for LLM API calls. Primarily useful for local models (Ollama, vLLM, LM Studio) that need more time for prompt evaluation on consumer hardware. The timeout is applied to the NearAI provider's HTTP client. Other providers (Anthropic, OpenAI) use rig-core's default client. - Add request_timeout_secs field to LlmConfig - Thread timeout through create_llm_provider -> NearAiChatProvider - Add NearAiChatProvider::new_with_timeout constructor - Add .env.example documentation - 2 regression tests for default and custom timeout values Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
…earai#615) (nearai#630) Add LLM_REQUEST_TIMEOUT_SECS env var (default: 120) to configure the HTTP request timeout for LLM API calls. Primarily useful for local models (Ollama, vLLM, LM Studio) that need more time for prompt evaluation on consumer hardware. The timeout is applied to the NearAI provider's HTTP client. Other providers (Anthropic, OpenAI) use rig-core's default client. - Add request_timeout_secs field to LlmConfig - Thread timeout through create_llm_provider -> NearAiChatProvider - Add NearAiChatProvider::new_with_timeout constructor - Add .env.example documentation - 2 regression tests for default and custom timeout values Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Summary
Add
LLM_REQUEST_TIMEOUT_SECSenvironment variable (default: 120) to configure the HTTP request timeout for LLM API calls. Primarily useful for local models (Ollama, vLLM, LM Studio) that need more time for prompt evaluation on consumer hardware.The timeout is applied to the NearAI provider's HTTP client, which handles the majority of use cases including proxied local models.
Closes #615
Changes
request_timeout_secsfield toLlmConfigLLM_REQUEST_TIMEOUT_SECSenv var in config resolutioncreate_llm_provider->NearAiChatProvider::new_with_timeout.env.exampledocumentationTest plan
cargo clippy --all --all-featureszero warningscargo check --no-default-features --features libsqlcompilestest_request_timeout_defaults_to_120passestest_request_timeout_configurablepassesGenerated with Claude Code
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com