Long-running image and video generation should be treated as durable work that can outlive an agent turn, browser session, or worker request. Submit once, retain the job identity, observe the existing job, and retrieve the finished artifact. A timeout in the caller should not silently create another paid generation.
This guide describes a reference lifecycle for media tools and the relevant recovery behavior in o11’s source. It is not a live provider test. Exact states, cancellation, billing, retention, and supported follow-up operations must be verified for the selected model and account.
Separate submission from completion
Submission means a provider accepted a request or placed it in a queue. Completion means processing reached a terminal state. Delivery means the application obtained and validated the required files. These are three different milestones.
Expose them separately in application state. A user can be told that a video is queued without seeing a misleading success message. A completed generation can still require file retrieval, format validation, or editorial review before it becomes a usable asset.
Replicate documents prediction lifecycle states. fal documents asynchronous inference. Map the actual supplier states into your application model and retain the original provider state for investigation.
Keep a business acceptance condition beyond terminal success. For a product clip, it may require the correct subject, aspect ratio, duration, and product appearance. Provider completion establishes technical progress, not creative approval.
Persist the job contract
Store the internal invocation identifier, provider job identifier, workspace, account reference, input revision, operation definition, submission time, authorized maximum, and expected outputs. Record the permitted status, cancel, and retrieval paths.
Persist safe references rather than raw credentials. A resumed worker should obtain the current authorized connection for the same account. It should not depend on a secret embedded in a model transcript or callback payload.
Freeze the follow-up plan for the submitted operation. If a catalog definition changes while a video is running, the old job still needs a compatible completion path. In o11’s source, wallet-funded asynchronous jobs retain their follow-up plan rather than rediscovering arbitrary operations midway through execution.
Use the supplier’s resource ownership rules. A job identifier from another workspace or account must not become usable because a model includes it in a request. Account-scoped resources need explicit bindings throughout their lifecycle.
Choose polling or notifications deliberately
Polling periodically asks for the status of an existing job. Notifications let the supplier announce a change to an endpoint you control. Either approach still needs durable state, deduplication, and a way to recover when an observation is missed.
fal documents completion webhooks. When using notifications, verify authenticity using the supplier’s documented mechanism, associate the event with the existing account-owned job, and make duplicate delivery harmless.
For polling, use a bounded schedule appropriate to the expected duration and provider limits. Polling every fraction of a second for a multi-minute video rarely helps the user. Record the next observation time and stop after a terminal result or defined escalation boundary.
Avoid holding an expensive application request open merely to wait. A durable worker can resume later, while the client reads status from the application’s own invocation record. The user should be able to close the page and return without restarting the purchase.
Handle timeouts without duplicating work
Distinguish request timeout, observation timeout, and supplier deadline. A request timeout means the client did not receive a response in time. An observation timeout means the application stopped waiting. A supplier deadline may actually terminate work, depending on the provider contract.
If submission returns a job identifier, inspect that job. If the response is lost before the identifier is recorded, use the platform’s idempotency and reconciliation path. Do not assume the absence of a local success message proves the provider never started.
In o11’s source, an uncertain invocation can become unknown and retain its hold. It is not automatically purchased again. The operator recovery path needs supplier evidence and authorization. This is an implemented local behavior, not certification of a particular live provider’s receipts.
The failure-recovery guide explains the broader classification. Keep the distinction visible in code so a generic retry wrapper cannot accidentally turn observation failures into repeated generation purchases.
Cancel with the supplier's actual capability
Cancellation is a request with a possible race against completion. A queued job may be stopped before processing. A running job may be cancelable, partially billable, or impossible to stop. Verify the selected operation’s documented behavior.
If completion wins the race, retain the completed result. If cancellation succeeds, record the actual terminal state and applicable charge evidence. Do not overwrite a provider’s completed status with canceled just because the user clicked a button first.
Closing the interface or aborting a local network request does not necessarily stop supplier work. Explain this to the user where it affects cost. A cancel button should call a supported backend operation, not merely hide the progress indicator.
For operations without a stop hook, preserve the existing job and arrange output retrieval or reconciliation. Give the user a truthful state and a next action. An unsupported cancellation should not become a permanent block on unrelated media tasks.
Retrieve and store the artifact
A successful job often returns temporary delivery URLs. Download required artifacts into authorized storage according to the provider’s terms and your retention policy. Keep content type, size, checksum, dimensions, duration when relevant, and provenance.
Replicate documents output-file handling and expiration. Treat the selected supplier’s retention window as an operational requirement. A database row containing a URL is not the same as a retained video file.
Validate the actual bytes and playback. Check that the file is complete, decodes correctly, has the intended aspect ratio and duration, and contains the expected subject. Editorial review may still reject a technically valid output.
For private workspaces, issue scoped download access rather than copying supplier credentials into a public URL. If a download expires, refresh access to the retained artifact or retrieve the existing provider output where supported. Regeneration is a new decision only when the original cannot be recovered.
Budget waiting, retries, and revisions
The generation charge may depend on duration, resolution, compute, or model-specific output. Status checks, storage, enhancement, and retries can add separate costs. Verify which units the exact operation bills.
For illustration, suppose a workflow permits three video attempts at an assumed $2 each and one enhancement at $0.50. The service envelope is $6.50 before other costs. If one accepted clip required all three attempts, its generation cost is $6, not $2. These are invented amounts, not current provider prices.
Reserved funds and final charges are different. Three simultaneous jobs with a $3 maximum each can require $9 of available authorization while outstanding, even if their settled total later becomes $6. Keep concurrency and cash headroom in the plan.
Use the media workflow guide to control creative revisions and the cost worksheet to include all branches.
Make resumption and cleanup first-class
After a worker restart, scan for nonterminal jobs that need observation and resume them by identity. Use a claim or equivalent coordination mechanism so two workers do not independently advance the same paid step. Keep duplicate notifications harmless.
Retain cleanup tasks durably too. Temporary uploads, discarded outputs, and released resources should have a retryable deletion path. A cleanup failure should remain visible without blocking unrelated jobs or erasing the evidence needed to resolve charges.
Before expanding the workflow, exercise interruption after submission, delayed notification, repeated delivery, cancellation races, expired output URLs, and download failure. Label mocked checks honestly and verify live behavior only under authorized supplier accounts.
Start with one supported model and one output type. Once submission, observation, cancellation boundaries, and delivery are dependable, add more capabilities. A shared tool interface saves integration work only when it preserves the lifecycle details needed to finish the user’s task reliably.
Example: a media job record
A useful internal record includes task identifier, invocation identifier, provider job identifier, account reference, input revision, authorized maximum, current provider state, next observation time, output references, and last recovery decision. Add the accepted asset identifier only after file and editorial review.
For a fictional video task, the worker submits once and records a waiting state. A completion notification arrives twice. The first verified event advances the existing job; the second is recorded or ignored as a duplicate. A separate delivery step downloads and validates the file before marking the asset available.
If the worker stops between completion and download, resumption should continue retrieval. It should not submit another generation. If the output has expired, the recovery process checks whether the existing artifact can be retrieved through the supplier’s supported path and explains when a new purchase is actually necessary.
Keep the observation deadline and cleanup deadline separate. A job can need operator review while its evidence remains retained. A completed, accepted asset can later have temporary inputs deleted. This record makes the lifecycle understandable without depending on the original agent session remaining open.





