Skip to content

feat(bedrock): add inference profile discovery and region injection - #61299

Merged
vincentkoc merged 2 commits into
openclaw:mainfrom
wirjo:feat/bedrock-inference-profiles
Apr 5, 2026
Merged

vincentkoc merged 2 commits into
openclaw:mainfrom
wirjo:feat/bedrock-inference-profiles

Conversation

@wirjo

@wirjo wirjo commented Apr 5, 2026

Copy link
Copy Markdown
Contributor

Inference profiles (cross-region and application) work with ConverseStream but require the SDK client region to match the profile region. Without this, users get "The provided model identifier is invalid" errors when using cross-region profiles like us.anthropic.claude-sonnet-4-6.

Changes:

  1. Inference profile discovery (discovery.ts):

    • Call ListInferenceProfiles alongside ListFoundationModels (parallel)
    • Inference profiles INHERIT capabilities from their underlying foundation model (modalities, reasoning, context window, cost)
    • resolveBaseModelId() maps profile → foundation model: "us.anthropic.claude-sonnet-4-6" → "anthropic.claude-sonnet-4-6" Application ARNs → extract model ID from models[].modelArn
    • Graceful degradation if IAM lacks bedrock:ListInferenceProfiles
    • Provider filter applies to profiles via underlying model ARNs
  2. Region injection (register.sync.runtime.ts):

    • Extract region from provider baseUrl or bedrockDiscovery.region
    • Pass through to pi-ai options.region in wrapStreamFn
    • Ensures SDK client connects to correct regional endpoint
  3. Inference profile model detection (anthropic-family-cache-semantics.ts):

    • isAnthropicBedrockModel() now recognizes application inference profile ARNs (arn:aws:bedrock:...:application-inference-profile/*)
  4. Tests (discovery.test.ts):

    • New: inference profile inheritance test (4 models: 1 foundation + 3 profiles, verifies capability inheritance, inactive filtering)
    • New: graceful AccessDeniedException handling test
    • Updated: all existing tests for dual-API discovery pattern

Fixes #55642

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: M labels Apr 5, 2026
@greptile-apps

greptile-apps Bot commented Apr 5, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds inference profile discovery (cross-region and application) to the Amazon Bedrock provider and injects the resolved AWS region into stream calls so the SDK client connects to the correct regional endpoint.

  • P1: In resolveInferenceProfiles, the provider-filter ARN parser indexes segment [0] (before the /), yielding \"foundation-model\" instead of the model's actual provider. When any providerFilter is configured, all inference profiles are silently filtered out. The fix is to index [1] instead.

Confidence Score: 4/5

Safe to merge after fixing the provider filter ARN parsing bug; all other logic is sound.

The P1 bug in the inference profile provider filter causes all inference profiles to be dropped when providerFilter is configured, directly breaking the primary use-case for users with filtered Bedrock deployments. All other changes (region injection, capability inheritance, graceful degradation, cache handling) are correct.

extensions/amazon-bedrock/discovery.ts line 246 — the ARN split index must change from [0] to [1].

Prompt To Fix All With AI
This is a comment left during a code review.
Path: extensions/amazon-bedrock/discovery.ts
Line: 245-247

Comment:
**Provider filter always evaluates `"foundation-model"` for inference profiles**

The ARN is split at `"/"` and index `[0]` is taken — the prefix segment `"arn:aws:bedrock:us-east-1::foundation-model"`. Calling `.split(":").pop()` on that prefix yields `"foundation-model"`, not the actual provider. This means `matchesFilter` is always `false` when a `providerFilter` like `["anthropic"]` is set, so **every inference profile is silently dropped**.

The fix is to index into segment `[1]` (the part after the `/`), which contains `"anthropic.claude-sonnet-4-6"`, and split on `.` to extract the provider:

```suggestion
        const provider = m.modelArn?.split("/")?.[1]?.split(".")?.[0];
```

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: src/agents/pi-embedded-runner/anthropic-family-cache-semantics.ts
Line: 24-29

Comment:
**Application inference profile Claude detection is name-heuristic only**

`isAnthropicBedrockModel` returns `true` for any application inference profile whose user-supplied name contains `"claude"`, and `false` for any profile whose name does not — even if it routes to a Claude model. A profile named `"my-prod-assistant"` over Claude would bypass prompt-caching semantics, while a non-Claude profile named `"my-claude-compat-llama"` would incorrectly get them. Consider documenting this limitation in a code comment so future maintainers know the constraint is intentional.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "feat(bedrock): add inference profile dis..." | Re-trigger Greptile

Comment thread extensions/amazon-bedrock/discovery.ts Resolved
@wirjo
wirjo force-pushed the feat/bedrock-inference-profiles branch 2 times, most recently from 7e124b2 to b4a996b Compare April 5, 2026 11:02

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5357525cbe

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread extensions/amazon-bedrock/discovery.ts Resolved
@wirjo
wirjo force-pushed the feat/bedrock-inference-profiles branch from b4a996b to e5f7710 Compare April 5, 2026 11:03

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e5f7710d35

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread extensions/amazon-bedrock/discovery.ts Resolved
wirjo and others added 2 commits April 5, 2026 12:47
Inference profiles (cross-region and application) work with ConverseStream
but require the SDK client region to match the profile region. Without
this, users get "The provided model identifier is invalid" errors when
using cross-region profiles like us.anthropic.claude-sonnet-4-6.

Changes:

1. Inference profile discovery (discovery.ts):
   - Call ListInferenceProfiles alongside ListFoundationModels (parallel)
   - Inference profiles INHERIT capabilities from their underlying
     foundation model (modalities, reasoning, context window, cost)
   - resolveBaseModelId() maps profile → foundation model:
     "us.anthropic.claude-sonnet-4-6" → "anthropic.claude-sonnet-4-6"
     Application ARNs → extract model ID from models[].modelArn
   - Graceful degradation if IAM lacks bedrock:ListInferenceProfiles
   - Provider filter applies to profiles via underlying model ARNs

2. Region injection (register.sync.runtime.ts):
   - Extract region from provider baseUrl or bedrockDiscovery.region
   - Pass through to pi-ai options.region in wrapStreamFn
   - Ensures SDK client connects to correct regional endpoint

3. Inference profile model detection (anthropic-family-cache-semantics.ts):
   - isAnthropicBedrockModel() now recognizes application inference
     profile ARNs (arn:aws:bedrock:...:application-inference-profile/*)

4. Tests (discovery.test.ts):
   - New: inference profile inheritance test (4 models: 1 foundation +
     3 profiles, verifies capability inheritance, inactive filtering)
   - New: graceful AccessDeniedException handling test
   - Updated: all existing tests for dual-API discovery pattern

Fixes openclaw#55642
@vincentkoc
vincentkoc force-pushed the feat/bedrock-inference-profiles branch from e5f7710 to e1b0db1 Compare April 5, 2026 11:51
@vincentkoc vincentkoc self-assigned this Apr 5, 2026
@vincentkoc
vincentkoc merged commit 78fe96f into openclaw:main Apr 5, 2026
9 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e1b0db140b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +108 to +111
const exact = (providers[providerId] as { baseUrl?: string } | undefined)?.baseUrl;
if (exact) {
const region = extractRegionFromBaseUrl(exact);
if (region) return region;

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.

P1 Badge Use active provider config when resolving Bedrock region

The region injector ignores the provider key from wrapStreamFn context and always reads models.providers["amazon-bedrock"] first. In configs that keep both legacy and canonical keys (for example bedrock and amazon-bedrock) with different baseUrl regions, calls made through the alias can be forced to the wrong region and fail with Bedrock "invalid model identifier" errors for inference profiles. Resolve region from the currently selected provider key first, then fall back to normalized aliases.

Useful? React with 👍 / 👎.

Comment on lines +211 to +216
} catch (error) {
log.debug?.("Skipping inference profile discovery", {
error: error instanceof Error ? error.message : String(error),
});
return [];
}

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.

P2 Badge Re-throw non-permission inference-profile discovery errors

fetchInferenceProfileSummaries swallows all exceptions and returns an empty list, but the caller treats that as a successful discovery and caches it for the full refresh interval. A transient Bedrock/API failure (throttling, network, endpoint issues) will therefore silently remove all inference profiles from discovery for up to an hour instead of surfacing an error. This should only suppress expected authorization failures (as the comment describes) and re-throw other error classes.

Useful? React with 👍 / 👎.

Lianjinfeng123 pushed a commit to Lianjinfeng123/openclaw that referenced this pull request Apr 6, 2026
…penclaw#61299)

* feat(bedrock): add inference profile discovery and region injection

Inference profiles (cross-region and application) work with ConverseStream
but require the SDK client region to match the profile region. Without
this, users get "The provided model identifier is invalid" errors when
using cross-region profiles like us.anthropic.claude-sonnet-4-6.

Changes:

1. Inference profile discovery (discovery.ts):
   - Call ListInferenceProfiles alongside ListFoundationModels (parallel)
   - Inference profiles INHERIT capabilities from their underlying
     foundation model (modalities, reasoning, context window, cost)
   - resolveBaseModelId() maps profile → foundation model:
     "us.anthropic.claude-sonnet-4-6" → "anthropic.claude-sonnet-4-6"
     Application ARNs → extract model ID from models[].modelArn
   - Graceful degradation if IAM lacks bedrock:ListInferenceProfiles
   - Provider filter applies to profiles via underlying model ARNs

2. Region injection (register.sync.runtime.ts):
   - Extract region from provider baseUrl or bedrockDiscovery.region
   - Pass through to pi-ai options.region in wrapStreamFn
   - Ensures SDK client connects to correct regional endpoint

3. Inference profile model detection (anthropic-family-cache-semantics.ts):
   - isAnthropicBedrockModel() now recognizes application inference
     profile ARNs (arn:aws:bedrock:...:application-inference-profile/*)

4. Tests (discovery.test.ts):
   - New: inference profile inheritance test (4 models: 1 foundation +
     3 profiles, verifies capability inheritance, inactive filtering)
   - New: graceful AccessDeniedException handling test
   - Updated: all existing tests for dual-API discovery pattern

Fixes openclaw#55642

* fix(bedrock): preserve inference profile model lookup

---------

Co-authored-by: Vincent Koc <[email protected]>
@zxkane

zxkane commented Apr 9, 2026

Copy link
Copy Markdown

Prompt caching broken for application inference profiles with random IDs

Hi @wirjo — thanks for landing this PR! It fixed the region injection and basic inference profile support, but we've found that prompt caching is still completely disabled for application inference profiles with random IDs (e.g., 7g9cumu1wd7v).

Root Cause

isAnthropicBedrockModel() checks profileId.includes("claude") — which fails for application inference profiles since their IDs are random strings, not model names. This causes two failures:

  1. wrapStreamFn path: baseWrapStreamFn wraps the stream with createBedrockNoCacheWrapper (forcing cacheRetention: "none"), so no cachePoint is ever injected into ConverseStream requests.

  2. resolveCacheRetention path: isAnthropicFamilyCacheTtlEligible and resolveAnthropicCacheRetentionFamily also call isAnthropicBedrockModel without context, returning undefined — silently discarding any explicit cacheRetention config.

The net result: 0% cache hit rate, even though Bedrock Converse API fully supports prompt caching for Sonnet 4.6 via application inference profiles. We verified this with Bedrock invocation logs — CacheReadInputTokenCount and CacheWriteInputTokenCount are always 0.

Impact

For our deployment (~2,800 invocations/day across 4 stacks), this means ~$150-300/day in avoidable input token costs. With caching enabled we measured 99% cache hit rate and ~50% cost reduction.

Fix PR

We've submitted #63606 which:

  • Adds optional modelName parameter to isAnthropicBedrockModel()
  • Resolves model name from the already-available provider config (zero API calls, zero latency impact)
  • Plumbs modelName through isAnthropicFamilyCacheTtlEligible and resolveAnthropicCacheRetentionFamily
  • 14 new tests (unit + integration)

The approach uses the model display name from config.models.providers["amazon-bedrock"].models[].name which typically contains "Claude Sonnet 4.6" etc., addressing the limitation noted in the source comments without requiring a GetInferenceProfile API call.

Workaround (current)

For anyone hitting this before the fix lands:

  1. Set AWS_BEDROCK_FORCE_CACHE=1 env var — tells pi-ai's supportsPromptCaching() to inject cachePoint
  2. Patch isAnthropicBedrockModel to return true for all app inference profile ARNs (we use a deploy-time patch script)

lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
…penclaw#61299)

* feat(bedrock): add inference profile discovery and region injection

Inference profiles (cross-region and application) work with ConverseStream
but require the SDK client region to match the profile region. Without
this, users get "The provided model identifier is invalid" errors when
using cross-region profiles like us.anthropic.claude-sonnet-4-6.

Changes:

1. Inference profile discovery (discovery.ts):
   - Call ListInferenceProfiles alongside ListFoundationModels (parallel)
   - Inference profiles INHERIT capabilities from their underlying
     foundation model (modalities, reasoning, context window, cost)
   - resolveBaseModelId() maps profile → foundation model:
     "us.anthropic.claude-sonnet-4-6" → "anthropic.claude-sonnet-4-6"
     Application ARNs → extract model ID from models[].modelArn
   - Graceful degradation if IAM lacks bedrock:ListInferenceProfiles
   - Provider filter applies to profiles via underlying model ARNs

2. Region injection (register.sync.runtime.ts):
   - Extract region from provider baseUrl or bedrockDiscovery.region
   - Pass through to pi-ai options.region in wrapStreamFn
   - Ensures SDK client connects to correct regional endpoint

3. Inference profile model detection (anthropic-family-cache-semantics.ts):
   - isAnthropicBedrockModel() now recognizes application inference
     profile ARNs (arn:aws:bedrock:...:application-inference-profile/*)

4. Tests (discovery.test.ts):
   - New: inference profile inheritance test (4 models: 1 foundation +
     3 profiles, verifies capability inheritance, inactive filtering)
   - New: graceful AccessDeniedException handling test
   - Updated: all existing tests for dual-API discovery pattern

Fixes openclaw#55642

* fix(bedrock): preserve inference profile model lookup

---------

Co-authored-by: Vincent Koc <[email protected]>
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
…penclaw#61299)

* feat(bedrock): add inference profile discovery and region injection

Inference profiles (cross-region and application) work with ConverseStream
but require the SDK client region to match the profile region. Without
this, users get "The provided model identifier is invalid" errors when
using cross-region profiles like us.anthropic.claude-sonnet-4-6.

Changes:

1. Inference profile discovery (discovery.ts):
   - Call ListInferenceProfiles alongside ListFoundationModels (parallel)
   - Inference profiles INHERIT capabilities from their underlying
     foundation model (modalities, reasoning, context window, cost)
   - resolveBaseModelId() maps profile → foundation model:
     "us.anthropic.claude-sonnet-4-6" → "anthropic.claude-sonnet-4-6"
     Application ARNs → extract model ID from models[].modelArn
   - Graceful degradation if IAM lacks bedrock:ListInferenceProfiles
   - Provider filter applies to profiles via underlying model ARNs

2. Region injection (register.sync.runtime.ts):
   - Extract region from provider baseUrl or bedrockDiscovery.region
   - Pass through to pi-ai options.region in wrapStreamFn
   - Ensures SDK client connects to correct regional endpoint

3. Inference profile model detection (anthropic-family-cache-semantics.ts):
   - isAnthropicBedrockModel() now recognizes application inference
     profile ARNs (arn:aws:bedrock:...:application-inference-profile/*)

4. Tests (discovery.test.ts):
   - New: inference profile inheritance test (4 models: 1 foundation +
     3 profiles, verifies capability inheritance, inactive filtering)
   - New: graceful AccessDeniedException handling test
   - Updated: all existing tests for dual-API discovery pattern

Fixes openclaw#55642

* fix(bedrock): preserve inference profile model lookup

---------

Co-authored-by: Vincent Koc <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
…penclaw#61299)

* feat(bedrock): add inference profile discovery and region injection

Inference profiles (cross-region and application) work with ConverseStream
but require the SDK client region to match the profile region. Without
this, users get "The provided model identifier is invalid" errors when
using cross-region profiles like us.anthropic.claude-sonnet-4-6.

Changes:

1. Inference profile discovery (discovery.ts):
   - Call ListInferenceProfiles alongside ListFoundationModels (parallel)
   - Inference profiles INHERIT capabilities from their underlying
     foundation model (modalities, reasoning, context window, cost)
   - resolveBaseModelId() maps profile → foundation model:
     "us.anthropic.claude-sonnet-4-6" → "anthropic.claude-sonnet-4-6"
     Application ARNs → extract model ID from models[].modelArn
   - Graceful degradation if IAM lacks bedrock:ListInferenceProfiles
   - Provider filter applies to profiles via underlying model ARNs

2. Region injection (register.sync.runtime.ts):
   - Extract region from provider baseUrl or bedrockDiscovery.region
   - Pass through to pi-ai options.region in wrapStreamFn
   - Ensures SDK client connects to correct regional endpoint

3. Inference profile model detection (anthropic-family-cache-semantics.ts):
   - isAnthropicBedrockModel() now recognizes application inference
     profile ARNs (arn:aws:bedrock:...:application-inference-profile/*)

4. Tests (discovery.test.ts):
   - New: inference profile inheritance test (4 models: 1 foundation +
     3 profiles, verifies capability inheritance, inactive filtering)
   - New: graceful AccessDeniedException handling test
   - Updated: all existing tests for dual-API discovery pattern

Fixes openclaw#55642

* fix(bedrock): preserve inference profile model lookup

---------

Co-authored-by: Vincent Koc <[email protected]>
Nachx639 pushed a commit to Nachx639/clawdbot that referenced this pull request Jun 17, 2026
…penclaw#61299)

* feat(bedrock): add inference profile discovery and region injection

Inference profiles (cross-region and application) work with ConverseStream
but require the SDK client region to match the profile region. Without
this, users get "The provided model identifier is invalid" errors when
using cross-region profiles like us.anthropic.claude-sonnet-4-6.

Changes:

1. Inference profile discovery (discovery.ts):
   - Call ListInferenceProfiles alongside ListFoundationModels (parallel)
   - Inference profiles INHERIT capabilities from their underlying
     foundation model (modalities, reasoning, context window, cost)
   - resolveBaseModelId() maps profile → foundation model:
     "us.anthropic.claude-sonnet-4-6" → "anthropic.claude-sonnet-4-6"
     Application ARNs → extract model ID from models[].modelArn
   - Graceful degradation if IAM lacks bedrock:ListInferenceProfiles
   - Provider filter applies to profiles via underlying model ARNs

2. Region injection (register.sync.runtime.ts):
   - Extract region from provider baseUrl or bedrockDiscovery.region
   - Pass through to pi-ai options.region in wrapStreamFn
   - Ensures SDK client connects to correct regional endpoint

3. Inference profile model detection (anthropic-family-cache-semantics.ts):
   - isAnthropicBedrockModel() now recognizes application inference
     profile ARNs (arn:aws:bedrock:...:application-inference-profile/*)

4. Tests (discovery.test.ts):
   - New: inference profile inheritance test (4 models: 1 foundation +
     3 profiles, verifies capability inheritance, inactive filtering)
   - New: graceful AccessDeniedException handling test
   - Updated: all existing tests for dual-API discovery pattern

Fixes openclaw#55642

* fix(bedrock): preserve inference profile model lookup

---------

Co-authored-by: Vincent Koc <[email protected]>
vixco pushed a commit to vixco/openclaw that referenced this pull request Aug 16, 2026
…penclaw#61299)

* feat(bedrock): add inference profile discovery and region injection

Inference profiles (cross-region and application) work with ConverseStream
but require the SDK client region to match the profile region. Without
this, users get "The provided model identifier is invalid" errors when
using cross-region profiles like us.anthropic.claude-sonnet-4-6.

Changes:

1. Inference profile discovery (discovery.ts):
   - Call ListInferenceProfiles alongside ListFoundationModels (parallel)
   - Inference profiles INHERIT capabilities from their underlying
     foundation model (modalities, reasoning, context window, cost)
   - resolveBaseModelId() maps profile → foundation model:
     "us.anthropic.claude-sonnet-4-6" → "anthropic.claude-sonnet-4-6"
     Application ARNs → extract model ID from models[].modelArn
   - Graceful degradation if IAM lacks bedrock:ListInferenceProfiles
   - Provider filter applies to profiles via underlying model ARNs

2. Region injection (register.sync.runtime.ts):
   - Extract region from provider baseUrl or bedrockDiscovery.region
   - Pass through to pi-ai options.region in wrapStreamFn
   - Ensures SDK client connects to correct regional endpoint

3. Inference profile model detection (anthropic-family-cache-semantics.ts):
   - isAnthropicBedrockModel() now recognizes application inference
     profile ARNs (arn:aws:bedrock:...:application-inference-profile/*)

4. Tests (discovery.test.ts):
   - New: inference profile inheritance test (4 models: 1 foundation +
     3 profiles, verifies capability inheritance, inactive filtering)
   - New: graceful AccessDeniedException handling test
   - Updated: all existing tests for dual-API discovery pattern

Fixes openclaw#55642

* fix(bedrock): preserve inference profile model lookup

---------

Co-authored-by: Vincent Koc <[email protected]>
globalcaos pushed a commit to globalcaos/tinkerclaw that referenced this pull request Sep 29, 2026
…penclaw#61299)

* feat(bedrock): add inference profile discovery and region injection

Inference profiles (cross-region and application) work with ConverseStream
but require the SDK client region to match the profile region. Without
this, users get "The provided model identifier is invalid" errors when
using cross-region profiles like us.anthropic.claude-sonnet-4-6.

Changes:

1. Inference profile discovery (discovery.ts):
   - Call ListInferenceProfiles alongside ListFoundationModels (parallel)
   - Inference profiles INHERIT capabilities from their underlying
     foundation model (modalities, reasoning, context window, cost)
   - resolveBaseModelId() maps profile → foundation model:
     "us.anthropic.claude-sonnet-4-6" → "anthropic.claude-sonnet-4-6"
     Application ARNs → extract model ID from models[].modelArn
   - Graceful degradation if IAM lacks bedrock:ListInferenceProfiles
   - Provider filter applies to profiles via underlying model ARNs

2. Region injection (register.sync.runtime.ts):
   - Extract region from provider baseUrl or bedrockDiscovery.region
   - Pass through to pi-ai options.region in wrapStreamFn
   - Ensures SDK client connects to correct regional endpoint

3. Inference profile model detection (anthropic-family-cache-semantics.ts):
   - isAnthropicBedrockModel() now recognizes application inference
     profile ARNs (arn:aws:bedrock:...:application-inference-profile/*)

4. Tests (discovery.test.ts):
   - New: inference profile inheritance test (4 models: 1 foundation +
     3 profiles, verifies capability inheritance, inactive filtering)
   - New: graceful AccessDeniedException handling test
   - Updated: all existing tests for dual-API discovery pattern

Fixes openclaw#55642

* fix(bedrock): preserve inference profile model lookup

---------

Co-authored-by: Vincent Koc <[email protected]>
lhfer pushed a commit to lhfer/openclaw that referenced this pull request Oct 11, 2026
…penclaw#61299)

* feat(bedrock): add inference profile discovery and region injection

Inference profiles (cross-region and application) work with ConverseStream
but require the SDK client region to match the profile region. Without
this, users get "The provided model identifier is invalid" errors when
using cross-region profiles like us.anthropic.claude-sonnet-4-6.

Changes:

1. Inference profile discovery (discovery.ts):
   - Call ListInferenceProfiles alongside ListFoundationModels (parallel)
   - Inference profiles INHERIT capabilities from their underlying
     foundation model (modalities, reasoning, context window, cost)
   - resolveBaseModelId() maps profile → foundation model:
     "us.anthropic.claude-sonnet-4-6" → "anthropic.claude-sonnet-4-6"
     Application ARNs → extract model ID from models[].modelArn
   - Graceful degradation if IAM lacks bedrock:ListInferenceProfiles
   - Provider filter applies to profiles via underlying model ARNs

2. Region injection (register.sync.runtime.ts):
   - Extract region from provider baseUrl or bedrockDiscovery.region
   - Pass through to pi-ai options.region in wrapStreamFn
   - Ensures SDK client connects to correct regional endpoint

3. Inference profile model detection (anthropic-family-cache-semantics.ts):
   - isAnthropicBedrockModel() now recognizes application inference
     profile ARNs (arn:aws:bedrock:...:application-inference-profile/*)

4. Tests (discovery.test.ts):
   - New: inference profile inheritance test (4 models: 1 foundation +
     3 profiles, verifies capability inheritance, inactive filtering)
   - New: graceful AccessDeniedException handling test
   - Updated: all existing tests for dual-API discovery pattern

Fixes openclaw#55642

* fix(bedrock): preserve inference profile model lookup

---------

Co-authored-by: Vincent Koc <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: bedrock-converse-stream incompatible with AWS inference profiles (jp./us./ap. prefixes)

3 participants