Skip to content

feat: configurable LLM request timeout via LLM_REQUEST_TIMEOUT_SECS - #630

Merged
ilblackdragon merged 1 commit into
mainfrom
fix/615-configurable-llm-timeout
Mar 8, 2026
Merged

ilblackdragon merged 1 commit into
mainfrom
fix/615-configurable-llm-timeout

Conversation

@zmanian

@zmanian zmanian commented Mar 6, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Add LLM_REQUEST_TIMEOUT_SECS environment 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

  • Add request_timeout_secs field to LlmConfig
  • Parse LLM_REQUEST_TIMEOUT_SECS env var in config resolution
  • Thread timeout through create_llm_provider -> NearAiChatProvider::new_with_timeout
  • Add .env.example documentation
  • 2 regression tests for default and custom timeout values

Test plan

  • cargo clippy --all --all-features zero warnings
  • cargo check --no-default-features --features libsql compiles
  • test_request_timeout_defaults_to_120 passes
  • test_request_timeout_configurable passes

Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

@github-actions github-actions Bot added size: M 50-199 changed lines scope: llm LLM integration scope: setup Onboarding / setup risk: high Safety, secrets, auth, or critical infrastructure contributor: core 20+ merged PRs and removed size: M 50-199 changed lines labels Mar 6, 2026
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 LLM_REQUEST_TIMEOUT_SECS environment variable. This change primarily addresses timeout issues experienced by users of local LLMs, where prompt evaluation can take a significant amount of time. The new timeout setting is applied consistently across all supported LLM providers.

Highlights

  • New Feature: Introduced LLM_REQUEST_TIMEOUT_SECS environment variable to configure the HTTP request timeout for LLM API calls.
  • Fix: Addressed timeout failures for local LLM users (Ollama, LM Studio, vLLM) by allowing configuration of the request timeout.
  • Provider Support: Implemented the timeout configuration across six LLM providers: NEAR AI, OpenAI, Anthropic, Ollama, OpenAI-compatible, and Tinfoil.
Activity
  • Added LLM_REQUEST_TIMEOUT_SECS env var (default: 120s) to configure HTTP request timeout for all LLM API calls
  • Fixed timeout failures for local LLM users (Ollama, LM Studio, vLLM) where prompt evaluation on consumer hardware can take 30-120+ seconds
  • Timeout is threaded through all 6 providers: NEAR AI, OpenAI, Anthropic, Ollama, OpenAI-compatible, Tinfoil
  • Completed test_request_timeout_defaults_to_120 to verifies default
  • Completed test_request_timeout_configurable to verifies env var override
  • Verified cargo clippy --all --all-features clean
  • Verified cargo check clean
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/llm/nearai_chat.rs
Comment on lines 60 to -61
pub fn new(config: NearAiConfig, session: Arc<SessionManager>) -> Result<Self, LlmError> {
Self::new_with_flatten(config, session, true)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider using the new_with_options function directly to avoid the extra function call.

        Self::new_with_options(config, session, true, 120)

Comment thread src/llm/mod.rs Outdated
Comment on lines 99 to 107
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}"),
})
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider adding a comment explaining why the provider field is hardcoded to http_client.

Comment thread src/config/llm.rs Outdated
None
};

let request_timeout_secs = parse_optional_env("LLM_REQUEST_TIMEOUT_SECS", 120)?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider adding a comment explaining why the default timeout is 120 seconds.

@zmanian
zmanian force-pushed the fix/615-configurable-llm-timeout branch from e0213b6 to 35a1bdf Compare March 7, 2026 15:27
@github-actions github-actions Bot added scope: tool/builtin Built-in tools size: L 200-499 changed lines labels Mar 7, 2026
…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>
@zmanian
zmanian force-pushed the fix/615-configurable-llm-timeout branch from 35a1bdf to 4eceb18 Compare March 7, 2026 23:30
@github-actions github-actions Bot added size: M 50-199 changed lines and removed size: L 200-499 changed lines labels Mar 7, 2026
@ilblackdragon
ilblackdragon merged commit 200aed1 into main Mar 8, 2026
22 checks passed
@ilblackdragon
ilblackdragon deleted the fix/615-configurable-llm-timeout branch March 8, 2026 08:30
This was referenced Mar 8, 2026
bkutasi pushed a commit to bkutasi/ironclaw that referenced this pull request Mar 28, 2026
…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>
drchirag1991 pushed a commit to drchirag1991/ironclaw that referenced this pull request Apr 8, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor: core 20+ merged PRs risk: high Safety, secrets, auth, or critical infrastructure scope: llm LLM integration scope: setup Onboarding / setup scope: tool/builtin Built-in tools size: M 50-199 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proposal - Configurable Request Timeouts for Local LLM Setups

2 participants