Skip to content

[Feature] Add custom timout for slow LLM self-hosted #312

@leadvic

Description

@leadvic

🎯 The Goal / Use Case

Allow users to configure HTTP client timeout for LLM requests when using slow models or hardware (when self-hosting with Ollama for example). Currently, PicoClaw appears to have a hardcoded ~2 minute timeout that terminates requests before slower LLM backends (self-hosted Ollama with large models) can complete their inference.

Use case: Running PicoClaw with self-hosted Ollama on AMD integrated GPUs (Radeon Renoir) using Vulkan backend, or any scenario where model inference legitimately takes 3-10 minutes per response.

💡 Proposed Solution

Add a configurable environment variable (e.g., PICOCLAW_HTTP_TIMEOUT or PICOCLAW_REQUEST_TIMEOUT) that allows users to override the default HTTP client timeout. This would enable support for:

  • Self-hosted LLMs on consumer hardware (AMD/Intel GPUs via Vulkan)
  • Large models (70B+) running on limited resources
  • Complex multi-turn reasoning tasks that require extended inference time

Suggested default: Keep 2 minutes for API providers, but allow override for self-hosted scenarios.

🛠 Potential Implementation (Optional)

In the HTTP client initialization (likely in Go code):

func newHTTPClient() *http.Client {
    timeout := 2 * time.Minute // default
    
    if envTimeout := os.Getenv("PICOCLAW_HTTP_TIMEOUT"); envTimeout != "" {
        if d, err := time.ParseDuration(envTimeout); err == nil {
            timeout = d
        }
    }
    
    return &http.Client{
        Timeout: timeout,
    }
}

Then document in config.json or environment variables section. Or something like that I guess.

💬 Additional Context
Evidence from logs:

# PicoClaw logs - timeout at client side
2026/02/16 13:30:35 [ERROR] agent: LLM call failed {error=context deadline exceeded (Client.Timeout exceeded while awaiting headers)}

# Ollama logs - request processing for ~2 minutes before 500 error
[GIN] 2026/02/16 - 13:28:29 | 500 |         1m55s |      172.27.0.1 | POST     "/v1/chat/completions"
[GIN] 2026/02/16 - 13:30:35 | 500 |         1m59s |      172.27.0.1 | POST     "/v1/chat/completions"
time=2026-02-16T13:30:35.056Z level=INFO source=runner.go:916 msg="aborting completion request due to client closing the connection"
[GIN] 2026/02/16 - 13:31:00 | 500 |          2m0s |      172.27.0.1 | POST     "/v1/chat/completions"

As you can see it looks like the error from timout is from PicoClaw.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions