Skip to content

fix(music): poll the job the gateway hands back, on both rails - #63

Merged
VickyXAI merged 1 commit into
mainfrom
fix/music-polls-its-job-like-images-do
Sep 8, 2026
Merged

VickyXAI merged 1 commit into
mainfrom
fix/music-polls-its-job-like-images-do

Conversation

@VickyXAI

@VickyXAI VickyXAI commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Problem

MusicClient treated every non-200 as an error. MiniMax music takes 1–3 minutes and the gateway answers 202 + poll_url (since 2026-09-08, immediately), so a music request could not succeed on either rail. The enterprise ledger shows 11 of 11 creates in the last 30 days answered 202; this client raised API error: 202 for each.

Change

  • The image client's poll loop moves to blockrun_llm/jobs.py (poll_until_completed) and both ImageClient and MusicClient use it — one definition of how a job ends.
  • Wallet rail: the signed create's 202 is polled with the same PAYMENT-SIGNATURE (the job is bound to that wallet; settlement is on the completed poll).
  • Account rail: the 202 arrives on the first post; polls carry the key, and the gateway's /api/v1/... poll_url is resolved to /v1/... on api.blockrun.ai as images already do.
  • MUSIC_POLL_INTERVAL_SECONDS = 5, MUSIC_POLL_BUDGET_SECONDS = 300. A budget that runs out raises 504 and has cost nothing.

Verification

tests/unit/test_music_poll.py (5 tests: both rails, upstream failure, timeout, fast path unchanged). Full unit suite 977 passed; test_image_poll.py unchanged and green on the shared loop. ruff clean.

Music is never fast: MiniMax takes one to three minutes and the gateway
answers 202 + poll_url — since 2026-09-08, at once. MusicClient treated
every non-200 as an error, so a music request could not succeed on either
rail; the enterprise ledger showed 11 of 11 creates in 30 days answered
202, and this client raised "API error: 202" for each.

The image client already polls. Its loop moves to jobs.py and both clients
use it: the wallet rail replays the create's PAYMENT-SIGNATURE on each poll
(the job is bound to that wallet, and settles on the completed poll); the
account rail sees its 202 on the first post and polls with the key.
A poll budget that runs out has cost nothing.
@VickyXAI
VickyXAI merged commit d80b5ec into main Sep 8, 2026
1 of 4 checks passed
@VickyXAI VickyXAI mentioned this pull request Sep 8, 2026
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