Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
56db41e
feat: report Bedrock InvokeModel model override on chat model providers
dannykopping Oct 14, 2026
e31b28e
feat(site/src/pages/AISettingsPage/ModelsPage): warn when a Bedrock I…
dannykopping Oct 14, 2026
3afd978
docs(docs/ai-coder): document Bedrock InvokeModel model selection
dannykopping Oct 14, 2026
ea6c843
refactor(site/src/pages/AISettingsPage/ModelsPage): simplify Bedrock …
dannykopping Oct 14, 2026
d6b2c6e
refactor(site/src/pages/AISettingsPage/ModelsPage): name Bedrock fixt…
dannykopping Oct 14, 2026
ba52822
chore: add PR screenshots (removed in next commit)
dannykopping Oct 14, 2026
171380c
chore: remove PR screenshots
dannykopping Oct 14, 2026
2f2f390
refactor: report Bedrock InvokeModel providers as a boolean on chat m…
dannykopping Oct 14, 2026
d953de4
refactor(site/src/pages/AISettingsPage/ModelsPage): show one Bedrock …
dannykopping Oct 14, 2026
8b5299d
feat(site/src): warn in the Agents chat input when the selected model…
dannykopping Oct 14, 2026
6bb3302
docs(docs/ai-coder/ai-gateway): mention the Agents chat input warning…
dannykopping Oct 14, 2026
5c84baf
refactor(site/src): share the composer notice row and tidy the Bedroc…
dannykopping Oct 14, 2026
5c7e6e7
refactor(site/src/pages/AgentsPage/components): derive composer notic…
dannykopping Oct 14, 2026
afadeea
chore: add PR screenshots (removed in next commit)
dannykopping Oct 14, 2026
833333b
chore: remove PR screenshots
dannykopping Oct 14, 2026
3cbbe13
docs(docs/ai-coder): explain how Bedrock InvokeModel maps requested m…
dannykopping Oct 14, 2026
594f993
fix(site/src/pages): link Bedrock InvokeModel warnings to the model s…
dannykopping Oct 14, 2026
b26343a
docs(docs/ai-coder/ai-gateway): clarify Bedrock model naming for Invo…
dannykopping Oct 14, 2026
a3966ac
fix(site/src/pages/AgentsPage/components): name the provider explicit…
dannykopping Oct 14, 2026
03e8f40
chore: add PR screenshots (removed in next commit)
dannykopping Oct 14, 2026
8797de6
chore: remove PR screenshots
dannykopping Oct 14, 2026
a20bde0
Merge remote-tracking branch 'origin/main' into bedrock-invokemodel-m…
dannykopping Oct 22, 2026
4c855c9
refactor(coderd): detect Bedrock InvokeModel providers with the gatew…
dannykopping Oct 22, 2026
b3ab7f9
refactor(site/src/pages/AgentsPage/components): build the composer ar…
dannykopping Oct 22, 2026
8a304ae
refactor(site/src): reuse the model selector's provider label in the …
dannykopping Oct 22, 2026
8c6e8a9
test(site/src/pages/AgentsPage/utils): prefix the Bedrock config fixt…
dannykopping Oct 22, 2026
0a8d536
fix(coderd): keep listing Bedrock chat model providers with undecodab…
dannykopping Oct 22, 2026
af60986
fix(site/src/pages/AgentsPage/components): build the composer aria-de…
dannykopping Oct 22, 2026
e789391
fix(coderd): report Bedrock InvokeModel only for Bedrock-type chat mo…
dannykopping Oct 22, 2026
075e220
refactor(site/src): share the Bedrock InvokeModel docs path between t…
dannykopping Oct 22, 2026
01c2be9
test(site/src/pages/AgentsPage/components): cover the composer descri…
dannykopping Oct 22, 2026
06b57d8
fix: install site dependencies before generating API docs
dannykopping Oct 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1489,6 +1489,7 @@ docs/reference/api-key-scopes.md: node_modules/.installed $(wildcard scripts/sco

coderd/apidoc/.gen: \
node_modules/.installed \
site/node_modules/.installed \
scripts/apidocgen/node_modules/.installed \
$(wildcard coderd/*.go) \
$(wildcard enterprise/coderd/*.go) \
Expand Down
4 changes: 4 additions & 0 deletions coderd/apidoc/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions coderd/apidoc/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 17 additions & 3 deletions coderd/exp_chats.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import (

"cdr.dev/slog/v3"
"github.com/coder/coder/v2/agent/agentssh"
aibridgeconfig "github.com/coder/coder/v2/aibridge/config"
agplaibridge "github.com/coder/coder/v2/coderd/aibridge"
"github.com/coder/coder/v2/coderd/audit"
"github.com/coder/coder/v2/coderd/cryptokeys"
"github.com/coder/coder/v2/coderd/database"
Expand Down Expand Up @@ -8402,13 +8404,15 @@ func (api *API) chatModelProviderDescriptors(
}
}
hasUserKey := userKeyStatus[provider.ID]
settings, settingsErr := db2sdk.AIProviderSettings(provider.Settings)
// Some provider configurations support ambient credentials rather than a
// stored key. Actual credential availability is checked by the gateway.
// Bedrock always supports them, so its settings are only needed for the

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P4 [CRF-12] The added comment calls BedrockInvokeModel "the InvokeModel hint", which is a second name for the field. (Gon)

Replace the two added lines with: // Bedrock always supports them, so undecodable Bedrock settings only leave BedrockInvokeModel false.

🤖

// InvokeModel hint, which corrupt settings leave false.
supportsAmbientCredentials := provider.Type == database.AIProviderTypeBedrock
if !supportsAmbientCredentials {
settings, err := db2sdk.AIProviderSettings(provider.Settings)
if err != nil {
return nil, xerrors.Errorf("decode AI provider settings: %w", err)
if settingsErr != nil {
return nil, xerrors.Errorf("decode AI provider settings: %w", settingsErr)
}
supportsAmbientCredentials = aiProviderSupportsAmbientCredentials(settings)
}
Expand All @@ -8422,11 +8426,21 @@ func (api *API) chatModelProviderDescriptors(
HasUserAPIKey: hasUserKey,
HasEffectiveAPIKey: hasKey || hasUserKey || supportsAmbientCredentials,
AllowUserAPIKey: api.DeploymentValues.AI.BridgeConfig.AllowBYOK.Value(),
BedrockInvokeModel: provider.Type == database.AIProviderTypeBedrock &&
bedrockUsesInvokeModel(settings.Bedrock),
})
}
return out, nil
}

// bedrockUsesInvokeModel reports whether the gateway serves the provider over

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P3 [CRF-13] The bedrockUsesInvokeModel doc says it reports whether the gateway serves the provider over InvokeModel, but it returns true for type=anthropic settings, which the gateway does not serve over Bedrock. (Gon)

The provider.Type check at line 8429 is what prevents the wrong result, and the doc does not say a caller needs it. The clause about sending configured models upstream repeats codersdk/chats.go:2824-2826. Replace it with: // bedrockUsesInvokeModel reports whether the gateway resolves these settings to the Bedrock InvokeModel protocol. It does not check the provider type.

🤖

// the Bedrock InvokeModel protocol, which sends the provider's configured
// models upstream in place of the requested model.
func bedrockUsesInvokeModel(settings *codersdk.AIProviderBedrockSettings) bool {
cfg := agplaibridge.BedrockConfig("", settings)
return cfg != nil && cfg.ResolvedProtocol() == aibridgeconfig.BedrockProtocolInvokeModel
}

// aiProviderSupportsAmbientCredentials reports whether the provider's settings
// support ambient credentials. It does not verify that credentials are available.
func aiProviderSupportsAmbientCredentials(settings codersdk.AIProviderSettings) bool {
Expand Down
70 changes: 70 additions & 0 deletions coderd/exp_chats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4294,6 +4294,76 @@ func TestListChatModelConfigs(t *testing.T) {
}
t.Fatal("bedrock provider descriptor not found")
})

t.Run("BedrockDescriptorReportsInvokeModelOverride", func(t *testing.T) {
t.Parallel()

ctx := testutil.Context(t, testutil.WaitLong)
client, db := newChatClientWithDatabase(t)
firstUser := coderdtest.CreateFirstUser(t, client.Client)

newBedrockProvider := func(providerType database.AIProviderType, protocol codersdk.AIProviderBedrockProtocol) database.AIProvider {
settings, err := json.Marshal(codersdk.AIProviderSettings{
Bedrock: &codersdk.AIProviderBedrockSettings{
Region: "us-east-1",
Model: "us.anthropic.claude-sonnet-5",
SmallFastModel: "us.anthropic.claude-haiku-5-5",
Protocol: protocol,
},
})
require.NoError(t, err)
return dbgen.AIProvider(t, db, database.AIProvider{
Type: providerType,
Settings: sql.NullString{String: string(settings), Valid: true},
})
}
defaultProtocol := newBedrockProvider(database.AIProviderTypeBedrock, "")
invokeModel := newBedrockProvider(database.AIProviderTypeBedrock, codersdk.AIProviderBedrockProtocolInvokeModel)
mantle := newBedrockProvider(database.AIProviderTypeBedrock, codersdk.AIProviderBedrockProtocolMantle)
// Anthropic rows can carry Bedrock settings until the backfill promotes
// them, but the gateway serves them as plain Anthropic providers.
anthropic := newBedrockProvider(database.AIProviderTypeAnthropic, codersdk.AIProviderBedrockProtocolInvokeModel)

response, err := client.ChatModels(ctx, firstUser.OrganizationID)
require.NoError(t, err)
invokeModelByProvider := make(map[uuid.UUID]bool)
for _, descriptor := range response.Providers {
invokeModelByProvider[descriptor.ID] = descriptor.BedrockInvokeModel
}

require.True(t, invokeModelByProvider[defaultProtocol.ID])
require.True(t, invokeModelByProvider[invokeModel.ID])
require.Contains(t, invokeModelByProvider, mantle.ID)
require.False(t, invokeModelByProvider[mantle.ID])
require.Contains(t, invokeModelByProvider, anthropic.ID)
require.False(t, invokeModelByProvider[anthropic.ID])
})

t.Run("BedrockDescriptorToleratesCorruptSettings", func(t *testing.T) {
t.Parallel()

ctx := testutil.Context(t, testutil.WaitLong)
client, db := newChatClientWithDatabase(t)
firstUser := coderdtest.CreateFirstUser(t, client.Client)

// Bedrock providers always support ambient credentials, so listing
// them must not depend on decoding their settings.
provider := dbgen.AIProvider(t, db, database.AIProvider{
Type: database.AIProviderTypeBedrock,
Settings: sql.NullString{String: `{"bedrock":`, Valid: true},
})

response, err := client.ChatModels(ctx, firstUser.OrganizationID)
require.NoError(t, err)
for _, descriptor := range response.Providers {
if descriptor.ID == provider.ID {
require.True(t, descriptor.HasEffectiveAPIKey)
require.False(t, descriptor.BedrockInvokeModel)
return
}
}
t.Fatal("bedrock provider descriptor not found")
})
}

func TestGetChatModel(t *testing.T) {
Expand Down
4 changes: 4 additions & 0 deletions codersdk/chats.go
Original file line number Diff line number Diff line change
Expand Up @@ -2821,6 +2821,10 @@ type ChatModelProviderDescriptor struct {
AllowUserAPIKey bool `json:"allow_user_api_key"`
Available bool `json:"available"`
UnavailableReason ChatModelProviderUnavailableReason `json:"unavailable_reason,omitempty"`
// BedrockInvokeModel reports whether the provider uses the AWS Bedrock
// InvokeModel protocol. That protocol ignores the model a client requests
// and sends the provider's configured models upstream instead.
BedrockInvokeModel bool `json:"bedrock_invoke_model,omitempty"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P3 [CRF-10] BedrockInvokeModel is a boolean with a noun name, so option.bedrockInvokeModel next to model and displayName reads as a model ID. (Gon)

The same name is used for the JSON field, ProviderInfo.bedrockInvokeModel, and ModelSelectorOption.bedrockInvokeModel, and AgentChatInput derives bedrockInvokeModelOption from it. The Go helper in this PR already uses a predicate name, bedrockUsesInvokeModel. Rename to UsesBedrockInvokeModel / uses_bedrock_invoke_model / usesBedrockInvokeModel before release; after release the JSON rename is an API break.

🤖

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit [CRF-11] BedrockInvokeModel uses omitempty, unlike the other booleans in ChatModelProviderDescriptor. (Ryosuke)

Enabled, HasAPIKey, HasEffectiveAPIKey, AllowUserAPIKey, and Available are always emitted, so their generated TypeScript fields are required; omitempty makes bedrock_invoke_model optional in typesGenerated.ts and in the types derived from it. Drop omitempty.

🤖

}

// OrganizationChatModelsResponse is the org chat model config collection:
Expand Down
1 change: 1 addition & 0 deletions docs/ai-coder/agents/models.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ A provider is deployment-wide, whilst the models that reference it are organizat
After saving a provider, add an Agents model for it from **Admin settings** > **AI** > **Models**.
Select the organization that should own the new model before you add it.
For provider-specific setup, including AWS Bedrock, refer to [AI Gateway provider configuration](../ai-gateway/providers.md#provider-types).
AWS Bedrock providers that use the InvokeModel protocol replace the model identifier with the model configured on the provider; refer to [How InvokeModel selects the model](../ai-gateway/providers.md#how-invokemodel-selects-the-model).

## Endpoint/base URL for OpenAI-compatible providers

Expand Down
40 changes: 40 additions & 0 deletions docs/ai-coder/ai-gateway/providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ Configure:
- An **endpoint** in the format the protocol requires: `https://bedrock-runtime.<region>.amazonaws.com` for InvokeModel or `https://bedrock-mantle.<region>.api.aws/anthropic` for Mantle.
The AWS region is read from the endpoint host.
- The **model** and **small fast model** identifiers, for InvokeModel only.
Use Bedrock identifiers, not Anthropic API model names.
Refer to [How InvokeModel selects the model](#how-invokemodel-selects-the-model).
Mantle providers do not set them; the client chooses the model on each request and AI Gateway forwards it upstream.

#### InvokeModel
Expand All @@ -132,11 +134,49 @@ The legacy Bedrock runtime API.
AI Gateway translates each request into Bedrock's InvokeModel format and sends it to `https://bedrock-runtime.<region>.amazonaws.com`.
Still supported, but Mantle is recommended for new deployments.

##### How InvokeModel selects the model

Clients and Bedrock name models differently.
Anthropic clients, including Claude Code and Coder Agents, request models by their Anthropic API names, such as `claude-sonnet-4-5`.
Bedrock does not accept those names.
It identifies a model by one of the following:

- A Bedrock model ID, such as `anthropic.claude-sonnet-4-5-20250929-v1:0`.
- A cross-Region inference profile ID, which adds a geographic prefix to the model ID, such as `global.anthropic.claude-sonnet-4-5-20250929-v1:0`.
- An [application inference profile](#application-inference-profiles) ARN.

AI Gateway does not translate Anthropic names into Bedrock identifiers.
Instead, an InvokeModel provider ignores the model that the client requests and sends one of the two Bedrock identifiers configured on the provider:

| Requested model identifier | Bedrock identifier sent to AWS |
|----------------------------------------------|-------------------------------------|
| Contains `haiku`, such as `claude-haiku-4-5` | The provider's **small fast model** |
| Anything else, such as `claude-opus-4-5` | The provider's **model** |

An InvokeModel provider therefore serves at most two Bedrock models, and the requested model only chooses between them.
AI Gateway records each request, its token usage, and its cost against the Bedrock model that ran, not the requested model.
For an application inference profile, that is the model behind the profile.
To offer another Bedrock model, add another InvokeModel provider configured with that model, or use a [Mantle](#mantle) provider.

The same applies to Coder Agents models.
The model identifier of an Agents model that uses an InvokeModel provider is not sent to AWS; it only selects the configured **model** or **small fast model**.
For example, an Agents model with the identifier `claude-opus-4-5` on a provider whose **model** is `global.anthropic.claude-sonnet-4-5-20250929-v1:0` runs Claude Sonnet 4.5.
The dashboard warns about this when you add or edit such a model, and the Agents chat input warns when such a model is selected.

The model identifier you give an Agents model on an InvokeModel provider does not change which Bedrock model runs, beyond the `haiku` rule above.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit [CRF-15] Line 166 repeats line 162: both say the Agents model identifier only chooses between the configured model and small fast model. (Leorio)

Delete line 166 and start line 167 with "To avoid confusion, match the Agents model identifier to the configured model that it selects, ...".

🤖

To avoid confusion, match it to the configured model that it selects, such as `claude-sonnet-4-5` for a configured **model** of `global.anthropic.claude-sonnet-4-5-20250929-v1:0`.
Keep the `claude-` prefix: Coder Agents uses it to send requests in the Anthropic Messages format.

#### Mantle

The newer Anthropic-compatible Bedrock endpoint, recommended by AWS for new deployments.
AI Gateway serves Anthropic models through the native Messages API, forwarding the request body **unchanged** and only applying AWS SigV4 signing with the provider's base identity.

Because the model is forwarded as requested, clients and Coder Agents models on a Mantle provider must use Mantle model IDs, such as `anthropic.claude-sonnet-5`, rather than Anthropic API names.
Use the bare model ID, without a cross-Region inference profile prefix such as `us.` or `global.`.
To list the IDs that Mantle serves in a Region, call its `/v1/models` endpoint.
Refer to [Get list of models](https://docs.aws.amazon.com/bedrock/latest/userguide/models-get-info.html) in the AWS documentation.

To route Claude Code through a Mantle provider, run it in mantle mode with client-side signing disabled so the gateway signs centrally:

```sh
Expand Down
1 change: 1 addition & 0 deletions docs/reference/api/chats.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading