Repository navigation
Send billing reports to Thalamus for vault-served requests - #13
Merged
Merged
Conversation
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.
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.
Per-request
billingreports 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.tsanddocs/billing-reports.md.New Features
Written for commit 4db18c2. Summary will update on new commits.