Skip to content

Send billing reports to Thalamus for vault-served requests - #13

Merged
ualtinok merged 5 commits into
mainfrom
billing-reports
Nov 11, 2026
Merged

ualtinok merged 5 commits into
mainfrom
billing-reports

Conversation

@oaiauth-alfonso

@oaiauth-alfonso oaiauth-alfonso Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Per-request billing reports through Thalamus's routing accessor, for vault-served requests on OpenCode 2 (HTTP and xAI WebSocket) and Pi; OpenCode 1 sends none. Without the accessor no billing work runs. Provider usage semantics, charge basis and automatic-cache claims are a cited table in packages/core/src/providers.ts and docs/billing-reports.md; rows marked assumed are checked against live replies before release.


Summary by cubic

Sends per-request billing reports to Thalamus via the routing accessor for vault-served requests on OpenCode 2 HTTP, xAI WebSocket, and Pi; OpenCode 1 sends none. Billing only runs for placeholder-key requests with a vault receipt and an installed accessor. Provider usage semantics and charge basis live in a cited table in packages/core/src/providers.ts and docs/billing-reports.md.

New Features

  • Retries and account reroutes report each physical send with its own UUID and attempt number; redirects core follows are routing hops, not billable calls.
  • Pi reports provider-wire usage with its final stored responseId; cancellation after a protocol terminal marker reports completed, while pre-terminal cuts report cut.
  • A live-smoke mode for OpenCode 2 checks cache and reasoning reports against host-stored counters, using fresh identical-prompt sessions for the cache pair and stored visible output for reasoning.

Written for commit 4db18c2. Summary will update on new commits.

View guided diff Turn on auto-fix

Observe each physical OpenCode 2 HTTP/xAI WebSocket and Pi send only with a vault receipt and routing accessor. Keep provider usage semantics and charge basis in the provider table, and document official sources and explicit compatibility assumptions.

Pi uses provider-wire usage with its final stored responseId/outcome. Protocol-terminal cancellation is completed; pre-terminal cuts remain cut, and absent trailing usage remains omitted. Verified targeted unit/e2e cases plus scripts/gate.sh --fast on Node 24; no version bump.
Keep the sent model only, without usageByModel aliases. Retain latest raw stream counters and derive uncached input and cache-write totals once at report construction.

Treat a redirect core follows as a routing hop, not a billable model call. Intentionally replace the prior Pi two-report redirect expectation with exactly one completed report; preserve reports for retries, terminal redirects and send errors. Document the Pi Kimi pricing-id gap.

Four regressions were red before fixes. Verified 40 billing units, 3 focused fetch/redirect tests, the real OpenCode 2 billing case, and scripts/gate.sh --fast on Node 24 (GATE_OK, 4.90s).
Serve the fixture's rows through an in-memory vault client instead of constructing a separate liveHarness core used only for its client. The extension still creates and exercises its real core and pi-ai stream; all billing assertions and timeouts are unchanged.

Windows profiling attributed 279 ms to the discarded core's private token write and roster refresh. The focused DeepSeek case measured 656 ms before and 402 ms after. Three pre-change Windows runs of each reported failing file passed; the OpenCode 1 membership case never calls createFetch. The CI timeout was not reproduced.
Capture routing billing payloads in the scanned scratch home and compare cache, reasoning and usage semantics using synthetic-tested checks. Print stored host counters beside each probe and document bounded token cost.

Use fresh identical-prompt sessions rather than cumulative history for the cache pair, as approved: retaining the first long prompt would invalidate the comparison. Restore first-turn cache counts too when it already hits automatic caching.
Compare report output minus reasoning to OpenCode stored visible output within one token, falling back to chars/4 with an eight-token absolute floor. Add the three live regression rows and preserve strict mismatch and tolerance-boundary coverage.

The previous tiny-reply FAIL expectation contradicted the requested rounding tolerance, so replace it with ±8 fallback boundaries and larger factor-of-two failures. Host-counter independence now applies only to cache checks.

Record the 2026-11-11 OpenCode 2.2.3 evidence, separating verified cache/reasoning observations from untested assumptions and unavailable accounts.
@ualtinok
ualtinok merged commit 4db18c2 into main Nov 11, 2026
20 checks passed
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