Skip to content

fix(bedrock): list inference-profile-only chat models in ListModels - #20481

Closed
errmakov wants to merge 1 commit into
infiniflow:mainfrom
errmakov:fix/bedrock-inference-profile-models
Closed

errmakov wants to merge 1 commit into
infiniflow:mainfrom
errmakov:fix/bedrock-inference-profile-models

Conversation

@errmakov

Copy link
Copy Markdown
Contributor

Summary

Closes #20162.

When you list Bedrock models, the Go driver drops every model that does not support ON_DEMAND (internal/entity/models/bedrock.go). Bedrock serves Claude and the OpenAI GPT-6 models only through cross-region inference profiles, so they never appear. In API-key mode the add-model form shows this list in place of a model-name field, which leaves these models reachable only through "+ custom model". Invoking the bare id fails anyway: Invocation of model ID openai.gpt-6-sol with on-demand throughput isn't supported.

#20163 fixed this in rag/llm/model_meta.py, which has since been removed from main (#20289). The Go driver is now the only path, and it still has the filter. This PR applies the approach from the issue to the Go driver.

Change

  • When the catalog contains a chat model without ON_DEMAND, ListModels also reads GET /inference-profiles?typeEquals=SYSTEM_DEFINED, following nextToken. It maps each active profile back to its foundation model through models[].modelArn, then lists that model under its profile ids (us.anthropic.claude-…, global.openai.gpt-6-sol).
  • Models that support ON_DEMAND are listed exactly as before. A catalog that has no profile-only chat model sends no extra request, so CheckConnection still makes a single call.
  • Embedding models are still listed only when they support on-demand. Embed chooses the request body from the bare amazon. / cohere. prefix, so a profile id such as us.cohere.embed-v4:0 would be rejected.
  • If the credential lacks bedrock:ListInferenceProfiles, the driver logs a warning and returns the on-demand list as before.
  • The control-plane GET moved into a small helper so both calls share signing, the endpoint override and error handling.

Test plan

  • New TestBedrockListModelsListsInferenceProfileOnlyModels: profile-only chat models are listed under their active profile ids across two pages. An inactive profile and a profile-only embedding model are left out. Fails on main (len(got)=1 want 4), passes with this change.
  • New TestBedrockListModelsKeepsOnDemandModelsWhenProfilesUnavailable: a 403 on /inference-profiles still returns the on-demand list.
  • bash build.sh --test ./internal/entity/models/ passes, including the existing TestBedrockListModelsParsesCatalog and TestBedrockCheckConnectionDelegates.
  • Live check against Bedrock (us-east-1 / us-west-2 / eu-west-1) with an API key

Bedrock serves Claude and OpenAI GPT-6 only through cross-region inference
profiles, so filtering the catalog to ON_DEMAND hid them from model discovery.
List those chat models under their active system-defined profile ids; keep
embedding models on-demand only, and fall back to the on-demand list when the
credential cannot list inference profiles.

Closes infiniflow#20162
@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 1ef1d46a-161b-4f15-bc12-5ae142cf776a

📥 Commits

Reviewing files that changed from the base of the PR and between 9766c8c and a4710ac.

📒 Files selected for processing (2)
  • internal/entity/models/bedrock.go
  • internal/entity/models/bedrock_test.go

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

Bedrock model discovery now includes eligible profile-only chat models by listing active system-defined inference profiles. On-demand models and supported embeddings remain listed by foundation-model ID. If profile lookup fails, profile-only models are omitted and eligible on-demand models remain available.

Changes

Bedrock model discovery

Layer / File(s) Summary
Catalog classification and control-plane requests
internal/entity/models/bedrock.go
Model summary helpers classify catalog entries by eligibility and on-demand support. A shared control-plane GET helper handles authorization, responses, and non-200 errors.
Profile lookup and model listing
internal/entity/models/bedrock.go, internal/entity/models/bedrock_test.go
ListModels retrieves active system-defined inference profiles in pages and uses profile IDs for eligible profile-only chat models. Tests cover pagination, excluded entries, and profile lookup failure. On-demand models remain available when lookup fails.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant ListModels
  participant controlPlaneGET
  participant BedrockControlPlane
  ListModels->>controlPlaneGET: Get foundation-model catalog
  controlPlaneGET->>BedrockControlPlane: GET foundation-models
  BedrockControlPlane-->>ListModels: Catalog response
  ListModels->>controlPlaneGET: Get profiles when profile-only chat models exist
  controlPlaneGET->>BedrockControlPlane: GET inference-profiles with pagination
  BedrockControlPlane-->>ListModels: Active profile summaries
  ListModels-->>ListModels: Return eligible model and profile IDs
Loading

Suggested reviewers: jinhai-cn

Merge Risk: ⚪ Minimal · up to a4710

The change adds inference-profile-only chat models while retaining existing on-demand listings when profile lookup fails. No concrete merge-blocking issue is established; live regional checks remain outstanding.

Security Architecture Review

Security architecture risk: 🔵 Low · up to a4710

Discovery now offers cross-region inference options while retaining request authentication and permission-failure behavior. No authorization bypass was established, but deployment-specific access and data-residency policies remain unverified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The expansion concerns discoverable model identifiers and potentially their AWS-managed destination regions. Listing does not grant invocation permission or create credentials: subsequent chat requests still use the supplied configuration and Bedrock authorization. Effective account, tenant, and geographic exposure depends on policies not supplied here.

Trust Boundaries and Controls

  • observed — The shared control-plane helper authorizes requests before transmission. API-key authorization requires HTTPS and the exact regional AWS endpoint; credential-based requests use SigV4. Runtime requests retain the same authorization function, and profile IDs occupy the model path rather than selecting a new host.

Resilience and Maintainability Implications

  • observed — A denied profile-listing request produces a warning and an on-demand-only result. It does not substitute bare profile-only model IDs or retry without authorization. This contains discovery failure without weakening invocation controls.

Hardening Proposals

  • proposed — Where processing-location restrictions apply, constrain inference-profile use through explicit invocation and geographic policies. Do not treat catalog visibility or the configured endpoint region as proof of invocation entitlement or data residency.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: listing inference-profile-only Bedrock chat models in ListModels.
Description check ✅ Passed The description includes the required Summary section and provides clear background, implementation details, fallback behavior, and test coverage. The unchecked live Bedrock validation is identified b…
Linked Issues check ✅ Passed The change satisfies the coding requirements in [#20162]. ListModels retains eligible on-demand catalog models and their model types. It detects chat models without ON_DEMAND, requests `SYSTEM_DEF…
Out of Scope Changes check ✅ Passed The changes stay within [#20162]. The shared GET helper supports the two required Bedrock control-plane calls and preserves signing, endpoint, timeout, and error handling. The added tests verify the r…
  • Fix all pre-merge checks with AI

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

A rabbit checks the model list,
Profile IDs appear in view.
Pages turn, active names are found,
On-demand models stay around.
The rabbit hops beneath the moon.

Comment @coderabbitai help to get the list of available commands.

@kimnamu kimnamu left a comment

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.

Thanks for porting this to the Go driver, and for carrying over the embedding exclusion and the 403 fallback as well.

I ran the one unchecked item in your test plan, a live check with a Bedrock API key in us-east-1, us-west-2 and eu-west-1, against a4710ac. It behaves as described, and I don't have any changes to suggest.

ListModels, Bedrock API key us-east-1 us-west-2 eu-west-1
Models listed, main → this PR 51 → 116 51 → 118 33 → 80
Claude ids, main → this PR 0 → 28 0 → 28 0 → 26
GPT-6 Sol/Luna/Astra us. and global. us. and global. global. only
Entries from main still listed with the same types ✅ 51/51 ✅ 51/51 ✅ 33/33
Embedding models ✅ unchanged ✅ unchanged (cohere.embed-v4:0 is INFERENCE_PROFILE only here and stays out) ✅ unchanged
$ go test -run 'TestBedrockListModels|TestBedrockCheckConnection' ./internal/entity/models/
bedrock.go from main:  --- FAIL: TestBedrockListModelsListsInferenceProfileOnlyModels
                       bedrock_test.go:607: len(got)=1 want 4
this PR:               4 passed

ChatWithMessages with ids from the new list (API key):
us-east-1  us.anthropic.claude-haiku-4-5-20251001-v1:0    -> "pong"
us-east-1  global.anthropic.claude-opus-5-5               -> "pong"
eu-west-1  eu.anthropic.claude-sonnet-4-5-20250929-v1:0   -> "pong"
us-east-1  us.openai.gpt-6-sol                            -> "pong"
eu-west-1  global.openai.gpt-6-luna                       -> "pong"
us-east-1  anthropic.claude-haiku-4-5-20251001-v1:0 (bare id, for contrast)
           -> status 400: Invocation of model ID anthropic.claude-haiku-4-5-20251001-v1:0 with on-demand throughput isn’t supported.
Other checks
  • SigV4 (assume_role through a local profile) returns the same three lists as the API key, so the signed typeEquals=SYSTEM_DEFINED&maxResults=1000 query is accepted.
  • go test ./internal/entity/models/: 912 passed, 1 skipped. I left out two tokenizer tests that need the cl100k table, which my machine doesn't have; they fail the same way without this PR. go vet and gofmt -l are clean.
  • Unchanged from main and outside this PR: an empty inferenceTypesSupported still counts as on-demand, so meta.llama3-3-70b-instruct-v1:0:128k (us-west-2, []) stays listed, and Converse answers it with 404 Model not found.

@yuzhichang

Copy link
Copy Markdown
Member

Duplicated with #20163

@yuzhichang yuzhichang closed this Oct 9, 2026
@kimnamu

kimnamu commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

@yuzhichang thanks for going through the Bedrock threads. I think this one is a different fix from #20163, though. #20163 went into 0.27.x and only touched the Python rag/llm/model_meta.py, which no longer exists on main. This PR changes the Go driver, and on main (30a6808) ListModels still skips every model whose inferenceTypesSupported is set but lacks ON_DEMAND (internal/entity/models/bedrock.go:954). Claude and GPT-6 are only offered through inference profiles, so with an API key the model list on main still shows none of them. My live run of this branch is in the review above (us-east-1: 51 to 116 models, 0 to 28 Claude ids).

Would you be open to reopening this PR and #20162? They were closed together, so nothing on main tracks the gap right now. If the Go side is already covered somewhere else, a pointer is enough and I'll leave it there. cc @JinHai-CN, since you asked me to look at this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Bedrock "List models" with API key auth shows no Claude and no GPT-6 (inference-profile-only models are filtered out)

4 participants