Skip to content

fix(falai): bound pricing lookups and correct result handling - #9706

Merged
waleedlatif1 merged 2 commits into
stagingfrom
codex/fal-burst-investigation-20261105
Nov 5, 2026
Merged

waleedlatif1 merged 2 commits into
stagingfrom
codex/fal-burst-investigation-20261105

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Coalesce and cache historical fal prices per credential and endpoint, respect rate-limit cooldowns, and verify exact receipts belong to the requested job.
  • Distinguish terminal queue failures from failed delivery. Start exact receipt tracking at terminal queue status, bound result retrieval, and retain interrupted-delivery reconciliation without estimating charges for explicit model failures. Report bounded, redacted provider error types.
  • Allow remote generated images up to the existing 100 MiB buffered-transfer limit while retaining inline-image and JSON limits.

Type of Change

  • Bug fix

Testing

Passed 98 focused provider-boundary tests; full root bun run test with VITEST_MAX_WORKERS=6 (3,455 app files, 39,525 app tests); lint; all 62 audits; workspace type-check; test-type ratchet; block-registry check; and generated-artifact checks. Regression cases cover concurrent pricing, credential isolation, cache expiry, Retry-After recovery, cancellation, receipt identity, rejected results, and declared/streamed image limits. Twelve guard-removal checks and reproduced cancellation, terminal queue-error, and concurrent-cooldown regressions demonstrate that the regressions fail when their corresponding protections are removed.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Nov 5, 2026 10:22am UTC

Request Review

@greptile-apps

greptile-apps Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[High impact] The PR appears safe to merge, with no new actionable issues found.

Summary

This PR bounds Fal.ai pricing and result requests while preserving charge records when delivery fails.

  • Fal image and video jobs keep charges visible when media delivery fails.
  • Fal price lookups match receipts to jobs and reuse account-specific estimates.
  • Remote generated images can use the existing 100 MiB transfer limit.

Both earlier concerns are addressed: delivery failures retain reconciliation metadata, and successful shared prices are cached even when their only waiting caller stops.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Queue completes] --> B[Start exact receipt lookup]
  A --> C{Queue reports an error?}
  C -->|Yes| D[Skip result request]
  C -->|No| E[Fetch result within 30 seconds]
  E --> F{Explicit model failure?}
  F -->|Yes| D
  F -->|No| G[Keep result or delivery error]
  B --> H[Await exact receipt]
  D --> H
  G --> H
  H --> I{Receipt available?}
  I -->|Yes| J[Keep exact charge]
  I -->|No explicit failure| K[Use estimate or fallback floor]
  I -->|Explicit failure| L[Do not estimate]
Loading

Reviews (2) · Last reviewed commit: "fix(falai): preserve receipts across res..." · Reviewed by Greptile

Comment thread apps/sim/lib/media/falai-result.ts Resolved
Comment thread apps/sim/lib/tools/falai-pricing.ts Resolved

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 10 files

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/lib/internal/video/client.ts Resolved
Comment thread apps/sim/lib/media/falai-result.ts Resolved
Comment thread apps/sim/lib/media/falai-result.ts Resolved
Comment thread apps/sim/lib/media/falai-result.ts Resolved
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 10 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit 8e3df8a into staging Nov 5, 2026
84 checks passed

This branch was previously deployed

1 inactive deployment
Preview — 2d7361b4 Deployed Nov 5, 2026 by vercel[bot]
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