Skip to content

Conversation

@roomote
Copy link

@roomote roomote bot commented Oct 6, 2025

Summary

This PR addresses Issue #8541 by enabling support for Claude 4.5 global inference profiles in AWS Bedrock, allowing users with limited region access to utilize thinking tokens and 1M context options.

Problem

AWS Bedrock users who have access to limited regions cannot use the foundational model ID for Claude 4.5 directly. They need to use the global inference profile ARN (e.g., arn:aws:bedrock:us-east-1:148761681080:inference-profile/global.anthropic.claude-sonnet-4-5-20250929-v1:0), but Roo Code was not enabling thinking tokens and 1M context options for custom ARNs.

Solution

This implementation takes a flexible pattern-matching approach that:

  • Detects Claude Sonnet 4.5 models in custom ARNs (including global inference profiles)
  • Enables thinking tokens (reasoning budget) for detected Claude 4.5 models
  • Enables 1M context option for detected Claude 4.5 models
  • Maintains backward compatibility with existing configurations

Changes

Backend ()

  • Added isClaudeSonnet45Model() helper to detect Claude 4.5 patterns
  • Enhanced guessModelInfoFromId() to recognize Claude 4.5 models with full feature support
  • Modified 1M context eligibility check to include custom ARNs matching Claude 4.5 patterns
  • Added null safety for undefined model IDs

Frontend

  • Settings Component (webview-ui/src/components/settings/providers/Bedrock.tsx): Added pattern matching to show 1M context option for Claude 4.5 custom ARNs
  • Model Selection Hook (webview-ui/src/components/ui/hooks/useSelectedModel.ts): Enhanced custom ARN handling to properly set model capabilities for Claude 4.5 models

Tests

  • Added comprehensive test suite (src/api/providers/__tests__/bedrock-global-inference.spec.ts) covering:
    • Global inference profile ARN detection
    • 1M context enablement
    • Thinking/reasoning features
    • Various Claude 4.5 ARN patterns
    • ARN parsing validation

Testing

  • ✅ All existing tests pass
  • ✅ New test suite with 6 test cases covering all scenarios
  • ✅ Linting and type checking pass

Impact

This change enables AWS Bedrock users with limited region access to fully utilize Claude 4.5 capabilities through global inference profiles, addressing a key limitation for enterprise users with restricted AWS configurations.

Fixes #8541


Important

Adds support for Claude 4.5 global inference profiles in AWS Bedrock, enabling thinking tokens and 1M context options for users with limited region access.

  • Behavior:
    • Supports Claude 4.5 global inference profiles in AWS Bedrock, enabling thinking tokens and 1M context options.
    • Maintains backward compatibility with existing configurations.
  • Backend (bedrock.ts):
    • Adds isClaudeSonnet45Model() to detect Claude 4.5 patterns.
    • Enhances guessModelInfoFromId() for Claude 4.5 model recognition.
    • Modifies 1M context eligibility check for custom ARNs.
  • Frontend:
    • Settings Component (Bedrock.tsx): Adds pattern matching for Claude 4.5 ARNs.
    • Model Selection Hook (useSelectedModel.ts): Enhances custom ARN handling for Claude 4.5.
  • Tests:
    • Adds test suite (bedrock-global-inference.spec.ts) for global inference profile detection, 1M context, and reasoning features.
  • Misc:
    • Adds null safety for undefined model IDs in bedrock.ts.

This description was created by Ellipsis for a6c2c58. You can customize this summary. It will automatically update as commits are pushed.

- Add detection for Claude Sonnet 4.5 models in custom ARNs
- Enable thinking tokens and 1M context options for Claude 4.5 global inference profiles
- Update UI to show options for custom ARNs matching Claude 4.5 patterns
- Add comprehensive tests for global inference profile support

Fixes #8541
@roomote roomote bot requested review from cte, jr and mrubens as code owners October 6, 2025 19:51
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Oct 6, 2025
Copy link
Author

@roomote roomote bot left a comment

Choose a reason for hiding this comment

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

Self-review engaged: like a linter arguing with a mirror, I will now pedantically critique my own reflection.

}
})

vitest.mock("../../../utils/logging")
Copy link
Author

Choose a reason for hiding this comment

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

[P1] The logger module is mocked without a factory, but the test asserts on logger.info. To ensure logger.info is a spy, explicitly mock the module exports with a concrete logger object.

Suggested change
vitest.mock("../../../utils/logging")
vitest.mock("../../../utils/logging", () => ({
logger: {
info: vi.fn(),
error: vi.fn(),
warn: vi.fn(),
debug: vi.fn(),
},
}))

const isEligibleFor1MContext =
BEDROCK_1M_CONTEXT_MODEL_IDS.includes(baseModelId as any) || this.isClaudeSonnet45Model(modelConfig.id)
const is1MContextEnabled = isEligibleFor1MContext && this.options.awsBedrock1MContext

Copy link
Author

Choose a reason for hiding this comment

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

[P2] 1M context is enabled via anthropic_beta for custom Claude 4.5 ARNs, but getModel() still reports a 200k contextWindow for these cases. This can desync pricing/limits and any logic relying on info.contextWindow. Consider also setting info.contextWindow to 1_000_000 when awsBedrock1MContext is true for 4.5 custom ARNs to keep behavior consistent across UI, cost model, and runtime.

const id = apiConfiguration.apiModelId ?? bedrockDefaultModelId
const baseInfo = bedrockModels[id as keyof typeof bedrockModels]

// Helper function to check if a model ID or ARN represents a Claude Sonnet 4.5 model
Copy link
Author

Choose a reason for hiding this comment

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

[P2] Claude 4.5 detection logic is duplicated here and in settings/providers/Bedrock.tsx, and again in the backend. This increases drift risk. Recommend extracting a shared helper (e.g., a small util in a shared package) and reusing it across frontend/backend so feature gating (thinking + 1M) stays consistent.

id.includes("claude-sonnet-4-5") ||
id.includes("claude-sonnet-4.5") ||
// Specific check for the global inference profile ARN mentioned in the issue
id.includes("global.anthropic.claude-sonnet-4-5-20250929")
Copy link
Author

Choose a reason for hiding this comment

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

[P3] The pattern check hardcodes the date suffix "20250929". Since the broader checks already match 'claude-sonnet-4-5'/'claude-sonnet-4.5', this specific fragment is brittle and redundant. Consider removing or relaxing it to avoid unexpected mismatches when AWS updates the ARN version.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Oct 6, 2025
@marianobilli
Copy link

Feature raised by mistake, please cancel

@daniel-lxs
Copy link
Member

Issue was closed

@daniel-lxs daniel-lxs closed this Oct 28, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Oct 28, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Oct 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[ENHANCEMENT] Enable Claude 4.5 global inference profile support for AWS Bedrock

5 participants