Skip to content

Include remaining OpenAI credit balance in API snapshots - #5109

Open
fcakyon wants to merge 1 commit into
steipete:mainfrom
fcakyon:fix/openai-credit-balance
Open

fcakyon wants to merge 1 commit into
steipete:mainfrom
fcakyon:fix/openai-credit-balance

Conversation

@fcakyon

@fcakyon fcakyon commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

The OpenAI API billing fallback successfully reads credit grants but omits usage.providerCost.balance from its JSON snapshot. Consumers that use that field cannot display the remaining credits, even though total_available was already parsed.

  • Return the existing available value as balance; no additional requests, credential discovery, or token renewal
  • Extend the existing billing-fallback regression to assert a $75 balance. Before the fix it failed with nil in both QuickJS and JavaScriptCore
  • Live macOS CLI verification with an existing Platform session credential returned source: "billing-api", balance: 112.7922562851, and currencyCode: "USD"; the deployed Stream Deck consumer displayed the rounded $113 after restart
Before: usage.providerCost.balance is absent
After:  usage.providerCost.balance = 112.7922562851

make test-fast FILTER=HostResultProviderTests: all 14 tests passed on this branch, including both plugin engines. make check: passed, with 0 SwiftLint violations. The live deployment check verifies the JSON field and consumer display; automatic replacement of a revoked credential is outside this change.

@clawsweeper

clawsweeper Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T12:33:56.087546Z 290d54d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 17, 2026
@clawsweeper

clawsweeper Bot commented Nov 17, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge.

What this changes

Include OpenAI’s already-parsed remaining credit balance in API usage snapshots.

Example: The billing endpoint reports $100 granted, $25 used, and $75 available.

  • Before: The snapshot omits usage.providerCost.balance.
  • After: The snapshot includes usage.providerCost.balance = 75.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, correct repair with reported live CLI evidence and a meaningful both-engine regression; existing head checks are still running.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR supplies a macOS CLI after-fix balance value from the billing-api path using an existing Platform credential, plus the downstream rounded display; this exercises the changed plugin output through the shipped JSON entry point.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Consumers of the balance field cannot display credits that the billing fallback successfully fetched.
Reason: The change fills an existing documented result field without adding a capability, option, credential path, or competing implementation.

Merge readiness

✅ Ready for maintainer review

Keep this PR open for landing: it fixes a confirmed snapshot omission with a focused change and no identified correctness defects.

Priority: P2
Reviewed head: 290d54dc2abdafd80302a1555822ef3879dccd0e

Before merge

None.

Findings

None.

Agent review details

How this fits together

The bundled OpenAI plugin reads billing responses, and the shared plugin mapper converts its cost object into the usage snapshot encoded by the CLI.

flowchart LR
  A[Existing configured credential] --> B[OpenAI plugin]
  C[Credit grants endpoint] --> B
  B --> D[Shared snapshot mapper]
  D --> E[CLI JSON]
  E --> F[Balance consumers]
Loading

Technical review

Best possible solution:

Populate the existing balance field directly from validated total_available and retain the focused host regression.

Do we have a high-confidence way to reproduce the issue?

The base plugin omits balance despite parsing total_available, and the existing fixture exposes the omission with a $75 assertion; no tests or live probes were run during this read-only review.

Is this the best way to solve the issue?

Directly populating the documented field is the smallest complete fix and preserves credential selection, fallback eligibility, and request behavior.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 1f6da9bec444.

Provenance checked

  • OpenAI billing-fallback cost result keeps the original intent (a634f55: The plugin cutover preserved OpenAI billing fallback and typed host results; its recorded rationale does not identify intentional suppression of the numeric balance.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add P2: A limited billing-fallback omission prevents JSON consumers from displaying an available credit balance.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: A limited billing-fallback omission prevents JSON consumers from displaying an available credit balance.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 17, 2026, 7:45 AM ET / 12:45 UTC.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant