Skip to content

refactor(opencode): one price mapper for catalog and config cost tiers - #35

Merged
goleary merged 2 commits into
devfrom
tier-price
Sep 2, 2026
Merged

goleary merged 2 commits into
devfrom
tier-price

Conversation

@goleary

@goleary goleary commented Sep 2, 2026 •

Copy link
Copy Markdown

Follow-up to #34, applying the simplification patch Andrew posted in Slack verbatim. No merge until Andrew and Gabe have reviewed.

Context

#34 landed the tiered-pricing fix with four hand-written mappings from models.dev / config cost shapes (cache_read, cache_write) to the model's { input, output, cache }, and the config merge still set experimentalOver200K alongside the 200K tier it synthesizes from a config context_over_200k, contradicting the converter's rule that the legacy field exists only when a model has no tiers.

Changes

  • One price() mapper handles base cost, catalog tiers, the catalog's context_over_200k, and a config context_over_200k.
  • The merge sets experimentalOver200K to undefined whenever it synthesizes the 200K tier, so catalog-only and config-named models follow the same rule.
  • Every comment is one line.
  • The two config-override tests collapse into one that covers openai/gpt-5.4 (catalog tier at 272K replaced by the 200K tier) and x-ai/grok-4 (catalog tier at 128K kept below it), priced through Session.getUsage at 150K and 300K.

Testing Done

Patch by Andrew Wang, from the Slack thread on #34.

🤖 Generated with Claude Code


Devin Review

Summary by cubic

Uses one price() mapper to normalize catalog and config cost tiers. Previously, a config context_over_200k override populated both a synthesized 200K tier and experimentalOver200K; now it creates only the tier and clears the legacy field, while usage pricing remains unchanged.

Refactors

  • Reuses price() for base costs, catalog tiers, and long-context overrides.
  • Tests cover replacing the openai/gpt-5.4 catalog tier and retaining the lower x-ai/grok-4 tier.
  • Provider tests pass, and package typechecking is clean.

Written for commit 54c1933. Summary will update on new commits.

Review in cubic

Andrew's simplification of #34: a single price() turns models.dev and
config cost shapes into {input, output, cache}, the merge no longer sets
experimentalOver200K alongside a config-derived 200K tier, and the two
override tests collapse into one covering gpt-5.4 and grok-4. No pricing
change beyond the legacy field now being undefined whenever tiers exist.

Co-Authored-By: Andrew Wang <andrew@replo.app>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

The following comment was made by an LLM, it may be inaccurate:

cubic-dev-ai[bot]

This comment was marked as resolved.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@goleary

goleary commented Sep 2, 2026

Copy link
Copy Markdown
Author

/devin review

@devin-ai-integration

Copy link
Copy Markdown

Starting Devin Review.

Devin Review

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions Bot closed this Sep 2, 2026
@goleary goleary reopened this Sep 2, 2026
@goleary
goleary merged commit 49367d8 into dev Sep 2, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants