fix(design): add --api-timeout flag, raise default 120s to 300s for image-gen#1528
Open
RagavRida wants to merge 2 commits into
Open
fix(design): add --api-timeout flag, raise default 120s to 300s for image-gen#1528RagavRida wants to merge 2 commits into
RagavRida wants to merge 2 commits into
Conversation
…mage-gen Five image-generation callsites (generate, variants, iterate x2, evolve) hardcoded a 120_000ms ceiling with no CLI override. With default size (1536x1024) + quality:high on gpt-4o + image_generation tool, response time pushes into the 90-180s range on slower account tiers, tipping over the 120s ceiling for many users (issue garrytan#1519). - design/src/constants.ts: DEFAULT_IMAGE_GEN_TIMEOUT_MS = 300_000 - apiTimeoutMs?: number option threaded through GenerateOptions, VariantsOptions, IterateOptions, EvolveOptions - --api-timeout <ms> CLI flag (distinct from --timeout, which is plumbed only to compare --serve / serve for the HTTP listener) - Regression test pins the constant + verifies the AbortController honors the override via stubbed slow fetch Closes garrytan#1519.
…outMs budget callWithThreading + callFresh each received the full apiTimeoutMs, so the worst-case wait on --api-timeout 300000 was 600s (2×300s). Now a shared deadline is set at iteration start; callFresh receives the remaining budget after threading fails or times out, and if the budget is already exhausted at fallback entry a clear Timeout (Xs) error is thrown immediately.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1519.
Summary
The five image-generation callsites in the design binary all hardcoded a
120_000ms timeout with no CLI override:design/src/generate.ts:40design/src/iterate.ts:85and:133design/src/variants.ts:61design/src/evolve.ts:55With default settings (
gpt-4o,1536x1024,quality: high) using the Responses API with theimage_generationtool, response time pushes into the 90-180s range on slower account tiers and tips over the 120s ceiling for many users. The reporter in #1519 confirmed via curl that the endpoint itself isn't slow (~26s on direct calls) and that account/network were fine — the failure is entirely the binary's hardcoded ceiling.The existing
--timeoutCLI flag is plumbed only tocompare --serve/servefor the HTTP listener (design/src/cli.ts:145, 251), so it does not reach the image-gen path.Changes
design/src/constants.ts(new): exportsDEFAULT_IMAGE_GEN_TIMEOUT_MS = 300_000apiTimeoutMs?: numberoption added toGenerateOptions,VariantsOptions,IterateOptions,EvolveOptionsand threaded to the AbortController callsite in each--api-timeout <ms>CLI flag parsed once incli.tsand passed to all four commands. Distinct from--timeoutto avoid colliding with the serve flag.design/test/api-timeout.test.ts(new): pins the default constant at 300_000 and verifiesgenerateVarianthonors the override via a stubbed fetch that waits on the abort signal.Behavior
$D generate --brief "..." --api-timeout 600000for a 10-min ceiling."Timeout (120s)"to"Timeout (<n>ms)"so it stays accurate when the override is used.evolve's separate vision-analysis call (30s timeout,design/src/evolve.ts:113) is unchanged — that path is fast and doesn't need the headroom.Test results
bun run gen:skill-docswas run after editingcommands.ts; no SKILL.md drift (the design flag list isn't surfaced in user-visible templates).