Skip to content

feat(box): Let a Box gateway call only the Bedrock model of its runtime - #2911

Merged
mquang-amazon merged 3 commits into
box-integrationfrom
box/bedrock-policy-per-model
Nov 25, 2026
Merged

mquang-amazon merged 3 commits into
box-integrationfrom
box/bedrock-policy-per-model

Conversation

@mquang-amazon

@mquang-amazon mquang-amazon commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Description

The role of a Box gateway could invoke every inference profile and every foundation model of the account. agentcore/box-bedrock-policy.json named inference-profile/* and foundation-model/*, and the Runtime profile's Bedrock route allows the whole bedrock-runtime.<region>.amazonaws.com host, so a boxed agent could call any model, the most expensive ones too.

This PR lets a Box gateway call only the model of its runtime, from the runtime's existing modelId in agentcore.json.

What changes

  • create records the model. For a Box template that calls a Bedrock model, create writes the model ID its code renders (the template default, or the scaffold input's modelId) into the runtime's modelId, as it already does for LiteLLM:

    "modelProvider": "Bedrock",
    "modelId": "global.anthropic.claude-sonnet-5-5"

    agent-python-minimal-box calls no model as created and gets none, and neither does a runtime that add runtime adds (its code is the user's). Both count as unscoped (see below).

  • Build scopes the policy. When every boxed runtime that calls Bedrock has a modelId, box-bedrock-policy.json allows only those models:

    { "Sid": "BoxedAgentInferenceProfileThroughGateway", "Effect": "Allow",
      "Action": ["bedrock:InvokeModel", "bedrock:InvokeModelWithResponseStream"],
      "Resource": ["arn:aws:bedrock:us-west-2:*:inference-profile/global.anthropic.claude-sonnet-5-5"],
      "Condition": { "StringEquals": { "aws:ResourceAccount": "${aws:PrincipalAccount}" } } },
    { "Sid": "BoxedAgentModelThroughItsInferenceProfile", "Effect": "Allow",
      "Action": ["bedrock:InvokeModel", "bedrock:InvokeModelWithResponseStream"],
      "Resource": ["arn:aws:bedrock:*::foundation-model/anthropic.claude-sonnet-5-5*"],
      "Condition": { "StringEquals": { "bedrock:InferenceProfileArn": "arn:aws:bedrock:us-west-2:${aws:PrincipalAccount}:inference-profile/global.anthropic.claude-sonnet-5-5" } } }

    plus the in-region statement on foundation-model/<id>. A call through an inference profile is authorized twice: on the profile, and on the foundation model in the region the profile sends it to, so the model statement names any region but holds only through that profile. Every plain ID gets all three statements, with no list of geographic prefixes: for a model ID (amazon.nova-pro-v1:0) the profile statements name a profile that cannot exist, and for a profile ID the in-region statement a model that cannot exist. A system inference profile ARN or a foundation model ARN gets the statements of its kind, in the ARN's region. LiteLLM's bedrock/, bedrock/converse/ and bedrock/invoke/ routes use the ID after them. Several runtimes give one statement set per model, each with its own Sid.

  • No modelId build can scope to: no change, and a warning. A boxed runtime that calls Bedrock (one with no modelProvider counts) with no modelId, or with one build cannot scope to (an application inference profile, provisioned, custom or imported model ARN, or an ID that is not provider.model), keeps the whole project on the every-model policy, and build warns, naming each such runtime:

    runtime "agent" has no modelId in agentcore.json that build can scope to (a Bedrock model ID or inference profile ID, or the ARN of a foundation model or system inference profile), so the Box gateways of this project can call every Bedrock model of the account. Set "modelId" to the model its code calls, then build again.

  • The LangChain template renders modelId. agent-python-langchain hardcoded MODEL_ID = "global.anthropic.claude-sonnet-5-5" and ignored --model-id. Its model/load.py now renders {{safeJson modelId}}, as the other templates do, so the code and agentcore.json name the same model.

  • The modelId schema comment, docs/box-local-testing.md, and the box README of the strands and LangChain templates say that the Box gateway calls only the model in modelId, so the code and modelId change together.

Decisions

  • The existing modelId field, not a new one. It already records the model the scaffold rendered; this PR also writes it for box runtimes that call Bedrock.
  • One policy file for the project. All Box gateways attach box-bedrock-policy.json, so it holds the models of all boxed runtimes. When one of them has no modelId, the file keeps every model. A file per runtime is a follow-up.
  • Changing the model. A user who changes the model in the code also changes modelId; otherwise the gateway denies the call (Bedrock AccessDenied). The schema comment says so.

Related Issue

Closes #

Strands Box bug bash, IAM finding F3 (security doc §2.4).

Documentation PR

Included: docs/box-local-testing.md and the template READMEs.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Other (please describe): Security fix: least privilege for the Box gateway's role.

Testing

How have you tested the change?

  • I ran bun test: 6410 pass, 3 fail. The 3 (the box on PATH > ... in boxProfileResolver.test.ts and projectGateways.test.ts) also fail on box-integration without this change; they run only with a box that has --format json --full on PATH.
  • I ran the relevant end-to-end tests with bun run test:e2e, or explained why they are not applicable: not run. A live test in a test account (us-west-2) took its place: create --template agent-python-strands-box wrote "modelId": "global.anthropic.claude-sonnet-5-5", deploy attached the two-statement policy above to the Box gateway's role, and invoke answered through the Box gateway ("17 plus 25 is 42."), so Bedrock accepts the scoped policy for a global inference profile.
  • I ran bun run typecheck
  • I ran bun run lint:check
  • I ran bun run format:check
  • I ran bun run audit
  • I ran bun run secrets:check
  • I ran bun run build
  • If I modified src/assets/, I updated affected snapshots with bun test <test-file> --update-snapshots and committed them: no snapshot has the LangChain model/load.py.
  • If I re-recorded fixtures or golden files, every change beyond account identifiers is explained by this PR: none re-recorded.
  • This PR does not change command.md (the release workflow regenerates it)

New tests:

  • boxMemory.test.ts: an inference profile gives the profile and its model only through it; a model ID gives that model in the region; several runtimes give one statement set per model with distinct Sids, and LiteLLM's bedrock/ model is used; a runtime with a model provider and no modelId keeps every model and gets the warning; a runtime with no model provider gets no warning.
  • manager.box.test.ts: create records modelId for agent-python-strands-box, agent-python-langchain-box and agent-python-strands-box-container, none for agent-python-minimal-box and the non-box agent-python-strands; the LangChain model/load.py names the same model.
  • manager.boxNetwork.test.ts: the Bedrock policy of a created project names only its model.

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings (build gives one new warning, by design, for a runtime with no modelId)
  • Any dependent changes have been merged and published

The Box gateway's role could invoke every inference profile and every foundation model of the
account: agentcore/box-bedrock-policy.json named `inference-profile/*` and `foundation-model/*`.

- create records the model a box runtime's code calls in the runtime's existing `modelId` (the
  --model-id, or the template default), as it already does for LiteLLM. The minimal template calls
  no model and gets none. The LangChain template now renders `modelId` into model/load.py, as the
  other templates do, so the code and agentcore.json name the same model.
- When every boxed runtime that calls Bedrock has a modelId, build writes a policy for those models
  only: an inference profile of the account in the region, and its foundation model only through
  that profile; or a foundation model ID in the region.
- When a runtime has no modelId (a project created before this change), build keeps the every-model
  policy and warns, naming the runtime and the field to set.
@mquang-amazon
mquang-amazon marked this pull request as ready for review November 24, 2026 22:56
@mquang-amazon
mquang-amazon requested a review from a team November 24, 2026 22:56
@codecov-commenter

codecov-commenter commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.87%. Comparing base (5393054) to head (b04d487).
⚠️ Report is 59 commits behind head on box-integration.

Additional details and impacted files
@@                Coverage Diff                @@
##           box-integration    #2911    +/-   ##
=================================================
  Coverage            96.87%   96.87%            
=================================================
  Files                  774      774            
  Lines                68744    68848   +104     
=================================================
+ Hits                 66593    66697   +104     
  Misses                2151     2151            

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@leo237 leo237 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks, scoping the Box gateway role to the runtime's own model is the right fix, and the inference-profile pair (the profile, plus the foundation model in any region only through that profile ARN) is the correct IAM shape. It covers global. too, since * in the region segment matches the empty region of a global-profile foundation-model ARN, and the live test agrees. I'm requesting changes because of one blocker, a regression where legitimate calls get denied.

Blocker: an ARN or a LiteLLM route prefix in modelId writes a policy that matches nothing. modelBehindProfile splits on . and treats anything without a known prefix as a bare foundation-model ID. I ran boxBedrockPolicy (us-west-2) on a few inputs:

modelId Resource written
arn:aws:bedrock:us-west-2:123456789012:inference-profile/us.anthropic.claude-sonnet-5-5 arn:aws:bedrock:us-west-2::foundation-model/arn:aws:bedrock:...:inference-profile/us.anthropic...
arn:aws:bedrock:us-west-2::foundation-model/amazon.nova-pro-v1:0 ...::foundation-model/arn:aws:bedrock:us-west-2::foundation-model/amazon.nova-pro-v1:0
LiteLLM bedrock/converse/us.anthropic.claude-sonnet-5-5 ...::foundation-model/converse/us.anthropic.claude-sonnet-5-5

None of these come with a build warning. Strands' BedrockModel, Converse and LiteLLM all accept these forms, and --model-id / the schema only require min(1). The old policy allowed the first two (inference-profile/*, foundation-model/*), so this PR turns working agents into a Bedrock AccessDenied at invoke time. Application-inference-profile and provisioned-model ARNs were already denied before, but they now fail the same silent way. Suggested fix, inline below: normalize ARNs (inference-profile/X and foundation-model/X reduce to X; for an ARN that names another region, use that region). Strip LiteLLM's converse/ / invoke/ route. For anything you can't classify (application-inference-profile, provisioned-model, custom/imported model, or an ID that doesn't look like provider.model), keep the every-model policy and warn, the same way as for a missing modelId.

Should fix: a model-free box runtime silently turns scoping off for the whole project. callsBedrock treats an undefined modelProvider as Bedrock, so the minimal-box runtime, or an add runtime box runtime whose code is the user's, counts as calling Bedrock with no model ID. Then modelIds.every(...) fails and every gateway gets every model. boxBedrockScopeWarning skips exactly those runtimes (modelProvider !== undefined), so there is no warning. Probe: minimal-box + strands-box (global.anthropic.claude-sonnet-5-5) gives the three wildcard statements and warning: undefined. The two functions should agree. If a runtime with no provider "calls no model as created", leave it out of the scoping decision too. If it might call Bedrock, warn.

Non-blocking: a single box-bedrock-policy.json for all Box gateways means each gateway can call every boxed runtime's model. The PR calls a file per runtime a follow-up. I didn't find it in the squash plan, so please file it so it doesn't get lost.

Test coverage / mutation results (boxMemory, manager.box, manager.boxNetwork, manager tests):

  • Caught, good: loosening the profile resource to inference-profile/*, always returning the every-model policy, dropping the bedrock:InferenceProfileArn condition, widening the foundation-model resource to *:*, a no-op recordBoxModelId in createProjectTree, foundation-model/${model}* changed to foundation-model/*, and suppressing the warning.
  • Survived: (1) removing recordBoxModelId from addBoxRuntime in manager.tsx (the add-runtime path has no test), (2) removing the bedrock/ strip in bedrockModelIdOf (the multi-runtime test checks only Sids), (3) hard-coding the old MODEL_ID back into the LangChain load.py (the test uses the default model, which equals the old hard-coded value, so it can't tell the difference; use a non-default --model-id).
  • Missing cases: a user-set --model-id through create, the a2a-python-strands-box / agui-python-strands-box templates, an ARN modelId, a project that mixes a model-free runtime with a model runtime, and a modelId changed between two builds (the file is rewritten from the spec, so stale grants should go, but nothing asserts it).

Checked and fine: the #2893 api-key route (box strips AWS_BEARER_TOKEN_BEDROCK and the gateway signs with its own role, so the role policy is what enforces this). Converse/ConverseStream are authorized as InvokeModel/InvokeModelWithResponseStream. The policy's region is the build region, which is also the bedrock target's endpoint region. Partitions work for aws-cn / aws-us-gov. The LangChain load.py now renders the same ID that create records. All box templates' load.py render {{safeJson modelId}}. There's no schema change, and existing projects keep the old policy and get the warning, so no migration is needed. The default model's e2e is unchanged.

Local: bun run typecheck passes. bun test: 6410 pass, 9 skip, 0 fail. CI: Analyze, CodeQL, and verify on Linux/Windows/macOS pass. e2e was skipped.

Comment thread src/core/project/boxMemory.ts Resolved
Comment thread src/core/project/boxMemory.ts Resolved
Comment thread src/core/project/boxMemory.ts Resolved
Comment thread src/core/project/boxMemory.ts Resolved
Comment thread src/core/project/manager.tsx Resolved
Comment thread src/core/project/manager.box.test.ts Resolved

@tejaskash tejaskash 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.

Changes requested. The scoped policy itself is right for global, geographic and plain model IDs: in the IAM policy simulator, modelId: global.anthropic.claude-sonnet-5-5 in us-west-2 allows the profile in the role's account and the model in us-west-2, eu-west-1 and the empty region through that profile, and denies another profile, another account, another model, and the model called directly. A plain amazon.nova-pro-v1:0 is allowed in the region only. The problems are the cases that fall back or produce a policy that can never match.

  1. A boxed runtime with no modelProvider brings back the every-model policy, and build says nothing (src/core/project/boxMemory.ts:137-138 and :166). The fallback at :166 triggers when any boxed runtime that callsBedrock has no modelId, and callsBedrockModel treats a missing modelProvider as Bedrock. The warning at :138 filters on modelProvider !== undefined, so the two disagree. With the real CLI: create --template agent-python-strands-box then build writes the scoped policy, but adding a second agent with add runtime --name helper --language python and building again writes inference-profile/* and foundation-model/* for both gateways, with no message. agent-python-minimal-box gets the wide policy too, though the description says it gets none. Make the warning condition the same as the fallback condition and update the test at boxMemory.test.ts:223.
  2. The in. inference profile prefix is missing (boxMemory.ts:80). ap-south-1 has 7 system profiles with the prefix in (for example in.anthropic.claude-sonnet-5). An unknown prefix is treated as a plain model ID, so build writes foundation-model/in.anthropic.claude-sonnet-5, which does not exist, and every call is denied with no warning. The same will happen for the next prefix AWS adds. Suggest dropping the list: for every ID that is not an ARN, write the profile statement, the in-region model statement, and the through-profile model statement for the ID minus its first segment. For a plain model ID the profile statements can never match, so nothing widens.
  3. A modelId that is an ARN produces a policy that can never match (boxMemory.ts:102-109). An inference profile ARN becomes foundation-model/arn:aws:bedrock:...:inference-profile/..., and the same for an application inference profile or a foundation model ARN. When the ID starts with arn:, use it as the resource (with the through-profile model statement for a system profile, and foundation-model/* under bedrock:InferenceProfileArn for an application profile), or refuse an ARN for a box runtime at build with a message.
  4. The AccessDenied after changing the model in code is explained only in a source comment (src/projectSchemas/runtime.ts:372). Add one sentence to docs/box-local-testing.md and the box template README: the Box gateway may call only the model in modelId of agentcore.json, so change both together and deploy again.

Smaller:

  • manager.tsx:2293: the recordBoxModelId call in addBoxRuntime is always a no-op (that path never sets modelProvider). Delete it and drop the export.
  • Tests: removing the warning from the writer (boxNetworkWriters.ts:398) or hardcoding the LangChain model again (agent-python-langchain/model/load.py:4) fails nothing. Assert the build warning in manager.boxNetwork.test.ts, use a non-default model for the LangChain row, and add a2a-python-strands-box and agui-python-strands-box to the create table.
  • The description mentions --model-id, which create does not have, so the recorded value is always the template default.
  • boxMemory.ts:72: LiteLLM also accepts bedrock/converse/<model> and bedrock/invoke/<model>, which become foundation-model/converse/.... Strip those too.
  • boxMemory.ts:143: with two runtimes the warning reads runtime "agent0", "agent1" has no modelId. Word it for a list.

- A modelId that build cannot scope to falls back, with a warning, instead of writing a policy that
  matches nothing: build reads a model ID or system inference profile ID (provider.model), a
  foundation model ARN or a system inference profile ARN (in the ARN's region), and LiteLLM's
  bedrock/, bedrock/converse/ and bedrock/invoke/ routes. An application inference profile,
  provisioned, custom or imported model ARN, or an ID that is not provider.model, keeps the
  every-model policy and the warning.
- No list of geographic prefixes: every plain ID gets the profile statement, the model statement
  through that profile, and the in-region model statement. A model ID's profile statements and a
  profile ID's model statement name resources that cannot exist, so nothing widens, and in. or a
  future prefix needs no change.
- The warning and the fallback agree: a boxed runtime with no modelProvider (minimal-box, or an
  added runtime) counts as calling Bedrock in both, so the project keeps every model and build
  says which runtime to give a modelId. The warning names several runtimes in one sentence.
- The no-op recordBoxModelId call in add runtime is removed.
- docs/box-local-testing.md and the strands and LangChain READMEs of a box runtime say that the
  Box gateway calls only the model in modelId, so the code and modelId change together.
- The comment on foundation-model/<model>* says why it ends in *.
- Tests: an in. profile, a plain model ID, a profile ARN in another region, a foundation model ARN,
  each LiteLLM route (asserting the resource), the three kinds that fall back, a mixed project, the
  plural warning; create with a non-default model for strands-box and langchain-box (the code and
  modelId match), a2a-python-strands-box and agui-python-strands-box; build rewrites the policy
  to a changed modelId and warns when it is missing.
@mquang-amazon

Copy link
Copy Markdown
Contributor Author

Thanks @leo237 and @tejaskash, all addressed in 5e070e4 (inline replies on Leo's threads).

@tejaskash:

  1. Warning and fallback disagree. Both now use the same set of runtimes. A runtime with no modelProvider (minimal-box, or one from add runtime) counts as calling Bedrock in both, so the project keeps every model and build names that runtime. The description no longer says minimal-box gets none; it gets the every-model policy and the warning until it has a modelId.
  2. in. and future prefixes. The prefix list is gone. Every plain ID gets the profile statement, the model statement through that profile (the ID minus its first segment) and the in-region model statement. For a model ID the profile statements name a profile that cannot exist, and for a profile ID the in-region statement a model that cannot exist, so nothing widens. Test with in.anthropic.claude-sonnet-5.
  3. ARNs. A system inference profile ARN gives the profile and the model through it, in the ARN's region; a foundation model ARN gives that model in its region. An application inference profile, provisioned, custom or imported model ARN falls back with the warning.
  4. Docs. docs/box-local-testing.md and the box README of the strands and LangChain templates say that the Box gateway calls only the model in modelId, so the code and modelId change together and deploy again.

Smaller: the no-op recordBoxModelId call in addBoxRuntime and its export are removed; LiteLLM's bedrock/converse/ and bedrock/invoke/ are stripped; the warning names several runtimes in one sentence (runtimes "a", "b" and "c" have ...). You are right that create has no --model-id; the recorded value is the template default (or the scaffold input's modelId), and the description is updated.

Tests added: each ID and ARN form, the three kinds that fall back, each LiteLLM route (asserting Resource), a mixed project, the plural warning; create with a non-default model for strands-box and langchain-box (the code and modelId match), plus a2a and agui; build asserts the warning, and a changed modelId rewrites the policy with no grant of the old model left.

@leo237: the policy-file-per-runtime follow-up is noted; I'll file it.

bun test: 6425 pass, 3 fail (the box on PATH > ..., which also fail on box-integration; they run only with a box that has --format json --full on PATH). Typecheck, lint, format and build pass. Live in a test account (us-west-2): create --template agent-python-strands-box records global.anthropic.claude-sonnet-5-5, deploy writes the scoped policy, and invoke answers through the Box gateway; the Box template e2e and the Runtime egress test pass (LangChain fails on the known OpenTelemetry Failed to detach context log line, which the non-box LangChain template has too). Switching models, a mismatched model, an ARN modelId and add runtime are still running live; I'll post the results.

@leo237 leo237 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Approving. 5e070e4 fixes the blocker and the should-fix, and I found no new blocker. The policy is scoped in every case I probed, or it falls back to the every-model policy with a warning. No probe produced a resource that matches nothing, and no wildcard defeats the scoping.

Probes (boxBedrockPolicy / boxBedrockScopeWarning, us-west-2):

modelId / project Result
arn:...:us-east-1:<acct>:inference-profile/us.anthropic.claude-sonnet-5-5 The profile in us-east-1 for the role's account, plus foundation-model/anthropic.claude-sonnet-5-5* only through that profile. No warning.
arn:...:eu-west-1::foundation-model/amazon.nova-pro-v1:0 That model in eu-west-1 only.
application-inference-profile ARN, provisioned-model ARN The every-model policy, plus the warning.
arn:...::foundation-model/*, arn:aws:bedrock:*::..., anthropic.* The every-model policy, plus the warning. * never reaches a scoped resource.
LiteLLM bedrock/converse/<id>, bedrock/invoke/<id> Scoped to <id>.
minimal-box + strands-box; strands-box + a user-code add runtime box runtime The every-model policy, plus a warning naming the model-free runtime.

Dropping the prefix list holds up. For a plain model ID, the profile statements name a profile that cannot exist. For a profile ID, the in-region statement names a model that cannot exist. Neither one widens anything.

Mutations (boxMemory, manager.box, manager.boxNetwork and runtime tests): The three that survived last time are now caught. The bedrock/ strip removal fails 4 tests, and the hard-coded LangChain MODEL_ID fails 1. The addBoxRuntime call was removed as a no-op, which is correct. Also caught:

  • removing the converse//invoke/ strip
  • ignoring the ARN's region or kind
  • dropping MODEL_ID_PATTERN for plain IDs
  • restoring the old warning filter
  • dropping either statement group for plain IDs
  • removing the strands README {{#if box}} gate

Follow-ups (non-blocking):

  1. Removing if (!MODEL_ID_PATTERN.test(rest!)) return undefined; for ARNs passes every test. This check is the only thing that stops arn:aws:bedrock:us-west-2::foundation-model/* from writing foundation-model/* as a "scoped" policy with no warning. Please add a wildcard-ARN case to the fallback test.each.
  2. Two more mutations survive.
    • Removing the dedupe in boxBedrockPolicy survives, because the multi-runtime test counts the ...1 and ...2 Sids but not the total.
    • Removing the LangChain README paragraph survives, because no test renders the langchain-box README.
  3. The a2a-python-strands-box and agui-python-strands-box READMEs don't get the "change load.py and modelId together" paragraph. Their resolvers don't pass box.
  4. The ARN's partition is ignored. An arn:aws-cn:... modelId in an aws build writes arn:aws:bedrock:cn-north-1::..., which never matches, and build gives no warning. It's an edge case. Falling back when the partition differs from the build's would close it.
  5. A minimal-box-only project now warns on every build with "Set modelId to the model its code calls", but its code calls no model. That's acceptable given the agreed behavior. It may be worth a hint that a runtime calling no model can ignore the warning.
  6. The per-runtime policy file follow-up, as noted.

Local: bun run typecheck passes. bun test: 6425 pass, 9 skip, 0 fail.

CI: verify on Linux and Windows, Analyze and CodeQL pass. e2e was skipped. verify / macOS failed on project add config-bundle wizard > the example stays on screen while the user types over it, a 5 s timeout in a TUI test this PR doesn't touch. It passes locally, and the test before it took 5.6 s, so it looks flaky. A re-run should clear it.

@mquang-amazon

Copy link
Copy Markdown
Contributor Author

Live results for 5e070e4 (test account, us-west-2, with the L3 box-integration constructs):

Check Result
create --template agent-python-strands-box, deploy, invoke modelId: global.anthropic.claude-sonnet-5-5; the policy names that profile, its model through it, and the in-region model; invoke answers
Code and modelId both changed to us.amazon.nova-pro-v1:0, deploy, invoke the policy names only Nova (no Claude grant left); invoke answers
Code back to Claude, modelId still Nova invoke denied: AccessDeniedException ... ConverseStream for the Box gateway's role, so the scoping holds
modelId as the system inference profile ARN the profile in the ARN's region and its model through it; invoke answers
add runtime beside it build warns that the new runtime has no modelId, the policy falls back to every model, and the first runtime still answers
e2e: Box templates (minimal, strands, A2A, AG-UI, container) and the Runtime egress test pass; LangChain fails on the known OpenTelemetry Failed to detach context log line
e2e: non-box agent_python_strands and agent_python_langchain pass

The added runtime itself did not start on the Runtime, for a reason outside this PR: in a Box project with a Memory, its Runtime profile reads inputs.memory.agentMemory.id, which deploy no longer sets for a runtime other than the Memory's own (box: "inputs.memory.agentMemory.id has no value"). I'll follow up on that separately.

…ck policy

- An ARN of another partition than the build's falls back to the every-model policy with the
  warning: it names a model the gateway's role can never call.
- The warning says that a runtime whose code calls no model needs no modelId.
- The A2A and AG-UI box READMEs get the paragraph that ties the model to modelId, as the strands and
  LangChain ones do.
- Tests: a foundation model ARN with a wildcard, a wildcard model ID and an ARN of another partition
  fall back; the multi-runtime policy has the deduplicated statement count; create renders the
  modelId paragraph in the README of strands-box, langchain-box, a2a-strands-box and
  agui-strands-box. Removing the ARN ID check, the dedupe, or the LangChain README paragraph now
  fails a test.

@leo237 leo237 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Re-approving at b04d487. The follow-up commit closes the follow-ups from my last review, and I found no new blocker.

My follow-ups from 5e070e4:

  1. Wildcard-ARN test: done. Removing the MODEL_ID_PATTERN check for ARNs now fails a test.
  2. Dedupe and LangChain README mutations: both caught now. The multi-runtime test counts 6 statements, and the new README test renders the langchain-box README.
  3. a2a and agui READMEs: done. Both resolvers pass box. I rendered the a2a README both ways: the paragraph appears only with box, and the ## Memory spacing is right either way.
  4. Partition: done. An arn:aws-cn: model ID in an aws build now falls back to the every-model policy and warns.
  5. Model-free hint: added to the warning.
  6. Per-runtime policy file: still a follow-up. Please make sure it's filed.

All my inline threads were already resolved.

tejaskash's review (b1c4fe4), as I read it:

  • 1 (model-free runtime fallback and warning disagree), 2 (in. prefix), 3 (ARN modelId): addressed in 5e070e4.
  • 4 (docs sentence): addressed. It's in docs/box-local-testing.md and in all four box template READMEs.
  • Smaller items: the no-op recordBoxModelId was removed. The tests he asked for were added: writer warning, non-default LangChain model, a2a/agui in the table. LiteLLM converse//invoke/ routes are stripped. The warning is worded for a list.
  • One item is open: the description still says the LangChain template "ignored --model-id". That's for him to confirm.

Mutations (boxMemory, manager.box, manager.boxNetwork, manager and templates tests; 642 pass at baseline). Caught: dropping the partition check, inverting it, policy fallback ignoring the region, removing the dedupe, box: false in the a2a or agui resolver, removing the hint, removing the ARN pattern check, removing the LangChain README paragraph.

Nits (non-blocking):

  • Survived: defaultTargetsWriter calling boxBedrockScopeWarning(spec) without region. The policy still falls back, but build would drop the warning for an ARN in another partition. A manager.boxNetwork case with an arn:aws-cn: modelId would pin it.
  • Survived: removing the {{#if box}} gate in the a2a or agui README. No test checks that a non-box render leaves the paragraph out.

Local: bun run typecheck and oxlint are clean. The touched and related suites pass, 642 tests, 0 fail. CI: CodeQL and Analyze pass. verify on Linux, macOS and Windows was still pending when I posted.

@mquang-amazon
mquang-amazon dismissed tejaskash’s stale review November 25, 2026 08:59

Each point of this review is addressed in 5e070e4 and b04d487 (see the reply comment), and Leo re-reviewed and approved. Dismissing to unblock the merge; happy to follow up on anything still open.

@mquang-amazon
mquang-amazon merged commit ae9fb3b into box-integration Nov 25, 2026
6 checks passed
@mquang-amazon
mquang-amazon deleted the box/bedrock-policy-per-model branch November 25, 2026 09:15
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.

4 participants