惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

量子位
WordPress大学
WordPress大学
小众软件
小众软件
云风的 BLOG
云风的 BLOG
IT之家
IT之家
人人都是产品经理
人人都是产品经理
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Last Week in AI
Last Week in AI
博客园 - 【当耐特】
T
Tailwind CSS Blog
阮一峰的网络日志
阮一峰的网络日志
V
V2EX
宝玉的分享
宝玉的分享
博客园 - Franky
F
Fortinet All Blogs
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
GbyAI
GbyAI
Hugging Face - Blog
Hugging Face - Blog
Jina AI
Jina AI
D
Docker
博客园 - 聂微东
C
Check Point Blog
H
Help Net Security

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(ollama): scope request timeouts to providers · opencl...
steipete · 2026-04-27 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -45,6 +45,7 @@ Docs: https://docs.openclaw.ai

4545

- Providers/Ollama: accept OpenAI SDK-style `baseURL` as an alias for `baseUrl` across discovery, streaming, setup pulls, embeddings, and web search so remote Ollama hosts are not silently ignored. Fixes #62533; supersedes #62549. Thanks @Julien-BKK and @Linux2010.

4646

- Providers/Ollama: scope synthetic local auth and embedding bearer headers to declared Ollama host boundaries so cloud keys are not sent to local/self-hosted embedding endpoints and remote/cloud Ollama endpoints no longer receive the `ollama-local` marker as if it were a real token. Supersedes #69261 and #69857; refs #43945. Thanks @hyspacex, @maxramsay, and @Meli73.

4747

- Providers/Ollama: resolve custom-named local Ollama providers such as `ollama-remote` through the Ollama synthetic-auth hook so subagents no longer miss `ollama-local` auth and silently fall back to cloud models. Fixes #43945. Thanks @Meli73 and @maxramsay.

48+

- Providers/Ollama: add provider-scoped model request timeouts, thread them through guarded fetch connect/header/body/abort handling, and document `params.keep_alive` for cold local models so first-turn Ollama loads no longer require global agent timeout changes. Fixes #64541 and #68796; supersedes #65143 and #66511. Thanks @LittleJakub, @Juankcba, @uninhibite-scholar, and @yfge.

4849

- Providers/PDF/Ollama: add bounded network timeouts for Ollama model pulls and native Anthropic/Gemini PDF analysis requests so unresponsive provider endpoints no longer hang sessions indefinitely. Fixes #54142; supersedes #54144 and #54145. Thanks @jinduwang1001-max and @arkyu2077.

4950

- Memory/doctor: treat Ollama memory embeddings as key-optional so `openclaw doctor` no longer warns about a missing API key when the gateway reports embeddings are ready. Fixes #46584. Thanks @fengly78.

5051

- Agents/Ollama: apply provider-owned replay turn normalization to native Ollama chat so Cloud models no longer reject non-alternating replay history in agent/Gateway runs. Fixes #71697. Thanks @ismael-81.

Original file line numberDiff line numberDiff line change

@@ -1,4 +1,4 @@

1-

0c3eaaee031f0adec2fcfc8a3a6a0d80dfc19d4d1c10b0ff4249b30e04b3c47d config-baseline.json

2-

420269ce22f17382cb253c80a232329e943296be101cda313506341ae39cc674 config-baseline.core.json

1+

6fceeca87ecf3245c9f3a184f1ec66c8dee8df6e5a14c6d9d1924557f8d36408 config-baseline.json

2+

15b6223907d0930307e950752e6498edc40f7df597e8e36914490f7611eab413 config-baseline.core.json

33

07963db49502132f26db396c56b36e018b110e6c55a68b3cb012d3ec96f43901 config-baseline.channel.json

44

74b74cb18ac37c0acaa765f398f1f9edbcee4c43567f02d45c89598a1e13afb4 config-baseline.plugin.json

Original file line numberDiff line numberDiff line change

@@ -163,6 +163,7 @@ surfaces, while Codex native hooks remain a separate lower-level Codex mechanism

163163

- `agent.wait` default: 30s (just the wait). `timeoutMs` param overrides.

164164

- Agent runtime: `agents.defaults.timeoutSeconds` default 172800s (48 hours); enforced in `runEmbeddedPiAgent` abort timer.

165165

- LLM idle timeout: `agents.defaults.llm.idleTimeoutSeconds` aborts a model request when no response chunks arrive before the idle window. Set it explicitly for slow local models or reasoning/tool-call providers; set it to 0 to disable. If it is not set, OpenClaw uses `agents.defaults.timeoutSeconds` when configured, otherwise 120s. Cron-triggered runs with no explicit LLM or agent timeout disable the idle watchdog and rely on the cron outer timeout.

166+

- Provider HTTP request timeout: `models.providers.<id>.timeoutSeconds` applies only to that provider's model HTTP fetches, including connect, headers, body, and total guarded-fetch abort handling. Use this for slow local/self-hosted providers such as Ollama before raising the whole agent runtime timeout.

