GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(core): price Copilot long-context tiers and cache writes by golfromeo-fr · Pull Request #59803 · anomalyco/opencode

Conversation

@golfromeo-fr

@golfromeo-fr golfromeo-fr commented Oct 28, 2026 •
edited by opencodejr Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Issue for this PR

Closes #52089

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

GitHub Copilot costs were undercounted badly on long sessions. In my case (#59671): a 25h session on Copilot / Claude Haiku 5.5, 348 requests, ~344K average context, OpenCode showed $1.56 when the real bill is roughly $9.34 (between $2.03 and $10.15, since Copilot picks the price tier per request by prompt size).

Two causes: the builder ignored the long_context price tier that Copilot's /models payload ships alongside default (tier boundary is default.max_prompt_tokens), and it hardcoded cache writes to $0 even though the payload carries a cache_write_price. Since #62034 moved Copilot onto the native ai protocols, cache-write tokens are counted correctly, but the builder still prices both wrong — pricing my session's totals at the ≤100K rates with free writes gives $1.5557, cent-exact with the displayed $1.56, which is how I know which rates the current code applies.

The builder now emits the cache write price and a context-tier cost entry, which SessionUsage.calculateCost already applies per request (tier selected when the prompt exceeds the boundary, ≤ boundary stays on the default tier), so no calculator change was needed.

Deliberately not addressed: Copilot's own reported billed amount (#35765) and the richer pricing shape from #59460.

How did you verify your code works?

A builder unit test against the Copilot rate card for Claude Haiku 5.5: the long-context tier entry is emitted (boundary taken from default.max_prompt_tokens), cache writes are priced at the default and long-context rates, a model with a malformed long_context object stays in the catalog instead of being dropped, and single-tier models are unaffected. bun run check passes, and the packages/core suite has the same 4 failures as a clean dev checkout (all environment-related).

Visual

<svg xmlns="http://www.w3.org/2000/svg" width="240" height="72" viewBox="0 0 240 72" role="img" aria-label="Copilot session cost: displayed $1.56, actual about $9.34">
  <style>
    .bar { animation: grow 2.8s ease-in-out infinite; }
    .tag { animation: fade 2.8s ease-in-out infinite; }
    @keyframes grow { 0%, 15% { width: 26px } 55%, 100% { width: 142px } }
    @keyframes fade { 0%, 30% { opacity: 0 } 65%, 100% { opacity: .9 } }
    @media (prefers-reduced-motion: reduce) { .bar, .tag { animation: none } }
  </style>
  <g fill="currentColor" font-family="ui-monospace,SFMono-Regular,monospace" font-size="11">
    <text class="tag" x="12" y="11" font-size="9" opacity="0">6x undercount: tier + cache writes</text>
    <text x="12" y="27" opacity=".5">billed</text>
    <rect x="62" y="18" width="26" height="9" rx="2" opacity=".5"/>
    <text x="94" y="27" opacity=".5">$1.56</text>
    <text x="12" y="53">actual</text>
    <rect class="bar" x="62" y="44" width="142" height="9" rx="2" opacity=".9"/>
    <text x="206" y="53">$9.34</text>
  </g>
</svg>

Screenshots / recordings

Not a UI change, so none attached.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Fixes #51845

Related: #35765, #53521

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Oct 28, 2026
@github-actions

github-actions Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot removed needs:issue needs:compliance This means the issue will auto-close after 2 hours. labels Oct 28, 2026
@github-actions

github-actions Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@golfromeo-fr
golfromeo-fr marked this pull request as ready for review October 28, 2026 02:51
opencodejr[bot]
opencodejr Bot reviewed Oct 28, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to merge. I ran the #52089 reproduction (a local mock of Copilot's /models and /responses) on the base and with this change:

  • Prices: cache writes go from $0 to $5/M, and a long-context tier is added above default.max_prompt_tokens.
  • Usage: the Responses generate and stream paths now report cacheWrite: 8270 and noCache: 3, where the base reported no cacheWrite and noCache: 8273.

The tier boundary matches how SessionUsage.calculateCost picks tiers (input plus cache reads plus cache writes, strictly above the boundary). The Copilot and session-usage tests pass. I couldn't run the package type check in this environment.

Public API is unchanged: only the internal parsing of Copilot's /models and usage responses changes.

One small point is inline: the new session-usage.test.ts cases exercise unchanged code and can be dropped.

Fixes #51845
Fixes #59671
Related: #35765, #53521

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/core/test/session-usage.test.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Oct 28, 2026
github-copilot: session cost ignores cache writes and long-context pricing #52089
Closed
**Cost calculation wrong for GitHub Copilot models with tiered pricing: Claude Haiku 5.5 long-context tier (>100K) not applied and cache-write tokens billed at $0 — session shown as $1.56, real cost ≈ $9.3–10.2 (~6x undercount)** #59671
Closed
golfromeo-fr added a commit to golfromeo-fr/opencode that referenced this pull request Oct 28, 2026
@golfromeo-fr
test(core): drop catalog cost cases covering unchanged code
238a59b
Review feedback on anomalyco#59803: the tier and cache-write pricing behavior
they pinned lives in SessionUsage.calculateCost, which this PR does not
change, and the changed code is already covered by the builder and
adapter tests.
opencodejr[bot]
opencodejr Bot reviewed Oct 28, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new commit removes the session-usage.test.ts cases I flagged, which addresses my earlier comment. It changes nothing else. I re-ran the Copilot tests and the #52089 and #51845 reproductions at this head: cache-write prices, the long-context tier and the cacheWrite/noCache mapping are all correct. No new concerns. The public API is unchanged.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@github-actions github-actions Bot mentioned this pull request Oct 28, 2026
📊 AI CLI 工具社区动态日报 2026-10-28 96loveslife/big_model_radar#716
Open
opencodejr[bot]
opencodejr Bot reviewed Oct 29, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new commit only merges dev. I checked that the PR's own changes are the same as before and that the merged dev commits don't touch the Copilot provider or the cost calculation. I re-ran the Copilot tests and the #52089 and #51845 reproductions at this head, and all are still fixed. My earlier test comment was addressed in the previous push. No new concerns, and the public API is unchanged.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@golfromeo-fr
golfromeo-fr force-pushed the copilot-tier-pricing branch from 59a8099 to 22e4c82 Compare October 29, 2026 01:50
golfromeo-fr added a commit to golfromeo-fr/opencode that referenced this pull request Oct 29, 2026
@golfromeo-fr
test(core): drop catalog cost cases covering unchanged code
22e4c82
Review feedback on anomalyco#59803: the tier and cache-write pricing behavior
they pinned lives in SessionUsage.calculateCost, which this PR does not
change, and the changed code is already covered by the builder and
adapter tests.
opencodejr[bot]
opencodejr Bot reviewed Oct 29, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This push rebases the branch onto a newer dev. The PR's own changes are the same as before, and the newer dev commits don't touch the Copilot provider or the cost calculation. I re-ran the Copilot tests and the #52089 and #51845 reproductions at this head, and all are still fixed. My earlier test comment remains addressed. No new concerns, and the public API is unchanged.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@golfromeo-fr
golfromeo-fr force-pushed the copilot-tier-pricing branch from 22e4c82 to f3451cd Compare October 29, 2026 02:40
golfromeo-fr added a commit to golfromeo-fr/opencode that referenced this pull request Oct 29, 2026
@golfromeo-fr
test(core): drop catalog cost cases covering unchanged code
f3451cd
Review feedback on anomalyco#59803: the tier and cache-write pricing behavior
they pinned lives in SessionUsage.calculateCost, which this PR does not
change, and the changed code is already covered by the builder and
adapter tests.
opencodejr[bot]
opencodejr Bot reviewed Oct 29, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This push rebases the branch onto a newer dev again. The PR's own changes are the same as before, and the newer dev commits don't touch the Copilot provider or the cost calculation. I re-ran the Copilot tests and the #52089 and #51845 reproductions at this head, and all are still fixed. My earlier test comment remains addressed. No new concerns, and the public API is unchanged.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@golfromeo-fr
golfromeo-fr force-pushed the copilot-tier-pricing branch from f3451cd to 130c26d Compare October 30, 2026 00:47
golfromeo-fr added a commit to golfromeo-fr/opencode that referenced this pull request Oct 30, 2026
@golfromeo-fr
test(core): drop catalog cost cases covering unchanged code
130c26d
Review feedback on anomalyco#59803: the tier and cache-write pricing behavior
they pinned lives in SessionUsage.calculateCost, which this PR does not
change, and the changed code is already covered by the builder and
adapter tests.
opencodejr[bot]
opencodejr Bot reviewed Oct 30, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This push rebases the branch onto a newer dev once more. The PR's own changes are the same as before, and the newer dev commits don't touch the Copilot provider or the cost calculation. I re-ran the Copilot tests and the #52089 and #51845 reproductions at this head, and all are still fixed. No new concerns, and the public API is unchanged.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@golfromeo-fr
golfromeo-fr force-pushed the copilot-tier-pricing branch from 130c26d to c17273d Compare October 30, 2026 19:22
golfromeo-fr added a commit to golfromeo-fr/opencode that referenced this pull request Oct 30, 2026
@golfromeo-fr
test(core): drop catalog cost cases covering unchanged code
c17273d
Review feedback on anomalyco#59803: the tier and cache-write pricing behavior
they pinned lives in SessionUsage.calculateCost, which this PR does not
change, and the changed code is already covered by the builder and
adapter tests.
opencodejr[bot]
opencodejr Bot reviewed Oct 30, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This push rebases the branch onto a newer dev again. The PR's own changes are the same as before. The newer dev commits change other parts of packages/ai/src/route, but not the shared token helpers, usage mapping or cost calculation this PR depends on. I re-ran the Copilot tests and the #52089 and #51845 reproductions at this head, and all are still fixed. No new concerns, and the public API is unchanged.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
golfromeo-fr added a commit to golfromeo-fr/opencode that referenced this pull request Oct 30, 2026
@golfromeo-fr
test(core): drop catalog cost cases covering unchanged code
cba0118
Review feedback on anomalyco#59803: the tier and cache-write pricing behavior
they pinned lives in SessionUsage.calculateCost, which this PR does not
change, and the changed code is already covered by the builder and
adapter tests.
@golfromeo-fr
golfromeo-fr force-pushed the copilot-tier-pricing branch from c17273d to cba0118 Compare October 30, 2026 21:31
opencodejr[bot]
opencodejr Bot reviewed Oct 30, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This push rebases the branch onto a newer dev again. The PR's own changes are the same as before, and the newer dev commits don't touch the code this fix relies on. I re-ran the Copilot tests and the #52089 and #51845 reproductions at this head, and all are still fixed. No new concerns, and the public API is unchanged.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@golfromeo-fr
golfromeo-fr force-pushed the copilot-tier-pricing branch from cba0118 to 1539d46 Compare November 2, 2026 13:55
golfromeo-fr added a commit to golfromeo-fr/opencode that referenced this pull request Nov 3, 2026
@golfromeo-fr
test(core): drop catalog cost cases covering unchanged code
21df4fe
Review feedback on anomalyco#59803: the tier and cache-write pricing behavior
they pinned lives in SessionUsage.calculateCost, which this PR does not
change, and the changed code is already covered by the builder and
adapter tests.
@golfromeo-fr
golfromeo-fr force-pushed the copilot-tier-pricing branch from 8271498 to 21df4fe Compare November 3, 2026 13:15
opencodejr[bot]
opencodejr Bot reviewed Nov 3, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This push rebases onto the latest dev. The PR's own changes are the same as in the previous version, and the newer dev commits don't touch the Copilot provider or the cost calculation. I re-ran the Copilot tests and my adapted #52089/#51845 reproduction at this head: cache-write prices, the long-context tier and the streamed cacheWrite/noCache values are all still correct. No new concerns, and the public API is unchanged.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@golfromeo-fr
golfromeo-fr force-pushed the copilot-tier-pricing branch from 21df4fe to 140c43e Compare November 3, 2026 20:37
golfromeo-fr added a commit to golfromeo-fr/opencode that referenced this pull request Nov 3, 2026
@golfromeo-fr
test(core): drop catalog cost cases covering unchanged code
140c43e
Review feedback on anomalyco#59803: the tier and cache-write pricing behavior
they pinned lives in SessionUsage.calculateCost, which this PR does not
change, and the changed code is already covered by the builder and
adapter tests.
opencodejr[bot]
opencodejr Bot reviewed Nov 3, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This push rebases onto the latest dev. The PR's own changes are the same as in the previous version. The newer dev commits touch packages/ai and aisdk.ts, but they don't change the token helpers this PR uses or how usage is mapped. I re-ran the Copilot tests and my adapted #52089/#51845 reproduction at this head: cache-write prices, the long-context tier and the streamed cacheWrite/noCache values are all still correct. No new concerns, and the public API is unchanged.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@golfromeo-fr
golfromeo-fr force-pushed the copilot-tier-pricing branch from 140c43e to 808d08f Compare November 4, 2026 01:57
golfromeo-fr added a commit to golfromeo-fr/opencode that referenced this pull request Nov 4, 2026
@golfromeo-fr
test(core): drop catalog cost cases covering unchanged code
808d08f
Review feedback on anomalyco#59803: the tier and cache-write pricing behavior
they pinned lives in SessionUsage.calculateCost, which this PR does not
change, and the changed code is already covered by the builder and
adapter tests.
opencodejr[bot]
opencodejr Bot reviewed Nov 4, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This push rebases onto the latest dev. The PR's own changes are the same as in the previous version, and the newer dev commits don't touch the Copilot provider or the cost calculation. I re-ran the Copilot tests and my adapted #52089/#51845 reproduction at this head: cache-write prices, the long-context tier and the streamed cacheWrite/noCache values are all still correct. No new concerns, and the public API is unchanged.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@golfromeo-fr
golfromeo-fr force-pushed the copilot-tier-pricing branch from 808d08f to c51db7e Compare November 9, 2026 13:29
golfromeo-fr added a commit to golfromeo-fr/opencode that referenced this pull request Nov 9, 2026
@golfromeo-fr
test(core): drop catalog cost cases covering unchanged code
c51db7e
Review feedback on anomalyco#59803: the tier and cache-write pricing behavior
they pinned lives in SessionUsage.calculateCost, which this PR does not
change, and the changed code is already covered by the builder and
adapter tests.
opencodejr[bot]
opencodejr Bot reviewed Nov 9, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This push rebases onto dev after #62034. That PR moved Copilot onto the shared packages/ai protocols and removed the copied chat/responses adapters. Those protocols already record cache-write tokens, so this PR is now only the price-building change in models.ts, which is the same as before.

I checked prices loaded from a mock Copilot /models on the new base and with this change:

  • Base: the cache-write price is $0, there is no long-context tier, and the #51845 session estimate is $3.974241.
  • This change: cache writes cost $5/M, the long-context tier applies above default.max_prompt_tokens, and the estimate is $11.437866. A 300K-token request is charged at long-context prices.

The Copilot model tests and the packages/ai compatible chat/responses tests pass. No concerns, and the public API is unchanged.

One small thing: the description still describes changes to the streaming adapters, which no longer exist on dev. You may want to update it.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
golfromeo-fr added a commit to golfromeo-fr/opencode that referenced this pull request Nov 9, 2026
@golfromeo-fr
test(core): drop catalog cost cases covering unchanged code
f4a6037
Review feedback on anomalyco#59803: the tier and cache-write pricing behavior
they pinned lives in SessionUsage.calculateCost, which this PR does not
change, and the changed code is already covered by the builder and
adapter tests.
@golfromeo-fr
golfromeo-fr force-pushed the copilot-tier-pricing branch from c51db7e to f4a6037 Compare November 9, 2026 13:54
opencodejr[bot]
opencodejr Bot reviewed Nov 9, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This push rebases onto the latest dev. The models.ts change and its test are the same as before, and the newer dev commits don't touch the Copilot provider or the cost calculation. The description now explains that #62034 covers counting cache-write tokens, which addresses my earlier note. I re-ran the Copilot tests and the pricing reproduction at this head. Cache writes are priced, the long-context tier applies above default.max_prompt_tokens, and the #51845 estimate is $11.437866. No new concerns, and the public API is unchanged.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@golfromeo-fr
golfromeo-fr force-pushed the copilot-tier-pricing branch from f4a6037 to c51db7e Compare November 9, 2026 16:04
opencodejr[bot]
opencodejr Bot reviewed Nov 9, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The branch is back on the earlier commit, which sits on a slightly older dev. The models.ts change and its test are identical to the previous push. I re-ran the Copilot tests and the pricing reproduction at this head. Cache writes are priced, the long-context tier applies above default.max_prompt_tokens, and the #51845 estimate is $11.437866. No new concerns, and the public API is unchanged.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
golfromeo-fr added a commit to golfromeo-fr/opencode that referenced this pull request Nov 9, 2026
@golfromeo-fr
test(core): drop catalog cost cases covering unchanged code
9be17ad
Review feedback on anomalyco#59803: the tier and cache-write pricing behavior
they pinned lives in SessionUsage.calculateCost, which this PR does not
change, and the changed code is already covered by the builder and
adapter tests.
@golfromeo-fr
golfromeo-fr force-pushed the copilot-tier-pricing branch from c51db7e to 9be17ad Compare November 9, 2026 16:45
opencodejr[bot]
opencodejr Bot reviewed Nov 9, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This push rebases onto the latest dev. The models.ts change and its test are identical to the previous push, and the newer dev commits don't touch the Copilot provider or the cost calculation. I re-ran the Copilot tests and the pricing reproduction at this head. Cache writes are priced, the long-context tier applies above default.max_prompt_tokens, and the #51845 estimate is $11.437866. No new concerns, and the public API is unchanged.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@golfromeo-fr
golfromeo-fr force-pushed the copilot-tier-pricing branch from 9be17ad to 233d2b7 Compare November 10, 2026 11:12
golfromeo-fr added a commit to golfromeo-fr/opencode that referenced this pull request Nov 10, 2026
@golfromeo-fr
test(core): drop catalog cost cases covering unchanged code
233d2b7
Review feedback on anomalyco#59803: the tier and cache-write pricing behavior
they pinned lives in SessionUsage.calculateCost, which this PR does not
change, and the changed code is already covered by the builder and
adapter tests.
opencodejr[bot]
opencodejr Bot reviewed Nov 10, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This push rebases onto the latest dev. The models.ts change and its test are the same as before. dev also edited models.ts (#62997, the new Copilot Auto model), but not the price-building code, and this change applies cleanly on top. I re-ran the Copilot tests and the pricing reproduction at this head. Cache writes are priced, the long-context tier applies above default.max_prompt_tokens, and the #51845 estimate is $11.437866. No new concerns, and the public API is unchanged.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@golfromeo-fr
golfromeo-fr force-pushed the copilot-tier-pricing branch from 233d2b7 to 34a9bc9 Compare November 10, 2026 16:46
golfromeo-fr added a commit to golfromeo-fr/opencode that referenced this pull request Nov 10, 2026
@golfromeo-fr
test(core): drop catalog cost cases covering unchanged code
34a9bc9
Review feedback on anomalyco#59803: the tier and cache-write pricing behavior
they pinned lives in SessionUsage.calculateCost, which this PR does not
change, and the changed code is already covered by the builder and
adapter tests.
golfromeo-fr added 2 commits November 10, 2026 17:48
@golfromeo-fr
fix(core): price Copilot long-context tiers and cache writes
9b0c703
Copilot's /models payload exposes per-request price tiers (default plus
long_context with its own prices and max_prompt_tokens) and a
cache_write_price, but the model builder read only the default tier and
hardcoded cache writes to zero, and both usage adapters dropped
cache_write_tokens entirely. Long sessions on tiered models like Claude
Haiku 5.5 were undercounted ~6x.

The builder now emits the cache write price and a context-tier cost entry
bounded by the default tier's max_prompt_tokens, which
SessionUsage.calculateCost already applies per request. Both Copilot
adapters map cache_write_tokens (or Anthropic-style
cache_created_input_tokens) into cacheWrite and keep the non-cached
input consistent with the total.
@golfromeo-fr
test(core): drop catalog cost cases covering unchanged code
98c25be
Review feedback on anomalyco#59803: the tier and cache-write pricing behavior
they pinned lives in SessionUsage.calculateCost, which this PR does not
change, and the changed code is already covered by the builder and
adapter tests.
@golfromeo-fr
golfromeo-fr force-pushed the copilot-tier-pricing branch from 34a9bc9 to 98c25be Compare November 10, 2026 16:48
opencodejr[bot]
opencodejr Bot reviewed Nov 10, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This push rebases onto the latest dev. The models.ts change and its test are identical to the previous push, and the newer dev commits don't touch the Copilot price builder or the cost calculation. I re-ran the Copilot tests and the pricing reproduction at this head. Cache writes are priced, the long-context tier applies above default.max_prompt_tokens, and the #51845 estimate is $11.437866. No new concerns, and the public API is unchanged.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@golfromeo-fr

golfromeo-fr commented Nov 10, 2026

Copy link
Copy Markdown
Author

With #62034 landed, session cost now uses what Copilot actually charged per request (copilot_usage), and #52089 was closed with that as the fix shipping in v2.2.7 — so the undercount this PR set out to fix is resolved for displayed costs.

I'm keeping the PR open in case the catalog fallback is still worth correcting: models.ts on dev still prices cache writes at $0 and ignores the long_context tier, and that catalog is what the TUI's per-request cost estimates, the model-picker pricing, and the stats aggregations consume when no reported cost is available. The change is small (builder + test), rebased on current dev, and the review bot has validated it at several heads.

If you'd rather handle catalog pricing alongside the billing work, I'm happy to close this — your call. Either way, thanks for the quick turnaround on the billing half.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@opencodejr opencodejr[bot] opencodejr[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

github-copilot: session cost ignores cache writes and long-context pricing GitHub Copilot cache-write tokens are omitted from session cost estimates

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@golfromeo-fr
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.