Files
magpie/internal/provider/testdata
yetone 7670295019 copilot: list each model's long-context tier, as Copilot Chat asks /models (gtliuu on X)
gtliuu on X: Copilot's Claude Opus 5.5 has a 200K and a long tier, and magpie
offered only 200K. magpie asked /models at X-GitHub-Api-Version 2026-01-09,
and at that version Copilot lists only the default tier's
max_prompt_tokens. Copilot Chat 0.68 never sends 2026-01-09:
@vscode/copilot-api 0.5.2's _mixinHeaders sets 2026-08-01 on every Copilot
API request, Models included, over networking.ts's 2026-01-09. At
2026-06-01 and later, /models gives each model its whole window (Opus 5.5
1M) and billing.token_prices with a default tier and a long_context tier.

- The editors' sign-in asks GET /models at 2026-08-01
  (copilotModelsVersion). The Copilot CLI's sign-in keeps its own
  2026-07-01, which already lists the tiers. Chat requests are unchanged:
  Copilot served prompts past the default tier at 2026-01-09. The other
  requests still on 2026-01-09 are #6571.
- The window follows Copilot Chat (languageModelAccess.ts and
  agentIntent.ts). A long tier at the default's prices gives the whole
  window: Claude Opus 5.5 1M, and the Sonnet, Fable and Gemini models
  936K or 983K. A long tier with a surcharge keeps the default tier's
  prompt as the window agents are told. The whole window becomes
  MaxContext, which the user can raise the window to. GPT-6 Luna gets
  272K and 872K, and Claude Haiku 5.5 100K and 936K. The whole window is
  the limits' max_prompt_tokens, not the long tier's prompt: Grok 4.7's
  long tier says 500000, but Copilot takes 372000.
- Price: Copilot's own list (AIU per batch_size tokens / 100 = USD per M)
  is the list price, ahead of models.dev. A long tier with a surcharge
  becomes a Tier above the default's prompt. Both 2026-06-01's field
  names (cache_price, context_max) and 2026-08-01's are read. GPT-4.1's
  all-zero list is no price. A flat, older list changes nothing.

Run (base origin/main 7b50e1f2c):
- go test -tags nogui -count=1 -timeout 45m ./internal/provider/...
  ./internal/catalog/... ./internal/gateway/... ./internal/usage/... on
  mote, in a sandbox HOME: all ok (provider 139s, catalog 3s, gateway
  918s, usage 42s). Not the whole ./...: mote's suite lock had six suites
  queued, and mica's disk is full.
- GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./..., and the
  linux and windows builds: ok.
- gofmt -l: clean.
- Fixtures are the owner's account's real /models replies at 2026-01-09,
  2026-06-01 and 2026-08-01, trimmed to four models.
- Real use: a -tags dev build in a sandbox HOME with only
  github-copilot/apps.json copied, on 127.0.0.1:3476. Its /v1/models
  lists copilot/claude-opus-5.5 at 1000000 (200000 before) and
  gpt-6-luna at 272000, both priced from Copilot's list. A
  584,849-token prompt to copilot/claude-opus-5.5 on /v1/messages got
  200 end_turn, billed by Copilot at 233.9 AIU (400 an M, the default
  tier's price).

Broken by hand, each red:
- /models asked without copilotModelsVersion: TestCopilotListsTheLongContextTier.
- tiers not applied: that test and TestCopilotTiersAtTheFirstTieredVersion.
- the long tier's prompt over the limits': red on Grok 4.7's 500000.
- context_max not read: TestCopilotTiersAtTheFirstTieredVersion.
- copilotListPrice off: TestCopilotListPriceIsCopilots.

Not tried: a request on a surcharged model raised past its default
tier (GPT-6 Luna over 272K), or a Business or Enterprise account's list.
2026-11-14 03:37:38 +08:00
..