feat(replicate): add configurable maxWaitTimeInSeconds option for image generation#11296
feat(replicate): add configurable maxWaitTimeInSeconds option for image generation#11296
Conversation
…ge generation Co-authored-by: lgrammel <205036+lgrammel@users.noreply.github.com>
lgrammel
left a comment
There was a problem hiding this comment.
please add a changeset, update the replicate provider docs, and show me where in the replicate docs flexible waits are defined
…eInSeconds Co-authored-by: lgrammel <205036+lgrammel@users.noreply.github.com>
|
|
||
| // Build the prefer header based on maxWaitTimeInSeconds: | ||
| // - undefined/null: use default sync wait (prefer: wait) | ||
| // - 0: disable sync mode (no prefer header) |
There was a problem hiding this comment.
is disabling the sync mode supported in our code? if not we should not support it in the header (ie remove that part here)
There was a problem hiding this comment.
Removed the maxWaitTimeInSeconds: 0 (async mode) support since the provider code expects output to be immediately available and doesn't handle polling for async predictions. Changed the schema to use z.number().positive().nullish() and simplified the header logic in commit 196b213.
| * | ||
| * - When not specified: Uses default 60-second sync wait (`prefer: wait`) | ||
| * - When set to a positive number: Uses that duration (`prefer: wait=N`) | ||
| * - When set to 0: Disables sync mode (no `prefer` header), returning immediately |
There was a problem hiding this comment.
async mode might not be supported in the provider; rm
There was a problem hiding this comment.
Removed the async mode documentation from the schema comments in commit 196b213.
…'s not implemented Co-authored-by: lgrammel <205036+lgrammel@users.noreply.github.com>
Background
The Replicate provider hardcodes
prefer: 'wait'header, capping predictions at 60 seconds. Predictions exceeding this time fail silently. This affects popular models like nano banana pro that regularly exceed 60s.The flexible wait feature is documented in Replicate's API docs:
Prefer: wait=Ncan be used to specify a custom timeout durationSummary
Added
maxWaitTimeInSecondsprovider option to control sync wait duration:prefer: wait)prefer: wait=N)Manual Verification
Ran existing and new unit tests covering both header scenarios. Verified header construction logic and that
maxWaitTimeInSecondsis excluded from request body.Checklist
pnpm changesetin the project root)Future Work
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.