Skip to content

refactor(opencode): remove legacy 200k pricing - #44292

Open
opencode-agent[bot] wants to merge 1 commit into
devfrom
remove-200k-context
Open

refactor(opencode): remove legacy 200k pricing#44292
opencode-agent[bot] wants to merge 1 commit into
devfrom
remove-200k-context

Conversation

@opencode-agent

Copy link
Copy Markdown
Contributor

Summary

  • remove the legacy context_over_200k and experimentalOver200K pricing paths from OpenCode
  • select local request pricing exclusively from the model's context tiers
  • preserve catalog tiers when provider configuration overlays a model
  • remove the legacy fields from config schemas and regenerate the public OpenAPI/SDK surfaces

Testing

  • bun test test/plugin/models-dev.test.ts (packages/core)
  • bun typecheck (packages/core)
  • targeted provider tier-preservation and session tier-selection tests (packages/opencode)
  • bun typecheck (packages/sdk/js)
  • SDK/OpenAPI generation

Requested by: @rekram1-node (Aiden via Slack)

@Enough1122

Copy link
Copy Markdown

AI code review — automated review for reference, author can ignore or act on any point.

Consolidating on tiers and deleting the two parallel legacy paths is the right direction — one pricing mechanism, one fallback rule, and the updated tests now document the new semantics explicitly. A few things worth nailing down before merge:

  1. Silent cost regression for models that only had legacy >200k pricing. After this change, getUsage (packages/opencode/src/session/session.ts, ~lines 380–383) falls back to base cost when no context tier matches. Two sources of models previously covered by the legacy fields:

    • User configs still containing context_over_200k: with the field gone from ConfigProviderV1.Model (packages/core/src/v1/config/provider.ts), please confirm whether decoding strips it silently or fails validation — a hard error would break existing setups, a silent strip quietly re-prices long-context requests at base rates. If it's the latter, a deprecation warning during config load would soften the landing.
    • Upstream models.dev data: if any catalog entry still carries only context_over_200k (not tiers), the conversion in packages/core/src/plugin/models-dev.ts now drops it entirely. Worth verifying upstream has fully migrated those entries to tiers before this ships, or accepting the temporary regression knowingly.
  2. Overlay asymmetry between base cost and tiers. The new preservation line (packages/opencode/src/provider/provider.ts, ~line 1514) keeps catalog tiers when user config overlays a model — good for the empty-override case in the new test. But the inverse has no escape hatch: config can replace base input/output yet can neither supply its own tiers nor clear inherited ones. A user pointing a model at a flat-rate proxy ends up with custom base pricing above 200k switching back to catalog tier rates mid-request. Consider allowing tiers in config cost, or an explicit way to reset them.

  3. Test nit (packages/opencode/test/provider/provider.test.ts, "model config preserves catalog cost tiers"): asserting exact tier literals pins the test to today's catalog numbers. More robust: fetch the un-overlaid catalog model first and assert the overlaid one's tiers deep-equal it — same guarantee, zero churn when models.dev updates.

Otherwise the removals are consistent across schemas, conversions, OpenAPI, and SDK types — nice, thorough sweep.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants