fix(music): poll the job the gateway hands back, on both rails - #63
Merged
Merged
Conversation
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.
Merged
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.
Problem
MusicClienttreated every non-200 as an error. MiniMax music takes 1–3 minutes and the gateway answers202 + 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 raisedAPI error: 202for each.Change
blockrun_llm/jobs.py(poll_until_completed) and bothImageClientandMusicClientuse it — one definition of how a job ends.PAYMENT-SIGNATURE(the job is bound to that wallet; settlement is on the completed poll)./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.pyunchanged and green on the shared loop. ruff clean.