From 37cc163d05fcaa6d2b8f5742bf98ab94d6b51cc7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 26 Jan 2026 19:22:55 +0000 Subject: [PATCH 1/3] Initial plan From e05b1d37d4c7086217f3b5d861fd65be717b19c9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 26 Jan 2026 19:28:13 +0000 Subject: [PATCH 2/3] Configure extended timeouts for Ollama HttpClient to fix local LLM timeouts Co-authored-by: hammar <68027+hammar@users.noreply.github.com> --- LocalAgent.ApiService/Program.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/LocalAgent.ApiService/Program.cs b/LocalAgent.ApiService/Program.cs index e46b786..3d3b1ae 100644 --- a/LocalAgent.ApiService/Program.cs +++ b/LocalAgent.ApiService/Program.cs @@ -26,6 +26,28 @@ .UseFunctionInvocation() .UseOpenTelemetry(configure: t => t.EnableSensitiveData = true); +// Configure extended timeouts for local LLM operations +// The HttpClient naming convention is "{connectionName}_httpClient" +builder.Services.AddHttpClient("llama32_httpClient") + .ConfigurePrimaryHttpMessageHandler(() => new SocketsHttpHandler + { + // Disable HttpClient's own timeout to avoid conflicts with resilience pipeline + PooledConnectionLifetime = TimeSpan.FromMinutes(10), + PooledConnectionIdleTimeout = TimeSpan.FromMinutes(5) + }) + .ConfigureHttpClient(client => + { + // Set to infinite to let the resilience pipeline handle timeouts + client.Timeout = Timeout.InfiniteTimeSpan; + }) + .AddStandardResilienceHandler(options => + { + // Increase total request timeout to 5 minutes for local LLM inference + options.TotalRequestTimeout.Timeout = TimeSpan.FromMinutes(5); + // Increase attempt timeout to 4 minutes + options.AttemptTimeout.Timeout = TimeSpan.FromMinutes(4); + }); + builder.Services.AddSingleton(sp => { var mcpServerEndpoint = builder.Configuration.GetConnectionString("McpServer")!; From 22f7971c08e9e97ac554b9293bc5dbb9a2a39f61 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 26 Jan 2026 19:29:19 +0000 Subject: [PATCH 3/3] Address code review feedback: Fix comments and adjust timeout values Co-authored-by: hammar <68027+hammar@users.noreply.github.com> --- LocalAgent.ApiService/Program.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/LocalAgent.ApiService/Program.cs b/LocalAgent.ApiService/Program.cs index 3d3b1ae..f16846f 100644 --- a/LocalAgent.ApiService/Program.cs +++ b/LocalAgent.ApiService/Program.cs @@ -31,7 +31,7 @@ builder.Services.AddHttpClient("llama32_httpClient") .ConfigurePrimaryHttpMessageHandler(() => new SocketsHttpHandler { - // Disable HttpClient's own timeout to avoid conflicts with resilience pipeline + // Configure connection pooling to keep connections alive longer for LLM requests PooledConnectionLifetime = TimeSpan.FromMinutes(10), PooledConnectionIdleTimeout = TimeSpan.FromMinutes(5) }) @@ -44,8 +44,8 @@ { // Increase total request timeout to 5 minutes for local LLM inference options.TotalRequestTimeout.Timeout = TimeSpan.FromMinutes(5); - // Increase attempt timeout to 4 minutes - options.AttemptTimeout.Timeout = TimeSpan.FromMinutes(4); + // Increase attempt timeout to 2 minutes, leaving room for retry logic + options.AttemptTimeout.Timeout = TimeSpan.FromMinutes(2); }); builder.Services.AddSingleton(sp =>