fix: raise hosted image generation timeouts · openclaw/openclaw@e485640
2026-05-17
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -235,8 +235,10 @@ from each attempt.
|
235 | 235 | <Accordion title="Timeouts"> |
236 | 236 | Set `agents.defaults.imageGenerationModel.timeoutMs` for slow image |
237 | 237 | backends. A per-call `timeoutMs` tool parameter overrides the configured |
238 | | -default. Codex dynamic-tool calls honor the same timeout budget, bounded |
239 | | -by OpenClaw's 600000 ms dynamic-tool bridge maximum. |
| 238 | +default. Google, OpenRouter, and xAI hosted image providers use 180 second |
| 239 | +defaults; Azure OpenAI image generation uses 600 seconds. Codex dynamic-tool |
| 240 | +calls honor the same timeout budget, bounded by OpenClaw's 600000 ms |
| 241 | +dynamic-tool bridge maximum. |
240 | 242 | </Accordion> |
241 | 243 | <Accordion title="Inspect at runtime"> |
242 | 244 | Use `action: "list"` to inspect the currently registered providers, |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -17,6 +17,7 @@ import {
|
17 | 17 | import { normalizeGoogleModelId, resolveGoogleGenerativeAiHttpRequestConfig } from "./api.js"; |
18 | 18 | |
19 | 19 | const DEFAULT_GOOGLE_IMAGE_MODEL = "gemini-3.1-flash-image-preview"; |
| 20 | +const DEFAULT_IMAGE_TIMEOUT_MS = 180_000; |
20 | 21 | const DEFAULT_OUTPUT_MIME = "image/png"; |
21 | 22 | const GOOGLE_SUPPORTED_SIZES = [ |
22 | 23 | "1024x1024", |
@@ -217,7 +218,7 @@ export function buildGoogleImageGenerationProvider(): ImageGenerationProvider {
|
217 | 218 | : {}), |
218 | 219 | }, |
219 | 220 | }, |
220 | | -timeoutMs: req.timeoutMs ?? 60_000, |
| 221 | +timeoutMs: req.timeoutMs ?? DEFAULT_IMAGE_TIMEOUT_MS, |
221 | 222 | fetchFn: fetch, |
222 | 223 | pinDns: false, |
223 | 224 | allowPrivateNetwork, |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -217,6 +217,44 @@ describe("openrouter image generation provider", () => {
|
217 | 217 | expect(release).toHaveBeenCalledOnce(); |
218 | 218 | }); |
219 | 219 | |
| 220 | +it("uses a 180s default timeout when no request timeout is provided", async () => { |
| 221 | +const release = vi.fn(async () => {}); |
| 222 | +postJsonRequestMock.mockResolvedValue({ |
| 223 | +response: { |
| 224 | +json: async () => ({ |
| 225 | +choices: [ |
| 226 | +{ |
| 227 | +message: { |
| 228 | +images: [ |
| 229 | +{ |
| 230 | +imageUrl: { |
| 231 | +url: `data:image/png;base64,${Buffer.from("png-one").toString("base64")}`, |
| 232 | +}, |
| 233 | +}, |
| 234 | +], |
| 235 | +}, |
| 236 | +}, |
| 237 | +], |
| 238 | +}), |
| 239 | +}, |
| 240 | + release, |
| 241 | +}); |
| 242 | + |
| 243 | +const provider = buildOpenRouterImageGenerationProvider(); |
| 244 | +await provider.generateImage({ |
| 245 | +provider: "openrouter", |
| 246 | +model: "google/gemini-3.1-flash-image-preview", |
| 247 | +prompt: "draw a sticker", |
| 248 | +cfg: {}, |
| 249 | +}); |
| 250 | + |
| 251 | +expect(postJsonRequestMock).toHaveBeenCalledWith( |
| 252 | +expect.objectContaining({ |
| 253 | +timeoutMs: 180_000, |
| 254 | +}), |
| 255 | +); |
| 256 | +}); |
| 257 | + |
220 | 258 | it("sends reference images as data URLs for edit-style requests", async () => { |
221 | 259 | postJsonRequestMock.mockResolvedValue({ |
222 | 260 | response: { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -19,7 +19,7 @@ import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runti
|
19 | 19 | import { OPENROUTER_BASE_URL } from "./provider-catalog.js"; |
20 | 20 | |
21 | 21 | const DEFAULT_MODEL = "google/gemini-3.1-flash-image-preview"; |
22 | | -const DEFAULT_TIMEOUT_MS = 90_000; |
| 22 | +const DEFAULT_TIMEOUT_MS = 180_000; |
23 | 23 | const MAX_IMAGE_RESULTS = 4; |
24 | 24 | const SUPPORTED_MODELS = [ |
25 | 25 | DEFAULT_MODEL, |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -167,6 +167,11 @@ describe("xai image generation provider", () => {
|
167 | 167 | expect(request.timeoutMs).toBe(180_000); |
168 | 168 | expect(request.body?.aspect_ratio).toBe("2:3"); |
169 | 169 | expect(request.body?.resolution).toBe("2k"); |
| 170 | +expect(resolveProviderOperationTimeoutMsMock).toHaveBeenCalledWith( |
| 171 | +expect.objectContaining({ |
| 172 | +defaultTimeoutMs: 180_000, |
| 173 | +}), |
| 174 | +); |
170 | 175 | }); |
171 | 176 | |
172 | 177 | it("supports edit with exact user-provided payload format including image object with type image_url", async () => { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。