166167
167168

## Where things can end early

168169
Original file line numberDiff line numberDiff line change

@@ -429,6 +429,7 @@ OpenClaw uses the built-in model catalog. Add custom providers via `models.provi

429429

- `models.providers.*.api`: request adapter (`openai-completions`, `openai-responses`, `anthropic-messages`, `google-generative-ai`, etc).

430430

- `models.providers.*.apiKey`: provider credential (prefer SecretRef/env substitution).

431431

- `models.providers.*.auth`: auth strategy (`api-key`, `token`, `oauth`, `aws-sdk`).

432+

- `models.providers.*.timeoutSeconds`: optional per-provider model HTTP request timeout in seconds, including connect, headers, body, and total request abort handling.

432433

- `models.providers.*.injectNumCtxForOpenAICompat`: for Ollama + `openai-completions`, inject `options.num_ctx` into requests (default: `true`).

433434

- `models.providers.*.authHeader`: force credential transport in the `Authorization` header when required.

434435

- `models.providers.*.baseUrl`: upstream API base URL.

Original file line numberDiff line numberDiff line change

@@ -296,6 +296,16 @@ OpenClaw rejects image-description requests for models that are not marked image

296296

apiKey: "ollama-local",

297297

baseUrl: "http://ollama-host:11434", // No /v1 - use native Ollama API URL

298298

api: "ollama", // Set explicitly to guarantee native tool-calling behavior

299+

timeoutSeconds: 300, // Optional: give cold local models longer to connect and stream

300+

models: [

301+

{

302+

id: "qwen3:32b",

303+

name: "qwen3:32b",

304+

params: {

305+

keep_alive: "15m", // Optional: keep the model loaded between turns

306+

},

307+

},

308+

],

299309

},

300310

},

301311

},

@@ -330,6 +340,33 @@ Custom Ollama provider ids are also supported. When a model ref uses the active

330340

provider prefix, such as `ollama-spark/qwen3:32b`, OpenClaw strips only that

331341

prefix before calling Ollama so the server receives `qwen3:32b`.

332342
343+

For slow local models, prefer provider-scoped request tuning before raising the

344+

whole agent runtime timeout:

345+
346+

```json5

347+

{

348+

models: {

349+

providers: {

350+

ollama: {

351+

timeoutSeconds: 300,

352+

models: [

353+

{

354+

id: "gemma4:26b",

355+

name: "gemma4:26b",

356+

params: { keep_alive: "15m" },

357+

},

358+

],

359+

},

360+

},

361+

},

362+

}

363+

```

364+
365+

`timeoutSeconds` applies to the model HTTP request, including connection setup,

366+

headers, body streaming, and the total guarded-fetch abort. `params.keep_alive`

367+

is forwarded to Ollama as top-level `keep_alive` on native `/api/chat` requests;

368+

set it per model when first-turn load time is the bottleneck.

369+
333370

## Ollama Web Search

334371
335372

OpenClaw supports **Ollama Web Search** as a bundled `web_search` provider.

@@ -535,6 +572,32 @@ For the full setup and behavior details, see [Ollama Web Search](/tools/ollama-s

535572

```

536573
537574

</Accordion>

575+
576+

<Accordion title="Cold local model times out">

577+

Large local models can need a long first load before streaming begins. Keep the timeout scoped to the Ollama provider, and optionally ask Ollama to keep the model loaded between turns:

578+
579+

```json5

580+

{

581+

models: {

582+

providers: {

583+

ollama: {

584+

timeoutSeconds: 300,

585+

models: [

586+

{

587+

id: "gemma4:26b",

588+

name: "gemma4:26b",

589+

params: { keep_alive: "15m" },

590+

},

591+

],

592+

},

593+

},

594+

},

595+

}

596+

```

597+
598+

If the host itself is slow to accept connections, `timeoutSeconds` also extends the guarded Undici connect timeout for this provider.

599+
600+

</Accordion>

538601

</AccordionGroup>

539602
540603

<Note>

Original file line numberDiff line numberDiff line change

@@ -27,6 +27,7 @@ describe.skipIf(!LIVE)("ollama live", () => {

2727

| {

2828

model?: string;

2929

think?: boolean;

30+

keep_alive?: string;

3031

options?: { num_ctx?: number; top_p?: number };

3132

tools?: Array<{

3233

function?: {

@@ -44,7 +45,8 @@ describe.skipIf(!LIVE)("ollama live", () => {

4445

api: "ollama",

4546

provider: PROVIDER_ID,

4647

contextWindow: 8192,

47-

params: { num_ctx: 4096, top_p: 0.9, thinking: false },

48+

params: { num_ctx: 4096, top_p: 0.9, thinking: false, keep_alive: "5m" },

49+

requestTimeoutMs: 120_000,

4850

} as never,

4951

{

5052

messages: [{ role: "user", content: "Reply exactly OK." }],

@@ -85,6 +87,7 @@ describe.skipIf(!LIVE)("ollama live", () => {

8587

expect(payload?.options?.num_ctx).toBe(4096);

8688

expect(payload?.options?.top_p).toBe(0.9);

8789

expect(payload?.think).toBe(false);

90+

expect(payload?.keep_alive).toBe("5m");

8891

const properties = payload?.tools?.[0]?.function?.parameters?.properties;

8992

expect(properties?.city?.type).toBe("string");

9093

expect(properties?.units?.type).toBe("string");

Original file line numberDiff line numberDiff line change

@@ -23,6 +23,7 @@ type GuardedFetchCall = {

2323

url: string;

2424

init?: RequestInit;

2525

policy?: unknown;

26+

timeoutMs?: number;

2627

auditContext?: string;

2728

};

2829

@@ -264,6 +265,25 @@ describe("createConfiguredOllamaCompatStreamWrapper", () => {

264265

);

265266

});

266267
268+

it("passes resolved provider request timeouts to native Ollama chat fetches", async () => {

269+

await withMockNdjsonFetch(

270+

[

271+

'{"model":"m","created_at":"t","message":{"role":"assistant","content":"ok"},"done":false}',

272+

'{"model":"m","created_at":"t","message":{"role":"assistant","content":""},"done":true,"prompt_eval_count":1,"eval_count":1}',

273+

],

274+

async (fetchMock) => {

275+

const stream = await createOllamaTestStream({

276+

baseUrl: "http://ollama-host:11434",

277+

model: { requestTimeoutMs: 450_000 },

278+

});

279+
280+

await collectStreamEvents(stream);

281+
282+

expect(getGuardedFetchCall(fetchMock).timeoutMs).toBe(450_000);

283+

},

284+

);

285+

});

286+
267287

it("maps native Ollama max thinking to think=high on the wire", async () => {

268288

await withMockNdjsonFetch(

269289

[

Original file line numberDiff line numberDiff line change

@@ -817,6 +817,15 @@ function resolveOllamaModelHeaders(model: {

817817

return model.headers as Record<string, string>;

818818

}

819819
820+

function resolveOllamaRequestTimeoutMs(

821+

model: object,

822+

options: { requestTimeoutMs?: unknown } | undefined,

823+

): number | undefined {

824+

const raw =

825+

options?.requestTimeoutMs ?? (model as { requestTimeoutMs?: unknown }).requestTimeoutMs;

826+

return typeof raw === "number" && Number.isFinite(raw) && raw > 0 ? Math.floor(raw) : undefined;

827+

}

828+
820829

export function createOllamaStreamFn(

821830

baseUrl: string,

822831

defaultHeaders?: Record<string, string>,

@@ -874,6 +883,10 @@ export function createOllamaStreamFn(

874883

signal: options?.signal,

875884

},

876885

policy: ssrfPolicy,

886+

timeoutMs: resolveOllamaRequestTimeoutMs(

887+

model,

888+

options as { requestTimeoutMs?: unknown } | undefined,

889+

),

877890

auditContext: "ollama-stream.chat",

878891

});

879892
Original file line numberDiff line numberDiff line change

@@ -22,6 +22,7 @@ export type InlineProviderConfig = {

2222

models?: ModelDefinitionConfig[];

2323

headers?: unknown;

2424

authHeader?: boolean;

25+

timeoutSeconds?: ModelProviderConfig["timeoutSeconds"];

2526

request?: ModelProviderConfig["request"];

2627

};

2728
Original file line numberDiff line numberDiff line change

@@ -414,6 +414,35 @@ describe("resolveModel", () => {

414414

});

415415

});

416416
417+

it("resolves provider request timeout metadata for configured provider models", () => {

418+

mockDiscoveredModel(discoverModels, {

419+

provider: "ollama",

420+

modelId: "qwen3:32b",

421+

templateModel: {

422+

...makeModel("qwen3:32b"),

423+

provider: "ollama",

424+

},

425+

});

426+

const cfg = {

427+

models: {

428+

providers: {

429+

ollama: {

430+

baseUrl: "http://localhost:11434",

431+

timeoutSeconds: 300,

432+

models: [makeModel("qwen3:32b")],

433+

},

434+

},

435+

},

436+

} as unknown as OpenClawConfig;

437+
438+

const result = resolveModelForTest("ollama", "qwen3:32b", "/tmp/agent", cfg);

439+
440+

expect(result.error).toBeUndefined();

441+

expect((result.model as { requestTimeoutMs?: number } | undefined)?.requestTimeoutMs).toBe(

442+

300_000,

443+

);

444+

});

445+
417446

it("applies agent default model params without explicit provider config", () => {

418447

mockDiscoveredModel(discoverModels, {

419448

provider: "ollama",