Repository navigation
docs(sdk): deprecate context_over_200k - #5335
Merged
Merged
Conversation
Contributor
|
No actionable findings. |
vitfera
pushed a commit
to vitfera/twenty
that referenced
this pull request
Nov 13, 2026
…#30141) Fixes twentyhq#30144 ## Problem The catalog sync prices long context from models.dev's `context_over_200k` and gives every model a 200K threshold (`LONG_CONTEXT_THRESHOLD_TOKENS`). models.dev deprecated that field on 2026-08-23 ([anomalyco/models.dev#5335](anomalyco/models.dev#5335)). The real threshold now comes from `cost.tiers[].tier.size`, and it isn't always 200K: - **13 OpenAI models** (gpt-6-luna, gpt-6-sol, gpt-6.1-sol, gpt-5.6, gpt-5.5, gpt-5.4 and others) switch to long-context rates above **272K**. `computeCostBreakdown` switches them at 200K, so a request of 200K–272K is debited at double the input rate. - **Claude Haiku 5.5** switches above **100K**, to 5× its base rates. models.dev publishes that tier only in `tiers`, so the catalog has no `longContextCost` for it, and requests over 100K are debited at base rates. Debited by `computeCostBreakdown` today, against the provider's price (90% of input cache-read, 1K output): | Model | Input | Provider price | Debited today | |---|---|---|---| | gpt-6-luna | 240K | $0.0051 | $0.0099 | | gpt-6.1-sol | 240K | $0.0796 | $0.1542 | | claude-haiku-5-5 | 150K | $0.0168 | $0.0034 | ## Fix - `extractCost` takes the lowest `context` tier from `cost.tiers` and uses its `size` as `thresholdTokens`. - It falls back to `context_over_200k` at 200K when a model has no tiers. - `ModelsDevModel` gains the `tiers` field. Built against today's models.dev payload, the only catalog changes are: - the 13 OpenAI thresholds (200K → 272K); - Haiku 5.5 gaining its 100K tier; - gpt-6.1-terra getting its 272K tier. Rates and the Google and xAI entries are unchanged. `ai-models.json` and `ai-providers.json` aren't regenerated here; the next daily sync rewrites them. The regenerated catalog can be added to this PR if preferred. ## Test plan - [x] `build-catalog.spec.ts`: two new cases, a 272K tier quoted in both fields and a 100K tier quoted only in `tiers`. Both fail on `main` (200000 instead of 272000; `longContextCost` undefined) and pass with the fix. - [x] All suites under `scripts/ai-catalog-sync` and `metadata-modules/ai` pass, except `build-front-component-shared-dependencies`, which needs a local `twenty-ui` build. - [x] oxlint and oxfmt are clean on the changed files. `tsgo` reports no errors in them. Written with Claude Code (Claude Opus 5.5). <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/twentyhq/twenty/pull/30141?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a> <!-- End of auto-generated description by cubic. --> --------- Co-authored-by: Etienne <[email protected]>
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.
Summary
ModelCost.context_over_200kas deprecated in SDK type metadatatiersfor the exact context thresholdChecks
bun run --cwd packages/sdk generatebun run --cwd packages/sdk typecheckgit diff --checkRequested by: @rekram1-node (Aiden via Slack)