Skip to content

feat(box): merge Box on Runtime from box-integration into v1.x - #2922

Open
vvargu wants to merge 431 commits into
v1.xfrom
box/box-integration-to-v1x
Open

vvargu wants to merge 431 commits into
v1.xfrom
box/box-integration-to-v1x

Conversation

@vvargu

@vvargu vvargu commented Nov 25, 2026 •

Copy link
Copy Markdown

Description

This PR merges the Box on Runtime work from box-integration into v1.x.

The work is mostly from Varun Gunda, Quang Nguyen, Sai Abhishek and Abhilash Panigrahi. It also includes the commits by Tejas Kashinath that the Box work depends on:

A cherry-pick of only the Box authors' commits onto v1.x does not apply. Most of those commits conflict without the commits above.

The branch is box-integration with v1.x merged in. The first merge had two conflicts, and this branch fixes them:

  • src/handlers/project/create/index.ts: v1.x (feat(telemetry): record the template a project is created with #2907) moved const template higher in the function. This branch keeps that change and keeps the region line from box-integration.
  • src/handlers/project/create/create.screen.test.tsx: this branch keeps the REGION constant from box-integration and the trackCommandRun helper from v1.x.

The second merge of v1.x (with v1.3.0) had conflicts in 8 files. This branch keeps both sides in each file:

  • platformVersion: v1.x and Box each added the field and its enum. This branch keeps one field and the v1.x enum in constants.ts, and keeps BOX_PLATFORM_VERSION.
  • cdk.ts: build and deploy run the v1.x CDK feature check, then synthesize with the Box networks.
  • dev/index.ts: the v1.x warmup code, with the Box boxProject argument added to the runner call.
  • Templates, manager.tsx, the schema tests and the e2e README: both additions.

The later merge of box-integration had one conflict, a comment in src/core/project/templates/runtime.ts. This branch keeps the v1.x s3BucketMounts line and the new Box comment.

Merged Box PRs on box-integration are #2787–#2789, #2836, #2837, #2839, #2845–#2853, #2857, #2859, #2860, #2862–#2867, #2870–#2872, #2877–#2879, #2883–#2889, #2893, #2899, #2903, #2908–#2911, #2914, #2916, #2917, #2921, #2931–#2935, #2942, #2943, #2948–#2953, #2955 and #2956. Two stacked PRs came in through feature branches: #2790 (box run) and #2793 (deploy a container agent in a box). It also includes #2937 (Tejas), which renames the containment value SANDBOXED to CONTAINED, to match aws/agentcore-l3-cdk-constructs#500.

The CI workflows on box-integration also run on that branch, so those lines come into v1.x with this PR. Remove them before merge if you do not want them on v1.x.

Matching L3 constructs PR: aws/agentcore-l3-cdk-constructs (link in a comment below).

Related Issue

Box on Runtime integration.

Documentation PR

The docs are in this PR (docs/box-local-testing.md and README.md).

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Other (please describe):

Testing

How have you tested the change?

  • I ran bun test: 6937 pass, 6 skip, 6 fail. The 6 failures are tests that call the box binary on PATH (boxProfileResolver.test.ts, projectGateways.test.ts). The local box was an old strands-box 0.1.0, and it does not accept the profile. The merge does not change those files.
  • I ran the relevant end-to-end tests with bun run test:e2e, or explained why they are not applicable
    (CI does not run them for you)
  • I ran bun run typecheck
  • I ran bun run lint:check
  • I ran bun run format:check (on the changed files)
  • 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
  • If I re-recorded fixtures or golden files, every change beyond account identifiers is explained
    by this PR
  • This PR does not change command.md (the release workflow regenerates it)

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
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the
terms of your choice.

mquang-amazon and others added 30 commits November 20, 2026 13:50
…ith static imports

Addresses the review of #2852: the tests now give AWS_CONFIG_FILE,
AWS_PROFILE, and both home variables through env, check that process.env
is not read and that HOME comes before USERPROFILE, and cover the order
resolveRegion takes.
…times read, for the review comment on boxNetworkSource.ts line 168
…is build adds, for the review comment on boxNetworkWriters.ts line 341
…nd the warnings from the written spec, for the review comment on boxNetworkWriters.ts line 214
…for the review comment on conditions.ts line 307
The hosted macOS arm64 runner has no nested virtualization, so it
cannot run a container tool, and agentcore dev of the box container
template fails there. The Linux arm64 runner still runs it.
- Revert the trailing newline five non-box gitignore.template files gained,
  so their output matches v1.x.
- agent-python-strands-box keeps only the two files that differ (its
  Dockerfile and .gitignore); the resolver lays them over agent-python-strands.
- Each box shortcut is a spread of its twin, so a change to one reaches both.
- The empty .venv is part of the box CodeZip files (boxCodeZipFiles), which
  create and add runtime both write, not a --skip-install branch of create.
- The LangChain README says traces are not collected when the agent runs in
  a box.
- renderBoxProfile takes its region; the unused us-west-2 fallback goes, and
  its JSDoc says where box starts for a CodeZip agent.
- Two tests use test.each.
…s, and when build fills a blank one

Addresses the review of #2862:
- With the credential's reserved variable (AGENTCORE_CREDENTIAL_<NAME>) set
  in the environment, deploy provisions it while dev hands box the route's
  variable. Build now says so when the two hold different keys.
- Build filled a blank stored key in .env.local with no message; it says so
  now, as it does for a different key.
- Add the egress test on AgentCore Runtime: the egress agent deployed in a
  box reaches the profile's host through the Box gateway, and box refuses
  any other. It shares its agent and checks with the dev test.
- Install the AGENTCORE_E2E_BOX_CDK build only in projects that deploy; the
  dev and dev-egress cases have no use for it.
- Drop the README sentence that the per-Python cases wait for #2867, which
  has merged.
…version plumbing

Addresses the review of #2867:
- A pin bump stopped every existing Box project: build refused any
  box.version but the pin, and nothing rewrote the field. Build and deploy
  now set each box runtime's box.version to the pinned box (boxVersionWriter)
  and say so, since the box features and the profiles the CLI writes change
  together. The late stop in staging goes with it.
- boxReleaseFor, the per-version build Map, and the release getters of the
  staging functions and the container dev runner go: each stages BOX_RELEASE.
  Tests no longer stage 1.0.0 and 2.0.0 through fakes, and a build test
  covers the update.
- The testing guide is rewrapped to 100 columns and says how to publish an
  unreleased box; the pinned-release test title matches its assertions.
…w-fixes-host-map

# Conflicts:
#	docs/box-local-testing.md
…nd account

## Problem

agentcore/box-bedrock-policy.json lets the role of the Box gateway use
bedrock:InvokeModel and bedrock:InvokeModelWithResponseStream on all
inference profiles and all foundation models, in all regions and in all
accounts:

  arn:aws:bedrock:*:*:inference-profile/*
  arn:aws:bedrock:*::foundation-model/*

The agent uses the model only through the `bedrock` target of the
gateway. `build` writes that target for one region. The agent uses only
the inference profiles of the account of the gateway. A code inspection
found this problem.

## Solution

boxBedrockPolicy(spec, region) gets the region of the `bedrock` target
from the default targets writer. boxMemoryPolicy gets the region of the
`agentcore` target from the same writer. When the writer has no region,
it writes no Bedrock policy and no Memory policy. The policy has 3
statements:

1. BoxedAgentInferenceProfilesThroughGateway: the inference profiles in
   the region. One file is for all deploy targets, thus the ARN keeps
   "*" for the account. The condition of
   [e96cbdb](e96cbdb)
   keeps the inference profile in the account of the gateway role:
   "aws:ResourceAccount": "${aws:PrincipalAccount}".
2. BoxedAgentModelsInRegionThroughGateway: the foundation models in the
   region, when the agent names the model ID.
3. BoxedAgentModelsThroughInferenceProfiles: the foundation models in
   all regions, only when the agent uses an inference profile of that
   account in the region:
   "StringLike": {"bedrock:InferenceProfileArn":
   "arn:aws:bedrock:<region>:${aws:PrincipalAccount}:inference-profile/*"}.
   IAM does not accept that value in an ArnLike condition. CreatePolicy
   and the stack give "The policy failed legacy parsing". The Bedrock
   example in the AWS documents also uses StringLike.
   A `us.` or `global.` inference profile can send the model operation
   to other regions. For a `global.` inference profile, Bedrock also
   examines arn:aws:bedrock:::foundation-model/<model>, which has no
   region. The "*" region agrees with that ARN.

Each ARN has the partition of the region (aws, aws-cn, or aws-us-gov),
from the partition data of the AWS SDK. boxTelemetryPolicy uses the same
data. The policy file cannot contain the AWS::Partition value of the
stack, because the L3 reads the file with PolicyDocument.fromJson, and
that function does not replace such a value.

boxGatewayIamWarnings counts the Bedrock file only for the Bedrock
runtime host of the region that `build` writes. It counts the Memory
file only for the Memory host of that region. Thus a target that signs
Bedrock operations for a different region with the gateway role gets a
warning, because the new policy does not let the role do these
operations. The new boxGatewayBedrockHost(region) gives the host.

The policy keeps the same 2 operations. The policy does not let the
role use an `application-inference-profile`. The policy before this
change did not let the role use one, and the CLI does not make one.

## Tests

Before this change, each of these tests gives an incorrect result.
After this change, each result is satisfactory:

- boxMemory.test.ts, "boxBedrockPolicy": 1 test for each statement, and
  1 test for the partition of cn-north-1 and us-gov-west-1.
- boxNetworkWriters.test.ts, "writes the Bedrock policy for the region
  of the bedrock target it writes".
- manager.boxNetwork.test.ts, "moves the Memory and Bedrock policies
  with their targets to the region of the targets". A deploy to a
  target in eu-west-1 moves the `bedrock` target from us-west-2, and the
  Bedrock policy moves with it.
- network.test.ts, "a Bedrock runtime target needs bedrock:InvokeModel,
  which the Bedrock file grants in the build region only".

Each of 9 mutations gives an incorrect result in 1 or more of these
tests: no account condition, a wildcard region for the inference
profiles, a wildcard region for the models, no inference profile
condition, a wildcard account in that condition, ArnLike and not
StringLike, a constant `arn:aws`, a constant region in the writer, and
no host check in the warning.

IAM: `aws iam simulate-custom-policy` on the us-west-2 policy gives
`allowed` for these 7 items: the model in us-west-2 by its ID, the
`us.` and `global.` inference profiles of the account in us-west-2, and
the model in us-west-2, us-east-1, us-east-2, and in the region-less
global ARN through such a profile. It gives `implicitDeny` for these 7
items: an inference profile of a different account, an inference
profile in us-east-1, the model in us-east-1 and the global model with
no inference profile, the model in us-east-1 through a profile of a
different account or of us-east-1, and an
`application-inference-profile`. `simulate-principal-policy` on the
gateway role after the deploy gives the same 14 results. CreatePolicy accepts
the policy.

Live test in a dev account in us-west-2: a new project from the
agent-python-strands-box-container template, with the L3 at
[08f8b230](https://github.com/aws/agentcore-l3-cdk-constructs/commit/08f8b23002f9357b7607b9d073dfd77929629e6a).
With the default model, global.anthropic.claude-sonnet-5-5, 6 invokes
gave 391, 5555 (through the add_numbers tool), and Paris. Then
amazon.nova-lite-v1:0 in `app/agent/model/load.py`, a deploy, and 3
invokes gave the same answers. CloudTrail shows 12 ConverseStream operations
of the gateway role on these 2 model IDs, with no error code. The
gateway log group shows 12 operations through the `bedrock` target,
with no error. CloudTrail gives `"inferenceRegion": "us-west-2"` for
each operation, thus
the live test did not show a model operation in a different region.
Only the simulation shows it. The teardown removed the stack and the 3
log groups that stay after the stack.

Not done: `bun run test:e2e`, and a live test in aws-cn or aws-us-gov.

`bun test` gives `5833 pass, 7 skip, 0 fail`. The typecheck, lint, and
format checks are satisfactory.
The box templates wrote secret.ref = "aws://default" under [egress.bedrock]
in the local profile. Write a bare aws:// instead, which resolves the AWS
default credential chain, as agentcore dev does without a box and as the
Runtime profile already does.
`box-integration` has one new change,
[#2870](#2870).
It writes `docs/box-local-testing.md` again. Git merged the file with
no conflict, and the OTEL paragraphs of this branch stay in "What build
and deploy do with the box profile". The merge adds one paragraph to
step 10, which tells how to read box telemetry. That paragraph names the
default X-Ray target and the log group `aws/spans`.
Addresses the review of #2850: the role could invoke any Bedrock model in any
region. It may now invoke an inference profile of its own account in the
region build builds for, a foundation model there, and a foundation model in
another region only through an inference profile in that region, which is
how a cross-region (us., global.) profile reaches it.
- Check every runtime that names a platformVersion after synth, V1 included
  and not only in a Box project (runtimePlatformVersions), each against its
  own value.
- A runtime the stack exports no RuntimeId for gets its own message, since
  the cause may be a renamed export, not an old CDK library.
- Test the schema's accepted and refused values, and the build refusal for a
  Box runtime with no platformVersion as well as V1.
- The validation comment says the check runs before the runtime sync
  rewrites agentcore.json.
…' JSDoc on BOX_NETWORK_WRITERS

Addresses the review of #2886: the build screen called build with no region,
so a global --region was ignored there; it passes the region withRegion
resolved, as the command does.
…uild region"

This reverts commit 6072b2c. #2883 makes the same change and more (the
region's partition, and the account in the inference-profile condition), and
the two conflict, so the grant lands with #2883.
…s from PATH

Addresses the review of #2872: a capability check in place of CI && !linux.
It also covers a local machine with no container tool, says nothing about
Windows by accident, and runs the test once a runner gains one.
fix(box): Sign the local Bedrock route with a bare aws://
…he Box gateway

The comment of leo237 on boxMemory.ts: boxMemoryPolicy wrote
"arn:aws:bedrock-agentcore:<region>" for each region. Thus `build` for
cn-north-1 or us-gov-west-1 wrote a Bedrock policy with the correct
partition, and a Memory policy with an incorrect partition.

boxMemoryPolicy gets the partition from the region, with the
partition data of the AWS SDK, the same as boxBedrockPolicy.

Test: boxMemory.test.ts, "boxMemoryPolicy" > "names the partition of
the region it is given", for cn-north-1 (aws-cn) and us-gov-west-1
(aws-us-gov). Before this change, the result of this test is
incorrect.
…review nit on split in manager.boxNetwork.test.ts
The comment of leo237 on shortcuts.ts: boxGatewayBedrockHost wrote
"bedrock-runtime.<region>.amazonaws.com" for each region, and
boxGatewayAgentCoreHost wrote "bedrock-agentcore.<region>.amazonaws.com".
In the aws-cn partition, the DNS suffix is "amazonaws.com.cn". Thus,
for `build` in cn-north-1, the `bedrock` and `agentcore` targets had an
incorrect endpoint. Also, boxGatewayIamWarnings compared a target host
with an incorrect host, and gave a warning for a correct China host.
This problem was on box-integration before this PR.

The 2 functions get the DNS suffix from the partition data of the
AWS SDK, as boxBedrockPolicy gets the partition.

Tests. Before this change, the result of each test is incorrect:

- shortcuts.test.ts, "Box gateway targets" > "take the DNS suffix of
  the partition of the region": cn-north-1 gives amazonaws.com.cn,
  us-gov-west-1 and us-west-2 give amazonaws.com.
- network.test.ts, "the Bedrock and Memory files grant the
  amazonaws.com.cn hosts of a build for China": no warning.

A constant "amazonaws.com" in each of the 2 functions gives an
incorrect result in the 2 tests.
fix(build): Keep the Bedrock grant of the Box gateway in its region and account
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Nov 28, 2026
@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label Nov 28, 2026
vvargu and others added 5 commits November 27, 2026 21:30
…he box

A customer gives a boxed agent a variable in [agent.env] of the local box
profile, which works under agentcore dev and on the Runtime. The derived
Runtime profile no longer forwards the envVars of agentcore.json, so this
change removes withRuntimeEnvVars, its skip rules and warnings, and
agentCorePackEnvSources.

The pack keeps AWS_EXECUTION_ENV, AWS_DNS_SUFFIX, and the ADOT settings that
the Runtime sets.
feat(box): Give the agent in the box the service variables of AgentCore Runtime
fix(box): Pin box to the strands-agents/box 0.3.3 release
…tegration-to-v1x

# Conflicts:
#	src/core/project/templates/runtime.ts
@github-actions github-actions Bot added size/xl PR size: XL and removed size/xl PR size: XL labels Nov 28, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Nov 28, 2026
@@ -1,3 +1,23 @@
{{!-- The API key of a boxed agent, which every keyed provider below includes. --}}
@@ -1,3 +1,23 @@
{{!-- The API key of a boxed agent, which every keyed provider below includes. --}}
@@ -1,3 +1,23 @@
{{!-- The API key of a boxed agent, which every keyed provider below includes. --}}
@github-actions github-actions Bot added size/xl PR size: XL and removed size/xl PR size: XL labels Nov 28, 2026
@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label Nov 28, 2026
test(e2e): Run the Box egress tests on AgentCore Runtime concurrently
@vvargu vvargu changed the title feat(box): Merge Box on Runtime from box-integration into v1.x feat(box): merge Box on Runtime from box-integration into v1.x Nov 28, 2026
@github-actions github-actions Bot added size/xl PR size: XL and removed size/xl PR size: XL labels Nov 28, 2026
@github-actions github-actions Bot added size/xl PR size: XL and removed size/xl PR size: XL labels Nov 30, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Nov 30, 2026
@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label Nov 30, 2026

This branch has not been deployed

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

Labels

size/xl PR size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants