-
Notifications
You must be signed in to change notification settings - Fork 2.4k
A couple more sonnet 4.5 fixes #8421
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
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 |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query" | |
| import { renderHook } from "@testing-library/react" | ||
| import type { Mock } from "vitest" | ||
|
|
||
| import { ProviderSettings, ModelInfo, BEDROCK_CLAUDE_SONNET_4_MODEL_ID } from "@roo-code/types" | ||
| import { ProviderSettings, ModelInfo, BEDROCK_1M_CONTEXT_MODEL_IDS } from "@roo-code/types" | ||
|
|
||
| import { useSelectedModel } from "../useSelectedModel" | ||
| import { useRouterModels } from "../useRouterModels" | ||
|
|
@@ -474,28 +474,28 @@ describe("useSelectedModel", () => { | |
| it("should enable 1M context window for Bedrock Claude Sonnet 4 when awsBedrock1MContext is true", () => { | ||
| const apiConfiguration: ProviderSettings = { | ||
| apiProvider: "bedrock", | ||
| apiModelId: BEDROCK_CLAUDE_SONNET_4_MODEL_ID, | ||
| apiModelId: BEDROCK_1M_CONTEXT_MODEL_IDS[0], | ||
|
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. [P1] Similar to the Bedrock tests, this relies on BEDROCK_1M_CONTEXT_MODEL_IDS[0]. Consider adding a corresponding test for the 4.5 model or removing reliance on array order in tests. |
||
| awsBedrock1MContext: true, | ||
| } | ||
|
|
||
| const wrapper = createWrapper() | ||
| const { result } = renderHook(() => useSelectedModel(apiConfiguration), { wrapper }) | ||
|
|
||
| expect(result.current.id).toBe(BEDROCK_CLAUDE_SONNET_4_MODEL_ID) | ||
| expect(result.current.id).toBe(BEDROCK_1M_CONTEXT_MODEL_IDS[0]) | ||
| expect(result.current.info?.contextWindow).toBe(1_000_000) | ||
| }) | ||
|
|
||
| it("should use default context window for Bedrock Claude Sonnet 4 when awsBedrock1MContext is false", () => { | ||
| const apiConfiguration: ProviderSettings = { | ||
| apiProvider: "bedrock", | ||
| apiModelId: BEDROCK_CLAUDE_SONNET_4_MODEL_ID, | ||
| apiModelId: BEDROCK_1M_CONTEXT_MODEL_IDS[0], | ||
| awsBedrock1MContext: false, | ||
| } | ||
|
|
||
| const wrapper = createWrapper() | ||
| const { result } = renderHook(() => useSelectedModel(apiConfiguration), { wrapper }) | ||
|
|
||
| expect(result.current.id).toBe(BEDROCK_CLAUDE_SONNET_4_MODEL_ID) | ||
| expect(result.current.id).toBe(BEDROCK_1M_CONTEXT_MODEL_IDS[0]) | ||
| expect(result.current.info?.contextWindow).toBe(200_000) | ||
| }) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -367,11 +367,11 @@ function getSelectedModel({ | |
| // Apply 1M context beta tier pricing for Claude Sonnet 4 | ||
| if ( | ||
| provider === "anthropic" && | ||
| id === "claude-sonnet-4-20250514" && | ||
| (id === "claude-sonnet-4-20250514" || id === "claude-sonnet-4-5") && | ||
|
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. [P2] Robustness: selecting tiers?.[0] assumes the 1M tier is always first. Prefer selecting the highest-contextWindow tier to avoid order-dependence. |
||
| apiConfiguration.anthropicBeta1MContext && | ||
| baseInfo | ||
| ) { | ||
| // Type assertion since we know claude-sonnet-4-20250514 has tiers | ||
| // Type assertion since we know claude-sonnet-4-20250514 and claude-sonnet-4-5 have tiers | ||
| const modelWithTiers = baseInfo as typeof baseInfo & { | ||
| tiers?: Array<{ | ||
| contextWindow: number | ||
|
|
||
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.
[P1] Tests rely on BEDROCK_1M_CONTEXT_MODEL_IDS[0]. Suggest adding a test case for the 4.5 entry (index 1) or refactoring tests to avoid index assumptions so we won't regress if the array order changes.