Skip to content

fix(credits): name an empty balance, refuse runs it cannot finish - #625

Merged
FlyM1ss merged 4 commits into
mainfrom
fix/llm-credits-preflight
Oct 13, 2026
Merged

FlyM1ss merged 4 commits into
mainfrom
fix/llm-credits-preflight

Conversation

@FlyM1ss

@FlyM1ss FlyM1ss commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

Prod 2026-10-07: a new account's GPT-5.5 / DJIA 30 backtest on ATL Credits died 39 bars in with "Model usage billing could not be completed." The 1.5-Credit welcome grant ran out. The store's InsufficientCreditsError fell into _execute_platform's catch-all BILLING_FAILED.

  • Error: a short balance is now INSUFFICIENT_CREDITS ("Not enough ATL Credits…"). The child prints ERROR: llm.run_failed category=… at its CLI boundary, so setup and finalize_run failures are covered too. The parent shows the safe message instead of a traceback tail and records the real error_category. Only the run's owner sees that message; anyone else reads a generic "the model run could not continue".
  • Preflight: POST /backtest/run refuses a platform_credits run the balance cannot finish. It returns 402, or 403 for a restricted account. The estimate is the sum of typical calls plus the largest reservation ceiling. Calls are counted from NYSE sessions up to the settled end. Output tokens are the per-model prod median. The prompt includes step instructions, the strategy prompt and carried upstream outputs. The ceiling comes from the execution service's own reservation_ceiling_micro_for. GPT-5.5 / DJIA 30 / one week comes out at about 1.79 Credits; prod observed about 1.81. The owner's running platform_credits runs (estimate minus settled spend) are set aside first, and this is re-checked under the slot-ledger lock. A failed balance read lets the run through; the per-call reservation remains the hard gate.
  • Welcome grant: new accounts get 8 Credits via default_signup_credits_v2. v1 holders keep their 1.5, so the boot backfill does not top up every existing account.
  • Analytics: account_restricted and credits_insufficient are added to the allow-list and both DDLs, and both now block in user state.
  • Frontend: on iFinD runs, formatBacktestError no longer rewrites Credits or model-stop messages as iFinD failures. app.js?v=159.
  • Docs: follow-up in docs: credits welcome grant and launch balance check #631 (landed after this merged).

🤖 Generated with Claude Code

FlyM1ss and others added 2 commits October 7, 2026 18:37
…Credit welcome

- Insufficient Credits at reservation is INSUFFICIENT_CREDITS, not the
  catch-all BILLING_FAILED; the child relays the category so the parent
  shows the safe message and records credits_insufficient.
- POST /backtest/run refuses a platform_credits run the balance cannot
  finish (402; 403 for a restricted account).
- Welcome grant v2 = 8 Credits for new accounts; v1 holders keep 1.5.
- Admit account_restricted / credits_insufficient in the analytics
  allow-list (account_restricted events were being dropped).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…; pass model stops through the iFinD mapper

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vercel

vercel Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
agentic-trading-lab Ready Ready Preview Oct 13, 2026 3:22pm UTC

FlyM1ss and others added 2 commits October 13, 2026 11:03
Resolves the trace_lifecycle wrap in the backtest child and the parallel
test additions; bumps app.js to v=159 since main independently reached 158.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Preflight counts the owner's running platform-credits runs (admitted
  estimate less settled spend) and re-checks under the slot-ledger lock,
  so concurrent launches cannot each pass against one balance (402).
- Calls priced from NYSE sessions up to the settled end, not the weekday
  upper bound; per-model median output tokens instead of a flat 1000.
- Prompt estimate adds step instructions/output formats, the single-prompt
  strategy text and carried upstream outputs; ceiling via the execution
  service's shared reservation_ceiling_micro_for (no copied constant).
- 402 rounds the need up and the balance down so the figures never tie.
- Model-failure slot errors are owner-only; others (and the legacy mirror)
  read a generic "the model run could not continue".
- Child reports run_failed at the CLI boundary (setup + finalize too),
  naming the run's own error past a failed finalize; parser scans both
  streams past an unknown category.
- account_restricted now blocks in analytics user state.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@FlyM1ss
FlyM1ss merged commit 10beea3 into main Oct 13, 2026
8 checks passed

This branch was successfully deployed

1 active deployment
Preview — b77dfd74 Deployed Oct 13, 2026 by vercel[bot]
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