From 22009e90a4576764687328ed3cf81efbd2813d77 Mon Sep 17 00:00:00 2001 From: Florian <2320560+florianbuetow@users.noreply.github.com> Date: Sat, 31 Jan 2026 23:48:38 +0100 Subject: feat: add configurable request timeout for LLM calls Local LLMs (LM Studio, Ollama, etc.) often need more than the default 30-second timeout. Added request_timeout config option (in seconds) to [general] section and HEXAI_REQUEST_TIMEOUT env var. Original constructor signatures preserved via *WithTimeout variants, so no test changes required. --- internal/appconfig/config.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'internal/appconfig') diff --git a/internal/appconfig/config.go b/internal/appconfig/config.go index 78237be..b17c5d4 100644 --- a/internal/appconfig/config.go +++ b/internal/appconfig/config.go @@ -27,6 +27,7 @@ type App struct { ContextWindowLines int `json:"context_window_lines" toml:"context_window_lines"` MaxContextTokens int `json:"max_context_tokens" toml:"max_context_tokens"` LogPreviewLimit int `json:"log_preview_limit" toml:"log_preview_limit"` + RequestTimeout int `json:"request_timeout" toml:"request_timeout"` // Single knob for LSP requests; if set, overrides hardcoded temps in LSP. CodingTemperature *float64 `json:"coding_temperature" toml:"coding_temperature"` // Minimum identifier characters required for manual (TriggerKind=1) invoke @@ -141,6 +142,7 @@ func newDefaultConfig() App { ContextWindowLines: 120, MaxContextTokens: 4000, LogPreviewLimit: 100, + RequestTimeout: 30, CodingTemperature: &t, OpenAITemperature: &t, OllamaTemperature: &t, @@ -256,6 +258,7 @@ type sectionGeneral struct { ContextWindowLines int `toml:"context_window_lines"` MaxContextTokens int `toml:"max_context_tokens"` CodingTemperature *float64 `toml:"coding_temperature"` + RequestTimeout int `toml:"request_timeout"` } type sectionLogging struct { @@ -419,6 +422,7 @@ func (fc *fileConfig) toApp() App { ContextWindowLines: fc.General.ContextWindowLines, MaxContextTokens: fc.General.MaxContextTokens, CodingTemperature: fc.General.CodingTemperature, + RequestTimeout: fc.General.RequestTimeout, } out.mergeBasics(&tmp) } @@ -883,6 +887,9 @@ func (a *App) mergeBasics(other *App) { if other.LogPreviewLimit >= 0 { a.LogPreviewLimit = other.LogPreviewLimit } + if other.RequestTimeout > 0 { + a.RequestTimeout = other.RequestTimeout + } if other.CodingTemperature != nil { // allow explicit 0.0 a.CodingTemperature = other.CodingTemperature } @@ -1185,6 +1192,10 @@ func loadFromEnv(logger *log.Logger) *App { out.LogPreviewLimit = n any = true } + if n, ok := parseInt("HEXAI_REQUEST_TIMEOUT"); ok { + out.RequestTimeout = n + any = true + } if n, ok := parseInt("HEXAI_MANUAL_INVOKE_MIN_PREFIX"); ok { out.ManualInvokeMinPrefix = n any = true -- cgit v1.2.3