Repository navigation
Report each signed payment session from call_runner - #1
Merged
Merged
Conversation
call_runner takes on_payment_session, called with each session the signer signs, before the paid request goes out. A caller can link a charge to the call that caused it, including a call that fails after the signer has signed. LivePaymentSession.manifest_id is the manifest from the 402 challenge, so the session is identified without reading the signer's state.
Replace gathering of payment_task with a drain loop to handle cancellation more gracefully. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
5 tasks done
eliteprox
force-pushed
the
feat/call-runner-manifest-id
branch
from
October 19, 2026 14:50
fe699fe to
e6d243b
Compare
|
This was referenced Oct 20, 2026
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.




Summary
This PR lets a gateway find out what each
call_runnercall cost.call_runnertakes a new, optionalon_payment_sessioncallback. Each time the remote signer signs a payment session, the SDK calls it with that session. The session's newmanifest_idproperty names the orchestrator session the payment funds, so the gateway can match it to Clearinghouse usage records and charge the right job.Callers that don't pass the callback see no change in results, errors or streams.
Why
The signer charges when it signs a payment, not when the job succeeds. So a call can be charged and still fail: the runner errors, the payment turns out to be unusable, or the caller cancels. A gateway that bills its own users has to know which charges belong to which call, including the failed ones. Today
call_runnerdoesn't tell it.We need this for the Network Engineering SPE build track (project board). Its second milestone defines how the builder engine reports network cost per job (ISS-04). The engine records the manifest of every payment the signer signs, then matches each one to a Clearinghouse usage record, so every job shows what it cost, whether it succeeded or not. livepeer-builder-core pins this branch until it merges.
An earlier version read
AuthIDfrom the signer's state. On livepeer#74, Josh pointed out that the state is opaque and shouldn't become a public contract, and suggested ManifestID instead. This version uses ManifestID and doesn't decode the signer's state.What callers see
asyncio.wait_for, for example, still accounts for every session it signed.Known limits
RunnerSelectionCursorstill fails over after a signed payment, so one job can pay twice. Runner selection: pool size, failure classification and payment_sent on rejections livepeer/livepeer-python-gateway#70 tracks that.This replaces livepeer#71, which was closed so the change could target a fork branch.
Test plan
pytest -W error::ResourceWarningate6d243b: 227 passed, 2 failed. Both failures are intests/test_stats_pull.pyand fail the same way onmain. The new tests cover sync and async callbacks, repeated 402s, a runner failure after payment, a refused session, an unusable payment, a raising callback, a cancelled call, andmanifest_idstaying the same across a payment refresh.