fix: rename provider id to github-copilot-amplifier for exact cost - #15
Open
David Koleczek (DavidKoleczek) wants to merge 1 commit into
Open
fix: rename provider id to github-copilot-amplifier for exact cost#15David Koleczek (DavidKoleczek) wants to merge 1 commit into
David Koleczek (DavidKoleczek) wants to merge 1 commit into
Conversation
Collaborator
Author
|
Companion PR (required together): microsoft/amplifier-agent#96 |
opencode only enables raw-usage passthrough (includeRawChunks) when the provider id contains the substring "github-copilot". That passthrough is what lets amplifier-agent's per-turn copilot_usage.total_nano_aiu reach opencode and override its inaccurate token-times-rate cost estimate, which otherwise overstates session cost under Anthropic prompt caching. - Rename DEFAULT_PROVIDER_ID from "amplifier" to "github-copilot-amplifier". The provider's display name stays "Amplifier". - On config rewrite, drop any stale provider block previously written under a different id but the same baseURL, so upgrading configs do not end up with a duplicate "Amplifier" provider. Requires the companion change in amplifier-agent (emit copilot_usage on the terminal chunk). Both are required together. Refs: microsoft-amplifier/amplifier-support#352 🤖 Generated with [Amplifier](https://github.com/microsoft/amplifier) Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
David Koleczek (DavidKoleczek)
force-pushed
the
fix/opencode-exact-cost
branch
from
July 20, 2026 19:25
e36f55e to
1d61fdc
Compare
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.
Bug
When opencode uses amplifier-agent as an OpenAI-compatible provider through this bridge, the session cost opencode displays is overstated. amplifier-agent's own
cost_usdis Anthropic-exact, but opencode ignores it and re-derives cost from token counts times the static per-model rate table this bridge writes. Under Anthropic prompt caching that is wrong: cache-read tokens get folded into the input bucket at the full input rate, and cache-creation tokens are dropped (recorded as 0), producing a systematic overcharge.Reported in microsoft-amplifier/amplifier-support#352.
Fix
opencode only enables raw-usage passthrough (
includeRawChunks) when the provider id contains the substringgithub-copilot. That passthrough is what lets amplifier-agent's per-turncopilot_usage.total_nano_aiureach opencode, which then overrides its token-times-rate estimate with the exact value.DEFAULT_PROVIDER_IDfromamplifiertogithub-copilot-amplifierto turn that path on. The provider's display name staysAmplifier, so the model picker is unchanged for users.baseURL. Without this, upgrading an existing config leaves a duplicateAmplifierprovider (the oldamplifierid plus the new one).Only the loose
github-copilotsubstring is matched. The exact-match Copilot machinery (OAuth, device-flow login, request-body rewriting) is gated on=== "github-copilot"or the Copilot npm loader, neither of which this hits.This depends on the companion change in amplifier-agent (emit
copilot_usageon the terminal SSE chunk). Both changes are required together; neither has any effect alone.Verification
Verified end-to-end in an isolated environment (opencode 1.17.15, amplifier-agent) with a 3-turn, cache-heavy session on claude-haiku-4-5:
$0.04905320vs amplifier-agentcost_usd$0.03107695(+57.8%).$0.03055695== amplifier-agentcost_usd$0.03055695(penny-exact).prepareon a config that had both ids leaves exactly one provider (github-copilot-amplifier).The session completed with no 4xx.
ruff checkandruff format --checkpass on the changed file.