-
Notifications
You must be signed in to change notification settings - Fork 1k
feat(anthropic): inherit context window for numeric variants #3521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f5df549
ee7fa9f
a331928
021c389
cc6a975
9e31156
5b75c80
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -626,8 +626,36 @@ export function clearGatherRoutedModelsInflight(): void { | |
| gatherInflight.clear(); | ||
| } | ||
|
|
||
| const NUMERIC_MODEL_ID_SEGMENT = /^\d+$/; | ||
|
|
||
| /** | ||
| * Resolve an unknown Claude point release or date pin from the nearest configured | ||
| * family row. Only numeric tail segments are removed so unrelated model families | ||
| * cannot inherit one another's limits. | ||
| */ | ||
| function anthropicFamilyContextWindow( | ||
| record: Record<string, number> | undefined, | ||
| id: string, | ||
| ): number | undefined { | ||
| if (!record || !id.toLowerCase().startsWith("claude-")) return undefined; | ||
| let candidate = id; | ||
| while (true) { | ||
| const cut = candidate.lastIndexOf("-"); | ||
| if (cut <= 0 || !NUMERIC_MODEL_ID_SEGMENT.test(candidate.slice(cut + 1))) return undefined; | ||
| candidate = candidate.slice(0, cut); | ||
| const value = modelRecordValue(record, candidate); | ||
| if (typeof value === "number" && value > 0) return value; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Resolve the configured context window in exact-model, Anthropic numeric-family, | ||
| * then provider-wide order. Return undefined when the selected value is not positive. | ||
| */ | ||
| export function configuredContextWindow(prov: OcxProviderConfig, id: string): number | undefined { | ||
| const configured = modelRecordValue(prov.modelContextWindows, id) ?? prov.contextWindow; | ||
| const configured = modelRecordValue(prov.modelContextWindows, id) | ||
| ?? (prov.adapter === "anthropic" ? anthropicFamilyContextWindow(prov.modelContextWindows, id) : undefined) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For an Anthropic numeric variant with a smaller provider-wide fallback—for example the tested AGENTS.md reference: src/AGENTS.md:L18-L18 Useful? React with 👍 / 👎. |
||
| ?? prov.contextWindow; | ||
| return typeof configured === "number" && configured > 0 ? configured : undefined; | ||
| } | ||
|
|
||
|
|
||
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 changes the public meaning of
modelContextWindows, butdocs-site/src/content/docs/reference/configuration/providers.md:129still describes it only as a per-model map and gives operators no indication that an Anthropic key such asclaude-fable-5also applies to numeric descendants. Document the matching order and Anthropic-only numeric-tail behavior so configuration edits do not unexpectedly affect additional models.AGENTS.md reference: src/AGENTS.md:L29-L29
Useful? React with 👍 / 👎.