From 7078d9d1e29ddc6e6e90572744b33d34c119477c Mon Sep 17 00:00:00 2001 From: Brooklyn Nicholson Date: Thu, 25 Jun 2026 00:32:48 -0500 Subject: [PATCH] fix(pets): raise generation timeouts for the slow quality-first model path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The quality-first default (OpenAI image via OpenRouter) is slow, and a full hatch fans out ~8 rows with up to 3 retries each (300s/call) across 2 parallel waves, so the absolute backend worst case is ~30 min. The old ceilings fired mid-run: - per-image HTTP call: 180s -> 300s (a single cold row can exceed 3 min) - drafts RPC: 240s -> 420s (single wave, no retries — 7 min is ample) - hatch RPC: 420s -> 1hr (sits above the ~30 min backend worst case) The hatch ceiling is intentionally well above the realistic max so the frontend never throws "request timed out" before the backend has exhausted its own retries. The background-resumable notification path remains the real UX safety net — the user can close the modal and get pinged on completion. --- apps/desktop/src/store/pet-generate.ts | 14 +++++++++----- plugins/image_gen/openrouter/__init__.py | 5 ++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/apps/desktop/src/store/pet-generate.ts b/apps/desktop/src/store/pet-generate.ts index 2b7962775aa3..5713b04a8a78 100644 --- a/apps/desktop/src/store/pet-generate.ts +++ b/apps/desktop/src/store/pet-generate.ts @@ -22,11 +22,15 @@ import { applyAdoptedPet, type GatewayRequest } from '@/store/pet-gallery' */ // Generation is many grounded image calls — far longer than the default 30s RPC -// timeout. Drafts fan out 4 base looks; hatch fans out ~8 animation rows. Even -// parallelized, a cold provider call is slow, so we give these calls real -// headroom (the bug was "request timed out: pet.generate" on the 30s default). -const GENERATE_TIMEOUT_MS = 240_000 -const HATCH_TIMEOUT_MS = 420_000 +// timeout. Drafts fan out 4 base looks; hatch fans out ~8 animation rows. The +// quality-first default (OpenAI image via OpenRouter) is slow, and each hatch +// row can retry up to 3x (300s/call) across 2 parallel waves, so the absolute +// backend worst case is ~30 min. The hatch ceiling sits above that (1h) so the +// frontend never throws "request timed out" before the backend has actually +// exhausted its own retries — the background-resumable notify path is the real +// UX safety net (the user can close the modal and get pinged on completion). +const GENERATE_TIMEOUT_MS = 420_000 +const HATCH_TIMEOUT_MS = 3_600_000 // Filler words to drop when deriving a default name from a free-text prompt. const NAME_STOPWORDS = new Set([ diff --git a/plugins/image_gen/openrouter/__init__.py b/plugins/image_gen/openrouter/__init__.py index 5b2b105d0402..d15aaabd53b0 100644 --- a/plugins/image_gen/openrouter/__init__.py +++ b/plugins/image_gen/openrouter/__init__.py @@ -64,7 +64,10 @@ _ASPECT_RATIOS = { # so we never overflow the model's limit. _MAX_REFERENCE_IMAGES = 3 -_REQUEST_TIMEOUT = 180.0 +# Per single image call. The quality-first default (OpenAI image via OpenRouter) +# is genuinely slow — a single cold row can run well past 3 minutes — so give +# each call real headroom before we treat it as hung and fall back / retry. +_REQUEST_TIMEOUT = 300.0 def _load_image_gen_config() -> Dict[str, Any]: