fix: add timeoutSeconds config for model providers#63191
fix: add timeoutSeconds config for model providers#63191uninhibited-scholar wants to merge 4 commits into
Conversation
- Extract path from image content blocks in tool results - This fixes Feishu image delivery when using the read tool - Previously, media paths were only extracted from MEDIA: tokens in text content, but read tool returns paths in image blocks Fixes issue where read tool image results lost media before final outbound payload assembly in Feishu channel. Closes openclaw#41744
- Extract MEDIA: tokens even when wrapped in code blocks - LLMs frequently format paths in code fences - Previously these were silently ignored causing delivery failures - Now tokens are extracted and delivered correctly Fixes openclaw#41966
Fixes tar security vulnerability (Symlink Path Traversal) Applied same fix as PR openclaw#42768 by futuremind2026
- Add timeoutSeconds field to ModelProviderConfig type and schema - Use provider-specific timeout for undici HTTP client - Fixes issue openclaw#63156 where HTTP client timeout was hardcoded - Allows users to configure custom timeouts for LM Studio, Ollama, and other providers Example config: ```json { "models": { "providers": { "lm-studio": { "baseUrl": "http://127.0.0.1:1234/v1", "api": "openai-completions", "timeoutSeconds": 180 } } } } ```
Greptile SummaryThis PR adds a
Confidence Score: 2/5Not safe to merge — the The timeout feature itself (types, schema, attempt.ts wiring) is sound and well-structured, but the accompanying src/media/parse.ts — duplicate
|
| // Use provider-specific timeout if configured, otherwise use agent default | ||
| const providerConfig = params.config?.models?.providers?.[params.provider]; | ||
| const providerTimeoutSeconds = providerConfig?.timeoutSeconds; | ||
| const timeoutMs = providerTimeoutSeconds | ||
| ? providerTimeoutSeconds * 1000 | ||
| : undefined; | ||
| ensureGlobalUndiciStreamTimeouts({ timeoutMs }); |
There was a problem hiding this comment.
Global dispatcher replaced per-attempt — concurrent providers share one timeout
ensureGlobalUndiciStreamTimeouts replaces the single process-wide undici dispatcher. When two agents run concurrently (e.g. a 180 s lm-studio run and a default openai run), the second call overwrites the timeout for all in-flight HTTP requests, including the first agent's ongoing stream. The last runEmbeddedAttempt to start wins, which makes provider-specific timeouts non-deterministic under concurrency. Consider gating this only when a value is explicitly set and, longer-term, using per-client dispatchers rather than the global one.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agents/pi-embedded-runner/run/attempt.ts
Line: 753-759
Comment:
**Global dispatcher replaced per-attempt — concurrent providers share one timeout**
`ensureGlobalUndiciStreamTimeouts` replaces the single process-wide undici dispatcher. When two agents run concurrently (e.g. a 180 s lm-studio run and a default openai run), the second call overwrites the timeout for all in-flight HTTP requests, including the first agent's ongoing stream. The last `runEmbeddedAttempt` to start wins, which makes provider-specific timeouts non-deterministic under concurrency. Consider gating this only when a value is explicitly set and, longer-term, using per-client dispatchers rather than the global one.
How can I resolve this? If you propose a fix, please make it concise.|
Closing in favor of #65143 — clean rewrite with only the |
Summary
This PR adds a configurable
timeoutSecondsfield to model provider configuration, allowing users to customize HTTP client timeouts for different providers.Changes
timeoutSeconds?: numbertoModelProviderConfigtypetimeoutSecondsfield inModelProviderSchemaMotivation
Fixes issue #63156 where HTTP client timeout was effectively hardcoded, causing request failures when prompt processing exceeded the default timeout. This is especially problematic for:
Usage
Users can now configure provider-specific timeouts:
{ "models": { "providers": { "lm-studio": { "baseUrl": "http://127.0.0.1:1234/v1", "api": "openai-completions", "timeoutSeconds": 180 }, "ollama": { "baseUrl": "http://127.0.0.1:11434", "api": "ollama", "timeoutSeconds": 300 } } } }Testing
Related Issues