Repository navigation
fix(standard): settle background Responses calls on polling - #733
Merged
Merged
Conversation
aitianshi
marked this pull request as ready for review
December 2, 2026 14:52
This comment has been minimized.
This comment has been minimized.
🟡 PR judge · 4 of 5 yes · #733 ↔ #683
Acceptance criteria, 3 of 3 met
Checks the script runs itself, 4 of 4 pass
|
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.
Closes #683
What
Background Responses calls kept unsettled bookings and their polled usage was never billed.
Keep the original model and booking until a terminal reply; record usage and cost once across concurrent or repeated polls.
Retry failed ledger settlement on later polls.
Forward DELETE and allow polling and known-response cancellation after the cap closes.
CLI and pages stay unchanged: both consume the same call records and ledger.
Verified
182 tests run: 181 passed, one skipped, across relay, ledger, runner, layering and dependency suites.
A scripted run charges three background completions in
agent/calls.jsonland the ledger, then stops at the cap.Concurrent polls, streaming, incomplete replies, missing usage, ledger failure, cancellation and DELETE covered.
Risk
The shared relay handles every run: a regression in recording or locking can affect synchronous calls as well as background calls. Settlement errors can retain reserved spend and stop admission conservatively.
Pending responses retain their booking when no terminal usage arrives.
Response tracking lasts for the unit relay's lifetime.
Not checked against a live provider.
Agents