Skip to content

Fix Amazon Ergo 1.0 routing and prices in Bedrock - #2815

Merged
edelauna merged 5 commits into
mainfrom
fix/bedrock-ergo-model-registry-365nn5m4b9gvk
Dec 4, 2026
Merged

edelauna merged 5 commits into
mainfrom
fix/bedrock-ergo-model-registry-365nn5m4b9gvk

Conversation

@zoomote

@zoomote zoomote Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

​Created by Roomote. Follow up by mentioning @roomote, in the web UI, or in Discord.

Related GitHub Issue

Closes: #2814

Description

Bedrock used the fallback Claude model for amazon.ergo-1.0. Requests now use the Ergo registry entry.

The entry has a 1,000,000-token context window and a 131,072-token output limit. It supports prompt caching and text input.

Ergo requires explicit routing consent. Global inference takes priority. US cross-region inference requires a supported US region. Save and both request methods reject configurations without either option. Foundation-model ARNs use their ARN region for validation and requests. Explicit profile ARNs keep their routing choice.

The Global option is available for Ergo, including custom ARNs. Validation messages use the checkbox labels in each locale.

Save, requests, and prices use one shared Ergo route resolver. The price helper consumes its result. Global input/output prices are $1/$3 per million tokens. US prices are $1.10/$3.30. Global cache read/write prices are $0.03/$1.25. US cache prices are $0.033/$1.375. Opaque application-profile and prompt-router ARNs use their region for a price estimate. Their actual target profile cannot be read from the ARN.

The getModel() routing changes affect all Bedrock models. Other models keep their routing behavior. Tests cover those ARNs with both inference options enabled.

The TLA+ model checks routing consent, construction, Save validation, region agreement, and price-reader agreement. Code tests check the implementation. The model does not prove code correctness.

Test Procedure

Local checks pass:

  • All Bedrock provider suites: 414 tests.
  • Types-package routing and ARN suites: 78 tests.
  • Validation, selected-model, and Bedrock component suites: 375 tests.
  • Docker visual checks: dark and light Ergo consent snapshots.
  • Type checks: extension, types package, and webview.
  • ESLint: changed TypeScript files. The provider test suppression count decreased.
  • TLC: the fixed configuration passes. All eight defect configurations fail as expected.

Run the focused tests from their package directories:

(cd src && pnpm exec vitest run api/providers/__tests__/bedrock)
(cd packages/types && pnpm exec vitest run src/__tests__/bedrock-ergo.test.ts src/__tests__/bedrock-custom-arn.test.ts)
(cd webview-ui && pnpm exec vitest run src/utils/__tests__/validate.spec.ts src/components/ui/hooks/__tests__/useSelectedModel.spec.ts src/components/settings/providers/__tests__/Bedrock.spec.tsx)
TLA_JAR=/path/to/tla2tools.jar docs/architecture/tla/check.sh BedrockErgo

Tests check outgoing model IDs in both request methods. The matrix includes foundation-model ARNs, mismatched regions, GovCloud, and unset options. Explicit profiles keep their ARN with both options enabled or disabled. Invalid routing sends no request and records no transport error.

Defect replay on the original code fails four Save assertions and five price assertions. The resolver tests also reject two deliberate defects: ignoring ARN regions and overriding explicit ARN routes. TLC checks 216 states after the non-US region classes were merged. No live AWS request was made for these checks.

Recorded Stream (new provider only)

Not applicable. This PR registers a model in an existing provider. It does not add a provider.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Listing Discussion (new provider or MCP server only): I opened a GitHub Discussion for this listing and linked it in the PR description.
  • Recorded Stream (new provider only): I added one recorded streaming response. It shows the finish chunk. If the handler reads cost or usage from chunks, it also shows the usage chunk.
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I reviewed my own code with care.
  • Writing Style: The PR title and description use Simplified Technical English (ASD-STE100): short sentences, plain words, active voice, one idea per sentence, no contractions.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Test Helpers (test changes only): Shared test helpers (src/test-utils/, @/utils/test-utils) are used only for mechanical duplication; test intent and scenario-specific mocks remain visible.
  • Visual Snapshot (UI changes only): If a user would notice this change at a glance (layout, theme tokens, brand elements, empty/error states), I added or updated a *.visual.tsx snapshot in webview-ui/. See webview-ui/AGENTS.md → "When a UI change needs a snapshot".
  • Documentation Impact: I checked if my changes need documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I read and agree to the Contributor Guidelines.

Visual Snapshots

