Skip to content

fix(imagegen): bump image-to-image timeout to 180s (was 60s shared with t2i)#19

Merged
1bcMax merged 1 commit intomainfrom
fix/imagegen-i2i-timeout
Apr 28, 2026
Merged

fix(imagegen): bump image-to-image timeout to 180s (was 60s shared with t2i)#19
1bcMax merged 1 commit intomainfrom
fix/imagegen-i2i-timeout

Conversation

@KillerQueen-Z
Copy link
Copy Markdown
Collaborator

Summary

The 60s setTimeout on the main /v1/images/{generations,image2image} fetch in src/tools/imagegen.ts covers both x402 retry attempts AND the actual generation. That budget is generous for text-to-image but consistently insufficient for image-to-image with gpt-image-2.

Root cause

```typescript
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 60_000); // 60s timeout
```

For text-to-image (gpt-image-1, ~10–30s) — fine. For image-to-image (gpt-image-2):

  • gpt-image-2 is reasoning-driven; an edit easily takes 60–150s on its own.
  • The request body carries a few MB of base64 reference image, adding measurable upload time.
  • The timeout shares its budget across the 402 round trip plus the paid retry.

End result: every gpt-image-2 image-to-image call hits `AbortError` before upstream returns, with a misleading error message ("Image generation timed out (60s limit). Try a simpler prompt.") that made it look like a server problem.

Reproduction

```bash
franklin
/model sonnet

use openai/gpt-image-2 with reference image /any/normal/photo.png to generate
```

Hangs at AbortError every time on a 1–4MB reference image.

Fix

Split the budget by mode:

  • image-to-image: 180s (3 minutes — comfortably covers worst-case gpt-image-2 edits)
  • text-to-image: 60s (unchanged)

Also updates the timeout error message so users know the longer limit applies and gives more relevant remediation hints (smaller image / simpler prompt) when the reference-image path was taken.

Out of scope

  • The existing 30s timeouts on `resolveReferenceImage` (URL fetch) and on the result download stay unchanged — those are network-bound and shouldn't routinely be slow.
  • No change to text-to-image behavior, x402 flow, or the request schema.

Test plan

  1. Pick any 1–4MB PNG.
  2. `franklin` → `/model sonnet`
  3. `use openai/gpt-image-2 with reference image /path/to/img.png to generate something`
  4. Before this patch: AbortError after ~60s every time.
  5. After this patch: completes in 60–120s typically; only hits the new 180s ceiling under truly degraded conditions.

```
src/tools/imagegen.ts | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
```

…th t2i)

The single 60s timeout on the main /v1/images/{generations,image2image}
fetch covered both x402 retry attempts AND the actual generation. That
budget is generous for text-to-image (gpt-image-1 finishes in 10–30s)
but consistently insufficient for image-to-image:

- gpt-image-2 is reasoning-driven; an edit easily takes 60–150s on its
  own
- the request body carries a few MB of base64 reference image, adding
  measurable upload time on slower links
- the timeout has to share its budget across two POSTs (the 402 round
  trip plus the paid one)

End result: every gpt-image-2 reference-image call I tried hit AbortError
before the upstream model returned, with a misleading message ("Try a
simpler prompt") that made it look like a server problem.

This patch:
- splits the budget — image-to-image gets 180s, text-to-image keeps 60s
- updates the timeout error message to mention the 180s limit and the
  most likely causes (image too large, model under load) when the
  reference-image path is taken

The existing 30s timeouts on resolveReferenceImage (URL fetch) and on
the result download stay unchanged — those are network-bound and
shouldn't routinely be slow.
KillerQueen-Z added a commit that referenced this pull request Apr 28, 2026
…timeout

UX
- New mascot artwork on the empty state: a bigger AI+coin themed
  Franklin pixel-art portrait. The PNG ships with a flood-filled
  alpha channel so the mascot composites directly onto whichever
  theme background sits behind the panel — no rounded-rectangle
  frame, no mix-blend-mode hack. Original PNG (with the dark frame)
  also kept on disk as franklin-mascot.png for record / fallback.
- Settings popover gains a "Per-turn spend cap (USD)" field. Empty
  keeps the existing $0.25 default; "0" disables the cap entirely;
  any positive number sets it. Local mirror of core PR #20.

Core (cherry-picks of in-flight PRs)
- src/tools/imagegen.ts: image-to-image gets a 180s timeout (was
  shared 60s with text-to-image — gpt-image-2 edits on a few-MB
  reference image consistently hit AbortError before completion).
  Mirror of PR #19.
- src/agent/loop.ts + src/commands/config.ts: MAX_TURN_SPEND_USD
  is no longer hard-coded; reads max-turn-spend-usd from config
  with fallback to $0.25. Mirror of PR #20.

Bumps vscode-extension to 0.4.5; updates README changelog.
@1bcMax 1bcMax merged commit 1aaa77b into main Apr 28, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant