fix(opencode): preserve NanoGPT cache writes and billed cost - #48477
Open
huggix wants to merge 1 commit into
Open
fix(opencode): preserve NanoGPT cache writes and billed cost#48477huggix wants to merge 1 commit into
huggix wants to merge 1 commit into
Conversation
Contributor
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
Contributor
|
The following comment was made by an LLM, it may be inaccurate: The searches show that PR #48477 is the current PR. The related results mention cache pricing and cost-related fixes, but none appear to be duplicates of the current PR addressing the specific NanoGPT cache writes and billed cost issue. No duplicate PRs found |
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
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.
fix(opencode): preserve NanoGPT cache writes and billed cost
Issue for this PR
Closes #48478
Type of change
What does this PR do?
NanoGPT reports cache writes in
usage.cache_creation_input_tokensand the settled charge inx_nanogpt_pricing. The OpenAI-compatible adapter drops these fields, so OpenCode can show zero cache writes and a cost estimate that misses long-context rates or discounts.Register a NanoGPT metadata extractor for streaming and non-streaming responses. Session accounting uses its cache-write count and valid USD charge, including an explicit zero. When pricing is absent or invalid, the existing estimate still applies. Other providers are unchanged.
How did you verify your code works?
From
packages/opencode:bun --bun run typecheck: passed.git diff --check: passed.The regression exercises actual SDK SSE parsing through OpenCode's LLM adapter into session accounting, plus non-streaming responses, separate usage/pricing frames, explicit zero, invalid values, non-USD fallback, excessive cache counts, and provider/stream isolation.
Screenshots / recordings
Not applicable: token/cost accounting only.
Checklist