BedrockErgo.visual.tsx covers the Ergo foundation-model ARN in dark and light themes. The snapshots show the consent error and the Global checkbox. The baselines were generated and checked with the pinned Playwright Docker image.

Videos (interaction / animation only)

Not applicable. No interaction or animation behavior changes.

Documentation Updates

Additional Notes

The issue reports the bug. A previous RCA session found the registry gap by source inspection. This PR applies the suggested fix from that issue.

Get in Touch

0x7777777_

@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
Pre-merge checks: Passed 3 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Regression Evidence Warning Summary: The changed Ergo routing has a concrete test gap at the Save-validation layer. Foundation-model ARN region handling is not tested, even though the PR description says it is. **Changed beh… 1. Add validate.spec.ts cases for foundation-model ARNs where the ARN region differs from awsRegion, in both directions. Include cross-region enabled and Global enabled. Expect the validation result that the request path uses. 2. Add a …
Passed Passed checks: 3 passed

Check name Status Explanation
Security Boundaries Passed PR #2815 (zoomote[bot], base main) adds the Bedrock model amazon.ergo-1.0 and an explicit routing-consent gate. I reviewed the PR commits b582729 and 5b922b3 (git diff b582729^ 5b922b3). The chang…
Persistence Integrity Passed The check fails only for a changed persistence path that can lose or corrupt state. I reviewed the PR's own commits (b582729 and 5b922b3) against their base (6df2566). The changed code does not touch …
Lifecycle Resource Cleanup Passed The PR adds Amazon Ergo 1.0 to the Bedrock registry, changes routing in getModel(), adds a validateInferenceProfile guard, and adds price helpers. I reviewed the PR commit range (a292226..HEAD, w…
Full details: Security Boundaries

Explanation

PR #2815 (zoomote[bot], base main) adds the Bedrock model amazon.ergo-1.0 and an explicit routing-consent gate. I reviewed the PR commits b582729 and 5b922b3 (git diff b582729^ 5b922b3). The changed code paths are src/api/providers/bedrock.ts, packages/types/src/providers/bedrock.ts, webview-ui/src/utils/validate.ts, locale strings, tests, and TLA+ docs. The security-relevant changes are the consent controls: - getModel() (bedrock.ts ~1291-1294) applies the Global or US profile for Ergo. getBedrockErgoInferenceProfile returns global when Global is set. It returns us only when cross-region is set and the region maps to us.. Otherwise it returns undefined, and the ID stays amazon.ergo-1.0. - validateInferenceProfile() (bedrock.ts ~892-899) runs at the start of both createMessage (line 435) and completePrompt (line 903). These are the only two Bedrock send paths (ConverseStreamCommand at 615 and ConverseCommand at 935). An unconsented Ergo request throws before any transport call. - Save validation (validate.ts ~109-124) rejects Ergo without a valid route. The request path enforces the same rule, so Save-time checks are not the only gate. I checked for bypasses: - Foundation-model ARNs: the constructor rewrites options.awsRegion to the ARN region (bedrock.ts ~255-267). The request path then uses that region. A mismatch can only fail closed. Ergo without consent throws. - GovCloud, ap-*, and other non-US regions do not map to us., so they are rejected unless Global is set. - Prefixed IDs such as us., eu., or global. strip to the base ID, so they cannot skip the check. - Explicit inference-profile or prompt-router ARNs skip the Ergo branch. The PR says this is intended. The user types the exact profile, so this is an explicit routing choice and not an unapproved bypass. I found no exposed secrets or personal data in the diff. The profile prefix comes from constants, not from user input, and ARN parsing is unchanged regex validation. I found no unvalidated input that reaches execution in a changed path. Non-security note: the Save-time check in validate.ts reads apiConfiguration.awsRegion. It does not read the ARN region. This can give a false block for a mismatched foundation ARN. The request path still fails closed, so this does not affect this check.

Full details: Persistence Integrity

Explanation

The check fails only for a changed persistence path that can lose or corrupt state. I reviewed the PR's own commits (b582729 and 5b922b3) against their base (6df2566). The changed code does not touch persistence: - packages/types/src/providers/bedrock.ts: adds the amazon.ergo-1.0 registry entry, the US price constants, getBedrockErgoInferenceProfile(), and an entry in BEDROCK_GLOBAL_INFERENCE_MODEL_IDS. These are static data and pure helpers. - src/api/providers/bedrock.ts: adds validateInferenceProfile(), which throws before a request. getModel() now sets the routed model ID and the US prices on the in-memory modelConfig object. None of this writes state. - webview-ui/src/utils/validate.ts: adds a consent check that returns a validation error string. It does not write settings. A rejected Save writes nothing. - Locale files: add one bedrockErgoInference message each. A search of the added non-test TypeScript lines found no globalState, secrets, file-system, localStorage, postMessage, save/upsert, .set(, rename, or un-awaited write calls. The PR therefore adds no changed write, rollback, or default-persistence path that could lose or corrupt state. The check passes. Note: the local HEAD also contains commits outside this PR, so I scoped the review to the two PR commits.

Full details: Lifecycle Resource Cleanup

Explanation

The PR adds Amazon Ergo 1.0 to the Bedrock registry, changes routing in getModel(), adds a validateInferenceProfile guard, and adds price helpers. I reviewed the PR commit range (a292226..HEAD, which covers b582729 and 5b922b3). The changed files are packages/types/src/providers/bedrock.ts and src/api/providers/bedrock.ts. The bedrock-converse-format.ts transform has no change in this range. Lifecycle review: - The diff adds no listener, watcher, timer, interval, subscription, AbortController, stream, client, or task. A search of added lines in src and packages/types found none of these. - validateInferenceProfile runs at the start of createMessage and completePrompt. It throws before any request or stream is created, so it allocates no resource that could leak. - getModel() now returns a modified id and info for Ergo and US routes. This is configuration state, not a resource. It does not create duplicate work after cancellation, disposal, or restart. - The new helpers getBedrockErgoInferenceProfile and BEDROCK_ERGO_US_PRICES are pure functions. They hold no state. No changed path leaks a listener, watcher, provider, timer, or task, and no changed path duplicates work after cancellation, disposal, or restart. The check passes. Note: the local main ref is behind the PR base, so a full base..HEAD diff includes unrelated OpenAI and webview changes. I scoped the review to the PR commits.

Full details: Regression Evidence

Explanation

Summary: The changed Ergo routing has a concrete test gap at the Save-validation layer. Foundation-model ARN region handling is not tested, even though the PR description says it is. Changed behavior (PR commits b582729 and 5b922b3, HEAD~2..HEAD): - webview-ui/src/utils/validate.ts (lines 113–124) checks Ergo routing for foundation-model ARNs. It calls getBedrockErgoInferenceProfile(apiConfiguration), which reads apiConfiguration.awsRegion, not the ARN region. - src/api/providers/bedrock.ts (lines 255–266) overwrites options.awsRegion with the ARN region on mismatch. The request path then routes by the ARN region (lines 1291–1294). - Save and request therefore read different regions for a mismatched foundation-model ARN. Missing evidence: - webview-ui/src/utils/__tests__/validate.spec.ts (lines 65–79) tests the foundation-model alias only with awsRegion: "eu-west-1" and the same ARN region. It has no mismatched-region case. That case would separate the two region sources. - src/api/providers/__tests__/bedrock.spec.ts adds Ergo request tests only for explicit profile ARNs and for apiModelId: "amazon.ergo-1.0". It has no foundation-model ARN request test for Global, US, or unset options. - The PR description says the tests cover foundation-model ARNs and mismatched regions. It also cites packages/types/src/__tests__/bedrock-ergo.test.ts and webview-ui/.../__tests__/BedrockErgo.visual.tsx. Neither file exists in this checkout. The Bedrock and useSelectedModel specs named in the description are not changed by these commits. Plausible regression case: awsRegion: "us-east-1", awsCustomArn: arn:aws:bedrock:eu-west-1::foundation-model/amazon.ergo-1.0, and cross-region enabled. Save accepts this configuration. The request path resolves the eu-west-1 region, finds no US profile, and does not send a valid model ID. The PR tests do not cover this case, so it is not caught. Scope note: The Global checkbox and the consent error are user-visible. The claimed visual snapshot is absent. Whether a snapshot is required depends on the webview-ui/AGENTS.md rule, which I did not read. The main basis for FAIL is the routing test gap above. Previous failure: The standing FAIL had no details. This run re-checked the same changed behavior and found the gap still present.

Resolution

  1. Add validate.spec.ts cases for foundation-model ARNs where the ARN region differs from awsRegion, in both directions. Include cross-region enabled and Global enabled. Expect the validation result that the request path uses. 2. Add a bedrock.spec.ts case for a foundation-model ARN with Global, US, and unset options. Include a mismatched ARN region. Assert the outgoing modelId in both createMessage and completePrompt, and assert that invalid routing sends no request. 3. Make Save validation use the same region as the request path, or document the intended rule and test it. In the current code, validation uses awsRegion and the request uses the ARN region. 4. Add the bedrock-ergo.test.ts file and the BedrockErgo.visual.tsx snapshot that the PR description cites, or remove those claims from the description.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Review status

This PR was opened by an automated account. A human maintainer must verify the change intent, provenance, and validation before merging.

Current step: Required CI passed. Waiting for automated review of the latest commit.

If automated review does not start, a maintainer must restart it.

Review-state labels are managed by this workflow; do not edit them manually. community-approved is managed the same way — do not add or remove it manually. It signals a fresh community code approval for the current head as an advisory priority only; maintainer review is still required.

@codecov

codecov Bot commented Dec 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@edelauna
edelauna marked this pull request as ready for review December 4, 2026 00:19
@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Changed-code mutation testing

Report for PR head a7db504ea582.

Surviving / uncovered mutants Advisories
8 1
Details: mutants, guidance, and reproduction

Changed-code mutation testing

PackageChanged executable linesValidKilledTimeoutSurvivedNo coverageResult
types527971071Advisory findings
extension2000000Advisory incomplete
webview202323000Passed

Focused tests

  • types (cwd packages/types): src/__tests__/provider-settings.test.ts, src/__tests__/provider-model-id.test.ts, src/__tests__/tool-repetition-limits.test.ts, src/__tests__/telemetry.test.ts, src/__tests__/ipc.test.ts, src/__tests__/cli.test.ts, src/__tests__/bedrock-ergo.test.ts, src/__tests__/nanogpt.test.ts, src/__tests__/global-settings.test.ts, src/__tests__/cloud.test.ts, src/__tests__/kimi-code.test.ts, src/__tests__/provider-identifiers.test.ts, src/__tests__/prompt-cache-ttl.test.ts, src/__tests__/deepseek-v4-pro.test.ts, src/__tests__/provider-default-model.test.ts, src/__tests__/bedrock-custom-arn.test.ts, src/__tests__/cache-write-ttl-pricing.test.ts, src/__tests__/index.test.ts, src/__tests__/telemetry.isTelemetryOptedIn.test.ts
  • extension (cwd src): The mutation run was incomplete; selected test file names were not recorded. See Advisory findings for the failure.
  • webview (cwd .): webview-ui/src/components/ui/hooks/__tests__/useSelectedModel.spec.ts, webview-ui/src/components/settings/providers/__tests__/Bedrock.spec.tsx, webview-ui/src/utils/__tests__/validate.spec.ts

All surviving and uncovered mutants

Warning annotations highlight up to 20 unique locations (maximum 7 per file). This summary lists every advisory mutant.

types

packages/types/src/providers/bedrock.ts

LineStatusMutatorReplacement
29SurvivedOptionalChainingAWS_INFERENCE_PROFILE_MAPPING.find(([pattern]) => region?.startsWith(pattern))[1]
29SurvivedOptionalChainingregion.startsWith
70NoCoverageArrayDeclaration["Stryker was here"]
70SurvivedOptionalChainingparts.slice
70SurvivedStringLiteral""
72SurvivedConditionalExpressiontrue
72SurvivedOptionalChainingresourceId.split
73SurvivedConditionalExpressiontrue

Resolve a mutation gap

Add or strengthen a focused test that fails under the mutation. If the mutant is equivalent, request maintainer approval for the narrowest mutator-specific exclusion and explain why it cannot change behavior:

// Stryker disable next-line ConditionalExpression: normalized input cannot reach the alternate branch
const result = condition ? value : fallback

Broad all exclusions and exclusions without a concrete reason are reported as advisories.

Reproduce locally

From a full checkout containing both commits:

pnpm install --frozen-lockfile
node scripts/stryker-diff.mjs ci --base a2922268ae301ae6a8255748a9adfe6ebdf60828 --head fd7fbf38850851fca8947f602169efdc71aba7d7

Mutation reports

  • types: reports/mutation/types/mutation.html
  • extension: reports/mutation/extension/mutation.html
  • webview: reports/mutation/webview/mutation.html

The workflow uploads generated reports in the changed-code-mutation-report artifact. A direct artifact link appears below after upload.

Advisory findings

  • extension Stryker preflight failed: 04:50:47 (3173) INFO ProjectReader Found 1 of 1454 file(s) to be mutated. 04:50:48 (3173) INFO Instrumenter Instrumented 1 source file(s) with 16 mutant(s) 04:50:48 (3173) INFO ConcurrencyTokenProvider Creating 2 test runner process(es). 04:50:50 (3173) INFO DryRunExecutor Note: running the dry-run only. No mutations will be tested. 04:50:50 (3173) INFO DryRunExecutor Starting initial test run (vitest test runner with "perTest" coverage analysis). This may take a while. 04:54:33 (3173) ERROR DryRunExecutor One or more tests failed in the initial test run: coding eval host command boundary rejects an outside-workspace git diff in clamp-range before command execution Cannot find module '../../../../scripts/agent-evals/coding-fixtures' imported from /home/runner/work/Zoo-Code/Zoo-Code/.stryker-tmp/sandbox-YwIqaJ/core/tools/__tests__/coding-eval-boundary.spec.ts 04:54:33 (3173) ERROR Stryker There were failed tests in the initial test run. file:///home/runner/work/Zoo-Code/Zoo-Code/node_modules/.pnpm/@stryker-mutator+core@10.0.0_@types+node@22.20.5/node_modules/@stryker-mutator/core/dist/src/process/3-dry-run-executor.js:65 throw new ConfigError('There were failed tests in the initial test run.'); ^ ConfigError: There were failed tests in the initial test run. at DryRunExecutor.validateResultCompleted (file:///home/runner/work/Zoo-Code/Zoo-Code/node_modules/.pnpm/@stryker-mutator+core@10.0.0_@types+node@22.20.5/node_modules/@stryker-mutator/core/dist/src/process/3-dry-run-executor.js:65:27) at DryRunExecutor.executeDryRun (file:///home/runner/work/Zoo-Code/Zoo-Code/node_modules/.pnpm/@stryker-mutator+core@10.0.0_@types+node@22.20.5/node_modules/@stryker-mutator/core/dist/src/process/3-dry-run-executor.js:100:14) at process.processTicksAndRejections (node:internal/process/task_queues:103:5) at async WorkItem.execute (file:///home/runner/work/Zoo-Code/Zoo-Code/node_modules/.pnpm/@stryker-mutator+core@10.0.0_@types+node@22.20.5/node_modules/@stryker-mutator/core/dist/src/concurrent/pool.js:32:28) at async file:///home/runner/work/Zoo-Code/Zoo-Code/node_modules/.pnpm/@stryker-mutator+core@10.0.0_@types+node@22.20.5/node_modules/@stryker-mutator/core/dist/src/concurrent/pool.js:69:13 { innerError: undefined } Node.js v22.23.4

@github-actions github-actions Bot added coderabbit-review-active Required CI passed; CodeRabbit review is active awaiting-coderabbit Waiting for CodeRabbit to approve the latest commit labels Dec 4, 2026
@edelauna edelauna changed the title [Fix] Bedrock requests for amazon.ergo-1.0 invoke the wrong model Fix Amazon Ergo 1.0 routing and prices in Bedrock Dec 4, 2026
@github-actions github-actions Bot added coderabbit-review-active Required CI passed; CodeRabbit review is active awaiting-coderabbit Waiting for CodeRabbit to approve the latest commit and removed coderabbit-review-active Required CI passed; CodeRabbit review is active awaiting-coderabbit Waiting for CodeRabbit to approve the latest commit labels Dec 4, 2026
@github-actions github-actions Bot added coderabbit-review-active Required CI passed; CodeRabbit review is active awaiting-coderabbit Waiting for CodeRabbit to approve the latest commit and removed coderabbit-review-active Required CI passed; CodeRabbit review is active awaiting-coderabbit Waiting for CodeRabbit to approve the latest commit labels Dec 4, 2026
@github-actions github-actions Bot removed coderabbit-review-active Required CI passed; CodeRabbit review is active awaiting-coderabbit Waiting for CodeRabbit to approve the latest commit labels Dec 4, 2026
@github-actions github-actions Bot added coderabbit-review-active Required CI passed; CodeRabbit review is active awaiting-coderabbit Waiting for CodeRabbit to approve the latest commit labels Dec 4, 2026
Merged via the queue into main with commit 553936c Dec 4, 2026
20 of 21 checks passed
@edelauna
edelauna deleted the fix/bedrock-ergo-model-registry-365nn5m4b9gvk branch December 4, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-coderabbit Waiting for CodeRabbit to approve the latest commit coderabbit-review-active Required CI passed; CodeRabbit review is active

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Bedrock model: Amazon Ergo 1.0

2 participants