Skip to content

feat(box): Send a boxed agent's Memory calls to Memory directly - #2889

Merged
vvargu merged 15 commits into
aws:box-integrationfrom
vvargu:box/memory-direct-access
Nov 24, 2026
Merged

vvargu merged 15 commits into
aws:box-integrationfrom
vvargu:box/memory-direct-access

Conversation

@vvargu

@vvargu vvargu commented Nov 21, 2026 •

Copy link
Copy Markdown

Description

A boxed agent's AgentCore Memory calls now go to Memory directly, signed with the execution role, and not through the Box gateway. The gateway signed them with its own role, so Memory could not hold each call to the session of the runtime, and one session could read or write the memory of another.

For a runtime with its default Memory, build now:

  • adds [egress.agentcore] to the Runtime profile: the AgentCore data-plane host bedrock-agentcore.<region>.<suffix>, with secret.ref = "aws://" and no backend.
  • sends a route or HTTP MCP server of the profile to that host directly too, signed with a bare aws://, with its name and other keys, and adds no second route beside it.
  • stops with RUNTIME_AGENTCORE_HOST_CREDENTIAL when such a route sends a key of its own (an env:// secret), because the direct route cannot send it. The problem names the entry and its variable.
  • adds no agentcore target to the Box gateway, and no Memory policy for the gateway role.

Box chooses where a connection goes from its host and port alone, before it sees the path ("the re-route is matched per connection, on host and port, before the path is known"). So box cannot send /memories directly and /code-interpreters through the gateway on one host. Code Interpreter, Browser, and the other AgentCore primitives are egress destinations on the same host as Memory, so they go there directly too. What the execution role may call there depends on its grants. Build writes no restricting policy for the host.

The agentcore name stays reserved on Box gateways, now as the Memory route's name. Build writes a managed egress- target only when the Runtime profile sends calls to it.

A runtime with no default Memory is unchanged.

Box projects built before this change are not migrated: Box on AgentCore Runtime is not launched yet.

Related Issue

Closes #

Dependencies

aws/agentcore-l3-cdk-constructs#481 must merge first. It gives a boxed runtime's role its Memory grant again (f63b066 removed it when the gateway made the Memory calls), and gives a PRIVATE_VPC runtime the AgentCore data-plane endpoint, which only the runtime's role may call through. Without it, the box's Memory calls get AccessDenied.

Documentation PR

Included: README and docs/box-local-testing.md.

Type of Change

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

Testing

  • bun test: 6417 pass, 3 fail. The failures are the the box on PATH tests, which run the local box on PATH, an older build. This change does not cause them.
  • bun run test:e2e: not run. No deployed check of Memory from a boxed agent yet.
  • bun run typecheck, bun run lint:check, bun run format:check, bun run build
  • Box 0.3.0 (the pin, sha256 checked) in a container, the same as 0.1.11-preview.10:
    • a backend route may not carry a path ("the re-route is matched per connection, on host and port, before the path is known"), and a host with a backend route may name no other entry;
    • two signed routes for one host are refused when they overlap, also for the exact same host;
    • a *.amazonaws.com route matches sts.us-east-1.amazonaws.com, for the permit and the secret;
    • a whole-host aws:// route to the AgentCore host signs Memory and Code Interpreter calls, and box normalizes the path before an http:request policy rule sees it.

The Box gateway signed the agent's Memory calls with its own role. Memory then
could not hold each call to the session of the runtime by its context keys, so
one session could read or write the memory of another session.

Build now adds no `agentcore` target to the Box gateway, and writes no
`agentcore/box-memory-policy.json` for the gateway role. The Runtime profile
gets a direct `[egress.agentcore]` route to the AgentCore host of the build
region. Box signs that route with a bare `aws://`, the execution role, and the
route has no gateway backend. The execution role already has the Memory
data-plane grants, because the runtime binds its Memory.

The route is added only for a runtime with its default Memory. A route or HTTP
MCP server of the profile that already has the AgentCore host keeps it. A user
route named `agentcore` for another host stops build.

When AgentCore Gateway can get the session from the context keys, Memory calls
can go through the gateway again.
@vvargu
vvargu requested a review from a team November 21, 2026 01:42

@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 for this. Moving Memory off the gateway role so Memory can scope each call to the runtime's session is the right fix, and the code for new projects is clean: the route is added only for the runtime's default Memory, it is a direct aws:// route with no backend, and the RUNTIME_ROUTE_NAME_TAKEN problem and the old-renderer parity tests are good. I checked the box egress docs: a bare aws:// route takes its SigV4 service and region from an *.amazonaws.com host, so bedrock-agentcore.<region>.amazonaws.com gets signed as bedrock-agentcore in the build region. I also checked that the L3 grants the runtime role the Memory data-plane actions for a bound Memory.

Blocking

  1. Conflicts with box-integration. A trial merge conflicts in src/core/project/runtimeProfile/rules/additions.ts (1 hunk, the rule table and imports next to #2885's [telemetry.agentcore_traces] row), src/core/project/runtimeProfile/rules/additions.test.ts (3 hunks), and src/core/project/manager.test.ts (2 hunks). They look textual, so keep both sides, but CI can't run until they're resolved. Please keep #2885's OTEL/X-Ray additions when you resolve them.

  2. Projects built before this change keep sending Memory through the gateway role, and nothing tells the user. Build saves its targets and additionalPolicies into agentcore.json, so an existing Box project already has the agentcore passthrough target on its Box gateway, agentcore/box-memory-policy.json in that gateway's additionalPolicies, and the file on disk. After this PR:

    • Nothing removes the agentcore target. It is not an egress- target, so the gateway rule treats it as the user's, keeps it, and writes [egress.agentcore] with a ${{ inputs.gateway.url }}/agentcore backend.
    • The additions rule then sees a route that already has the Memory host (routes.some(hasHost)) and adds no direct route. Memory calls still go through the gateway and are signed by the gateway role, which is the cross-session problem this PR is meant to fix.
    • box-memory-policy.json is no longer in BUILD_POLICY_FILES, so the IAM check now reads it as a user policy. It grants bedrock-agentcore:* data-plane actions, so boxGatewayIamWarnings stays quiet too. No warning appears and the role keeps the grant.

    I think build should remove what it wrote before. If the Box gateway has a target named agentcore that matches { passthrough https://bedrock-agentcore.<r>.<dnsSuffix>, CUSTOM, GATEWAY_IAM_ROLE bedrock-agentcore <r> } for some region (the shape the old getBoxGatewayAgentCoreTargetSpec produced), remove it with a step message. Also drop agentcore/box-memory-policy.json from additionalPolicies and emit { path, remove: true } for the file, which BoxNetworkFile already supports. Leave a target the user changed, as placeTarget already does for region moves. Please add a build test that starts from an old project (target, listing, and file present) and checks that the Runtime profile's [egress.agentcore] has no backend and the three leftovers are gone.

Non-blocking

  1. hasHost returns early for any route to the Memory host, including one that goes through the gateway. A user [egress.x] with destinations = ["bedrock-agentcore.<r>.amazonaws.com"] and secret.ref = "aws://" becomes a managed egress-x target with GATEWAY_IAM_ROLE, so Memory again goes out under the gateway role. That case does print a gateway IAM warning, so it isn't silent. Still, for this one host I'd only defer to a route with no backends, or report a problem when the route to the Memory host goes through the gateway. The unit test calls apply directly, so it doesn't cover what the gateway rule does before the additions rule runs.
  2. Stale doc: docs/box-local-testing.md (line 51) still says build writes "the Box gateway's Bedrock and Memory targets". README line ~262 ("its calls go out through its Box gateway") could mention the Memory exception and the VPC endpoint note from the PR description.
  3. hasHost matches destinations by exact string, so an entry for bedrock-agentcore.<r>.amazonaws.com:443 or a wildcard isn't counted, and box would then refuse two routes to one host. It's an edge case, but hostKey/buildHostMap could do the matching instead.
  4. For later: in China, box infers the signing scope only for .amazonaws.com / .api.aws, not .amazonaws.com.cn. Memory isn't offered there today (docs/china-regions.md), so nothing breaks now. If Memory ships in China, this route will need an explicit scope or a box change.

No internal references or account IDs in the diff or the commit message. I didn't find any unsafe test patterns.

Comment thread src/core/project/boxMemory.ts Resolved
Comment thread src/core/project/boxNetworkSource.ts Resolved
…-direct-access

# Conflicts:
#	src/core/project/manager.test.ts
#	src/core/project/runtimeProfile/rules/additions.test.ts
#	src/core/project/runtimeProfile/rules/additions.ts

@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-review at 4bca2ed (merge of box-integration at 3df8eab).

Merge: fixed, looks clean. The PR merges cleanly and has no conflict markers. #2885's OTEL/X-Ray changes are still there in additions.ts, additions.test.ts and manager.test.ts: the agentcore_traces row, defaultTracesTelemetry/withOtel in the derive test, and the box-telemetry-policy-* steps. The PR's own net diff matches what it was at 18f07c6, apart from line offsets and the comment and test changes that come from the merge. No change on the base is reverted.

Still blocking: the upgrade path (point 2 of my last review). No new commit addresses it. A project built before this PR keeps its agentcore gateway target. Build treats that target as the user's because it has no egress- prefix, so routes.some(hasHost) skips the direct route. Its Memory calls therefore still go through the gateway role. The project also keeps agentcore/box-memory-policy.json in its list and on disk. That file is no longer in BUILD_POLICY_FILES, so build reads it as a user policy and boxGatewayIamWarnings gives no warning. #2877 is still open, and its ownership record would not cover projects built before it anyway. What I suggested before still applies: remove the old target shape and the policy listing, delete the file (remove: true), and add a test that builds from an old project.

CI: CodeQL, Analyze, macOS and CodeBuild e2e pass. verify / Linux and verify / Windows were still pending when I posted this.

My earlier non-blocking notes still stand and I won't repeat them.

@codecov-commenter

codecov-commenter commented Nov 21, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.42197% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 96.87%. Comparing base (fc0b4dd) to head (833bc69).

Files with missing lines Patch % Lines
src/core/project/runtimeProfile/rules/additions.ts 99.18% 1 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff                @@
##           box-integration    #2889   +/-   ##
================================================
  Coverage            96.86%   96.87%           
================================================
  Files                  774      774           
  Lines                68684    68750   +66     
================================================
+ Hits                 66534    66599   +65     
- Misses                2150     2151    +1     

☔ 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.

A project that an earlier build wrote kept the `agentcore` target on its Box
gateway and `agentcore/box-memory-policy.json` in the gateway's
additionalPolicies and on disk. The gateway rule kept that target as the
user's, so the Memory calls still went through the gateway role, and the IAM
check read the old file as a user policy and gave no warning.

Build now removes the `agentcore` target when it is as the earlier build wrote
it for some region, removes the policy listing, and removes the policy file.
A target of that name that the user changed stays, and build then stops until
the user renames it, because its route would take the name of the Memory
route.

The Memory route rule now defers only to a direct route or HTTP MCP server to
the Memory host. A route through the Box gateway stops build with
RUNTIME_MEMORY_THROUGH_GATEWAY. The rule matches the host with `:443`, in any
case, and as a `*.` wildcard.

The README and the local testing guide now say that Memory calls go to Memory
directly, and that a runtime in VPC network mode needs a `bedrock-agentcore`
VPC endpoint.

@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-review of fafa189 (git diff 4bca2ed3..fafa189f, one new commit: "fix(box): Remove the Memory gateway access that an earlier build wrote"). Follow-up to my earlier COMMENT review.

Blocker (projects upgraded from an older build keep the cross-session Memory problem): fixed.

  • Old target: removeLegacyMemoryAccess finds the old target with isDeepStrictEqual against the exact shape the old getBoxGatewayAgentCoreTargetSpec wrote: name agentcore, passthrough to the AgentCore data-plane host of the target's own region, CUSTOM protocol, and GATEWAY_IAM_ROLE/bedrock-agentcore auth. Because the region comes from the target itself, a target written for any region is removed, including the China partition (tested). It runs over every bound Box gateway, so per-runtime networks are covered. It leaves alone a user's own agentcore target with a different shape, and the same shape on a non-Box gateway (both tested). If a user's own agentcore target remains, build stops with RUNTIME_ROUTE_NAME_TAKEN. That problem now points at agentcore.json and asks the user to rename the target. It doesn't fall back to a gateway route.
  • Policy: the box-memory-policy.json entry is dropped from additionalPolicies, and additionalPolicies itself is removed if that was its only entry. The file is deleted through { remove: true } with a removing <file> step, so the deletion is visible to the user. The delete uses unlinkSync behind existsSync, so a failure throws instead of being swallowed. Deleting without checking the content is fine: the older build owned this file and rewrote it on every build, so user edits never survived anyway.
  • End to end: the new manager-level test starts from an old project (old target, policy listing, policy file on disk) and runs build. It asserts that the target is gone, the listing is gone, the file is gone, the three step messages are printed, and [egress.agentcore] is the direct route (aws://, no backends).
  • Idempotent / new projects: on a second build, or on a new project, nothing matches and nothing is printed, because the remove step only reports when the file exists. That holds by construction; there is no explicit second-build test (see nit below).

Non-blocking items from my earlier review

  • hasHost also skipped the direct route when a gateway route already covered the Memory host: addressed. A route or MCP server with backends to the Memory host is now RUNTIME_MEMORY_THROUGH_GATEWAY and stops the build. This is tested in the rule and through build.
  • Stale docs (docs/box-local-testing.md, the README VPC endpoint note): addressed.
  • hasHost matched only the exact string: addressed. hasDestination now accepts any letter case, :443, and *. wildcards, and rejects other ports (tested).
  • China signing inference: still open as far as I can see. Fine to leave for a later phase.

New nits (non-blocking)

  1. hasDestination treats a *. wildcard as matching any number of subdomain levels (*.amazonaws.com covers bedrock-agentcore.<region>.amazonaws.com). Please confirm box matches wildcards the same way. If box's * matches only one label, a user's *.amazonaws.com route would stop build from adding the direct Memory route while box doesn't send Memory calls through that route either. Separately, a direct wildcard route without secret = aws:// now also stops the Memory route from being added, and then the Memory calls go out unsigned. A warning for that case may be worth adding.
  2. The legacy file is deleted no matter who lists it, but the listing is only removed from bound Box gateways. If a non-Box gateway lists agentcore/box-memory-policy.json, it is left pointing at a missing file. That's unlikely; one line in the step message or a check would cover it.
  3. A second build run in the old-project manager test would pin the idempotency.

Other checks: no internal references or account IDs in the diff. New tests use join(root, ...relative.split("/")) and existsSync, with no hard-coded / paths, chmod, spawned shells, or network. #2877 (box-gateway-targets.json) and #2864 (reserved names) are both still open. When they land, whichever merges second should include agentcore in, or reconcile it with, the reserved/recorded names. Nothing in this diff conflicts with them.

CI at review time: Linux and Windows verify pass, CodeQL, Analyze, and CodeBuild e2e pass. macOS verify failed only on project add runtime-endpoint wizard > a rejected add reports itself and hands the form back (timed out after 5000ms). That is the known macOS screen-test timeout flake and unrelated to this change. Please re-run macOS and merge only after checks are green. Merge state is blocked only because a review is required; the PR is up to date with box-integration.

Approving: the upgrade-path blocker is resolved and the rest are nits.

Comment thread src/core/project/boxNetworkWriters.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.

Thanks, sending Memory calls direct instead of through the gateway makes sense for most runtimes. Requesting changes because a PRIVATE_VPC runtime now loses Memory, the direct route opens more of the AgentCore host than Memory, and a few profiles that build today now stop (inline). If the route scoping can't land here, please record it as an open item for the v1.x merge.

…-direct-access

# Conflicts:
#	src/core/project/boxMemory.ts
…d send a profile route to the host directly

The direct Memory route opened every API of the AgentCore data-plane host
to the execution role, such as the identity and API key calls. It now names
`bedrock-agentcore.<region>.amazonaws.com/memories`, so box signs only the
Memory calls. A call to another API of the host goes unsigned, and AgentCore
refuses it.

A route of the profile to the AgentCore host that the gateway rule sends
through the Box gateway stopped build with RUNTIME_MEMORY_THROUGH_GATEWAY.
That broke profiles that need the host under `agentcore dev`, for Code
Interpreter or Browser. On the Runtime such a route now goes to the host
directly, signed with a bare `aws://`, with its name and other keys, and
build warns that it signs every API of the host. Box refuses the Memory
route beside a signed route that covers its path, so build adds none there.
A direct route to the host that box does not sign with `aws://` gets a
warning, as the Memory calls then fail.

Build keeps the Memory policy file of an earlier build while a gateway that
is not a Box gateway lists it. The upgrade test now builds twice.

The reserved Box gateway target names keep `agentcore`, now as the name of
the Memory route. The README and the local testing guide say that box signs
only `/memories`, and that a PRIVATE_VPC runtime needs the secure VPC's
AgentCore endpoint.
@vvargu
vvargu requested a review from tejaskash November 23, 2026 20:44
… sends directly

A route of the profile to the AgentCore host goes to the host directly on
AgentCore Runtime when the runtime has its default Memory. Build still wrote
the host's `egress-` gateway target, which the Runtime did not use, and the
gateway IAM check then warned about the gateway role's grants for it.

The gateway targets writer now writes a managed target only when a route or
MCP server of the derived Runtime profile sends calls to it through a
backend. A target that an earlier build wrote for a host that now goes
directly is removed, with a step message that says why.
…Memory

Box on AgentCore Runtime is not launched yet, and a Box project built before
this change can be discarded. So build no longer removes the `agentcore`
gateway target, the `agentcore/box-memory-policy.json` listing, or that file
from an earlier build. A user target named `agentcore` still stops build,
because its route would take the name of the Memory route.

@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-review at ff7bd08, after my APPROVE at fafa189. I reviewed the three new commits on top of the box-integration merge (git diff 41310f35..ff7bd08b): 78801c2, c411bae, and ff7bd08. The merge brought in #2888, #2864, #2863, and #2872. The branch contains the current box-integration and merges into it without conflicts.

My earlier notes

  • Wildcard depth: addressed. You checked that box matches *.amazonaws.com across several labels, which is what hasDestination does. A direct route to the host that isn't signed with aws:// now gets a warning, and that case is tested.
  • Policy file deleted for the whole project, listing removed only from Box gateways: moot. ff7bd08 drops the legacy cleanup entirely.
  • No second-build test: addressed for the new gateway-route case (manager.boxNetwork.test.ts builds twice and compares agentcore.json).
  • China signing inference: still open. Fine for a later phase.
  • macOS flake: see CI below.

The changes for the other review

  • The /memories path on [egress.agentcore] is applied and tested in the rule and through build/deploy for several regions. The README and local testing guide are updated.
  • RUNTIME_MEMORY_THROUGH_GATEWAY is removed. A gateway route to the AgentCore host is now rewritten to go direct with aws://, and build warns that the route signs every API of that host. gatewayRoutedTargets drops the egress- target that no backend uses. Both are tested in unit tests and through build.
  • ff7bd08 removes the upgrade cleanup that fixed my earlier blocker. Box on Runtime hasn't launched, so I accept that decision. One caveat is inline: a leftover legacy agentcore target doesn't stop the build as the commit message says.

Blocking (1, inline on additions.ts:279): when the AgentCore host's route carries a credential, the rewrite drops it silently. This applies to an env:// API key on an [egress] entry or an HTTP [mcp] server, for example an MCP server hosted on another AgentCore Runtime with bearer auth. The key is replaced by SigV4 from the execution role, and c411bae then removes the target that used to send the key. The warning doesn't mention the lost credential. I didn't find a later fix on box-integration-development, which doesn't have this code yet.

Non-blocking (inline): the commit message's claim about a legacy agentcore target is inaccurate. Also, a coupling note on gatewayRoutedTargets.

Other checks: no account IDs or internal links in the diff. No new types. The only type change is the removal of the RUNTIME_MEMORY_THROUGH_GATEWAY code, and nothing else references it.

CI at review time: Analyze and verify (Linux, Windows, macOS) were still pending for ff7bd08, and e2e was skipped. I didn't wait for them. Please merge only after they are green. A macOS 5000ms screen-test timeout is a known flake.

Leaving this as a comment, not an approval, because of the credential drop. Once the rewrite keeps a credentialed route on the gateway (or stops the build for it), with a test, I expect to approve.

Comment thread src/core/project/boxNetworkWriters.ts Resolved
…ries on the AgentCore host

On AgentCore Runtime the box of a runtime with its default Memory now reaches
the AgentCore data-plane host only for Memory. Code Interpreter, Browser,
identity, and API key calls on that host are blocked inside the box.

- Build writes agentcore-memory-paths.dw beside the Runtime profile and lists
  it last in `policies`. Its first rule denies each request to the host whose
  path is not /memories or under it. Its second denies a path that could
  leave /memories once AWS normalizes it: a `..` or `.` segment, an encoded
  dot, or an encoded backslash. No Memory, actor, session, or record ID holds
  a dot or a backslash.
- A route or HTTP MCP server of the profile to the AgentCore host, and a
  permit that names it, now stop build with RUNTIME_AGENTCORE_HOST_ROUTED.
  Box refuses a gateway route for a host that has another route, and a route
  of its own would reach the other APIs of the host. The problem names the
  entry or the permit of the local profile. Build no longer sends such a
  route to the host directly.
- A user policy file of the same name stops build.

The profile header names the policy file only when the profile lists it.
Box decodes %2e once before the policy, so a double-encoded %252e reaches the
policy as %2e and passes it. No Memory, actor, session, or record ID holds a
%, so the dot-segment rule now also blocks %25 on the AgentCore host.

@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-review at 84e0efa, after my COMMENT at ff7bd08. I reviewed the two new commits, git diff ff7bd08b..84e0efae (48d495e and 84e0efa). There was no force-push, and ff7bd08 is still an ancestor of the head.

My earlier notes

  • Blocking, credentialed route to the AgentCore host loses its key (additions.ts:279): addressed. 48d495e removes the rewrite. For a runtime with its default Memory, any [egress] entry, HTTP [mcp] server, or permit that reaches the AgentCore host now stops build with RUNTIME_AGENTCORE_HOST_ROUTED. The problem names the local entry or The permit "<id>". An env:// bearer key on such a route can no longer be swapped silently for aws://. This is the "fail the build" option I suggested. It's covered by unit tests (gateway-backed, direct, and MCP entries; :443, other case, and wildcard; the permit label) and by a build test that checks agentcore.json is left untouched.
  • ff7bd08 commit message on a user agentcore target: moot. Now that the rewrite is gone, a leftover old-shape agentcore target to the AgentCore host does stop build, through RUNTIME_AGENTCORE_HOST_ROUTED. A target of that name for another host still gets RUNTIME_ROUTE_NAME_TAKEN.
  • gatewayRoutedTargets coupling: still open, and now mostly dead code. See the inline comment.
  • China signing inference: still open. Fine for a later phase.

What's new

  • agentcore-memory-paths.dw is written next to the Runtime profile and listed last in policies. Its rules deny every path on the host except /memories and /memories/*, plus .. and . segments, %2e, %5c, and %25. Tests check that it parses, that it uses the regional and China host, and that a set of allowed and blocked paths behave as intended. That last test uses a local regex version of like, so it checks what the rules are meant to do, not how box evaluates them. Your container testing with box 0.1.11-preview.10 covers the gap, and HTTP/2 is noted as not tested. The build test checks the file text and the policies order. The created-template golden tests now expect the policy entry.
  • The header names the policy file only when the profile lists it, and both cases are tested.
  • A user policy file with that name stops build, and that's tested.

Non-blocking (inline): the stale comment and dead branch in boxNetworkWriters.ts. The endsWith name check and the reuse of RUNTIME_ROUTE_NAME_TAKEN for a policy file.

FYI, product impact. For a runtime with a default Memory, the box can no longer reach Code Interpreter, Browser, or another AgentCore Runtime on the data-plane host. That's true even through the gateway, and even when the profile routes the host. A broad *.amazonaws.com route also stops build now. The README says this, and I understand it came from a design review. It might be worth listing under "Breaking change" in the PR template, or noting it for the v1.x merge. @tejaskash's CHANGES_REQUESTED (PRIVATE_VPC endpoint dependency) is still open on the PR.

Other checks: one new problem code, RUNTIME_AGENTCORE_HOST_ROUTED, documented in types.ts. No other new types. No account IDs or internal links in the diff. The branch merges into box-integration without conflicts and isn't behind it. FYI only: it conflicts with #2877 at 9180136 (boxNetwork/network.ts, boxNetworkWriters.ts, manager.boxNetwork.test.ts, shortcuts.ts, two test files) and with #2887 at fa87fb5 (boxNetwork/network.test.ts, boxNetworkWriters.ts, runtimeProfile/types.ts).

CI at review time: verify (Linux, Windows, macOS) and Analyze were still pending for 84e0efa, and e2e was skipped. I didn't wait for them. Please merge only after they're green. A macOS 5000ms screen-test timeout and the Windows transactionSearch EFAULT are known flakes.

Approving. The blocker is fixed with tests, and what's left is non-blocking.

Comment thread src/core/project/boxNetworkWriters.ts Resolved
…-direct-access

# Conflicts:
#	docs/box-local-testing.md
#	src/core/project/manager.tsx
#	src/handlers/project/shortcuts.ts
… with no path limit

Box chooses where a connection goes from its host and port alone, before it
sees the path, so it cannot send /memories directly and Code Interpreter or
Browser through the Box gateway on one host. Code Interpreter, Browser, and
the other AgentCore primitives are egress destinations on the same host as
Memory, so for a runtime with its default Memory they all go to that host
directly, signed with the execution role.

- [egress.agentcore] now names the whole AgentCore data-plane host, not only
  /memories.
- Build no longer writes agentcore-memory-paths.dw or lists it in policies.
- A route or HTTP MCP server of the profile to the AgentCore host no longer
  stops build. It goes to the host directly, signed with a bare aws://, with
  its name and other keys, and build adds no second route beside it.

What the execution role may call on that host depends on its grants. The
README and the profile header say that these calls go to the host directly.

@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-review at 967e82f, after my APPROVE at 84e0efa. 84e0efa is still an ancestor (no force-push). Since then: a merge of box-integration (8f83fee, which brought in #2886 and #2878), then 5732c3c, 3c9ac03 and 967e82f. I reviewed git diff 8f83fee2..967e82f3 for the PR's own changes.

5732c3c reverses the design again. [egress.agentcore] now names the whole AgentCore host, agentcore-memory-paths.dw is gone, and any route or HTTP MCP server of the profile to that host is rewritten to go direct with a bare aws://. I'm changing my approval to request changes. That rewrite brings back the blocker I raised at ff7bd08, and it now gives no warning at all. Details are inline.

My earlier notes

  • Blocking at ff7bd08, credentialed route to the AgentCore host loses its key: regressed. At 84e0efa this was fixed by stopping build. 5732c3c removes RUNTIME_AGENTCORE_HOST_ROUTED and drops secret again. I ran a build probe: an [mcp.tools] HTTP server to bedrock-agentcore.us-west-2.amazonaws.com with secret.ref = "env://TOOLS_TOKEN" builds with warnings: []. The Runtime [mcp.tools] gets secret = aws://, no egress- target is written, and build still adds API key credential tools to agentcore.json and writes AGENTCORE_CREDENTIAL_TOOLS to .env.local. The token is never sent, and the user gets no hint why.
  • direct branch in boxNetworkWriters.ts is dead code: moot. It is live again, because the rewrite once more moves routes off the gateway. My coupling nit (tie direct to agentCoreDataPlaneHost(network.region)) still applies but is non-blocking.
  • endsWith(MEMORY_POLICY_FILE) and the reuse of RUNTIME_ROUTE_NAME_TAKEN for a policy file: moot. The policy file is gone.
  • China signing inference: still open, fine for a later phase.

New findings

  1. Blocking (security): with the path policy gone, code in the box can sign AgentCore Identity calls with the execution role. This is the concern in the open thread on additions.ts:298. The reply there says the reach is "bounded by the execution role's grants", but the risky case is the normal one. The strands-box template routes [egress.github] with env://GITHUB_TOKEN, so build adds an API key credential. Per the L3 code cited in that thread (AgentCoreRuntime.ts:471-498; I can't open that repo to check), the execution role then gets GetWorkloadAccessToken* and GetApiKeyCredential. So code in the box can call /identities/... on the now fully signed host and read the GitHub token that box exists to keep away from it. At 78801c2 your container test showed these calls left the box unsigned and got a 403. The design reason for dropping the allowlist (Code Interpreter and Browser must work) doesn't require opening /identities. You've already confirmed that box can deny by path in http:request and that it normalises ., .. and %2e first. So a denylist policy keeps Code Interpreter, Browser and Memory working and closes this gap: forbid on /identities and /identities/* for the AgentCore host, plus the dot-segment and %25 rule from 84e0efa. The other option is for the L3 to skip grantCredentialAccess() for a boxed runtime. If neither lands here, please get an explicit sign-off on the open thread and record it for the v1.x merge.
  2. Blocking: the env:// / API key case above (inline on additions.ts:273).
  3. Blocking: conflicts with box-integration again. A trial merge conflicts in src/core/project/runtimeProfile/rules/additions.test.ts against #2899 (6d009cf, IMDS forbid in every box profile). GitHub shows the PR as CONFLICTING. When you resolve it, please check that #2899's forbid policy still sits in the Runtime policies with this PR's changes.
  4. nit: the profile header can name a route that isn't in the profile (inline on additions.ts:166).

Other comments

  • The open thread on PRIVATE_VPC is now tied to aws/agentcore-l3-cdk-constructs#481. The README says the private VPC endpoint is one "which only the runtime's role may call through". On #481 I noted that its endpoint policy allows bedrock-agentcore:* on * with no account condition. If #481 keeps that, the README claim holds for the principal but not for the resource. Please keep the two in line once #481 settles.
  • The CHANGES_REQUESTED review from tejaskash is still open. Two of its three points are now answered by design (the full host, no build stop). The third, about credential reach, is finding 1 above.
  • The plan lists "direct memory access for the agent" as an open bug with no phase, so no later PR picks up the path policy.

Checklist: test coverage for the rewrite is good (rule test for egress and MCP, :443, case and wildcard, a build test with a second build), but no test has a credentialed entry. No new types; RUNTIME_AGENTCORE_HOST_ROUTED is removed cleanly from types.ts. The README and local testing guide match the new behaviour, apart from the endpoint-policy note above. No account IDs or internal links in the diff.

Local results at 967e82f: bun run typecheck passes. bun test: 6099 pass, 7 skip, 0 fail (6106 tests, 354 files). I did not run the e2e tests. GitHub CI shows conflicts, so CI for this head may be incomplete.

@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 for one blocking bug and the conflicts with box-integration (it now has the v1.x merge #2902 and box 0.3.0 from #2893).

Earlier points: the /identities exposure is closed in the L3 (a boxed runtime's role has no GetResourceApiKey, GetApiKeyCredential or GetResourceOauth2Token, AgentCoreApplication.ts:758), and routes to the AgentCore host now keep their names and go direct. Under PRIVATE_VPC, Memory reaches the data plane once L3 #481 merges, so #481 should merge first.

  1. A route to the AgentCore host loses its env:// key, and build says nothing (src/core/project/runtimeProfile/rules/additions.ts:272). leo237 raised it at :273 and it reproduces in three shapes: [mcp.tools] (type = "http") to the host with secret.ref = "env://TOOLS_TOKEN", [egress.tools] to the host with the same secret, and [egress.tools] with the host and api.github.com as destinations. In each, the Runtime profile sends the host direct with aws://, so the server gets SigV4 from the execution role instead of the bearer token and refuses the call. In the first two, deploy also provisions a credential nothing sends. Box cannot route one host both ways, so stop build with a RUNTIME_* problem that names the entry and says the host goes direct with the execution role. Add one rule test and one build test as a test.each over the [egress] and [mcp] forms.
  2. Recheck on box 0.3.0. The design rests on three behaviors seen with 0.1.11-preview.10: box routes by host and port only, refuses two signed routes for one host, and a *. wildcard matches several labels. Run those again on the 0.3.0 pin after the merge and update the Testing section.

Follow-ups that can land later:

  • src/core/project/boxNetwork/network.ts:640: a user's own gateway target for the AgentCore host is left unused, and the warning points the user the wrong way.
  • The CLI README (README.md:264-270) should say that any bedrock-agentcore:* grant added through additionalPolicies is callable by code in the box, as the L3 README does.
  • A box forbid on /identities and /identities/*, as leo237 suggested, would hold if a later L3 change gives a boxed role a credential grant.
  • additions.ts:317: the wildcard arm of hasDestination cannot run in build. additions.ts:266: a cast.

…-direct-access

# Conflicts:
#	docs/box-local-testing.md
#	src/core/project/boxNetwork/network.test.ts
#	src/core/project/boxNetworkWriters.ts
#	src/core/project/manager.boxNetwork.test.ts
#	src/core/project/runtimeProfile/rules/additions.test.ts
#	src/core/project/runtimeProfile/types.ts
…ore host

With the default Memory, box sends every call to the AgentCore host directly,
signed with the execution role, and box cannot route one host both ways. A
route to that host with an env:// key, such as an HTTP MCP server on another
AgentCore Runtime with bearer auth, lost its key with no message: the server
got SigV4 instead of the token, and deploy still provisioned the credential.

Build now stops with RUNTIME_AGENTCORE_HOST_CREDENTIAL and names the [egress]
entry or [mcp] server and its variable, from the Box network model's record of
the host's API key, or from a secret other than aws:// that the entry still
holds. That also covers an entry with the AgentCore host and another host.

Also:
- The profile header names the routes that reach the AgentCore host, not
  always [egress.agentcore].
- The gateway targets writer treats only the AgentCore host's target as
  direct, so a rule that drops another route never removes its target.
- The README says that code in the box can make any AgentCore call that the
  execution role allows, including a grant added through additionalPolicies.
@vvargu

vvargu commented Nov 24, 2026

Copy link
Copy Markdown
Author

@tejaskash thanks. Addressed in 833bc69, after a merge of the latest box-integration (the v1.x merge #2902 and box 0.3.0 from #2893). I merged instead of rebasing, so the PR history stays without a force-push.

  1. Lost env:// key: a route to the AgentCore host with a key of its own now stops build with RUNTIME_AGENTCORE_HOST_CREDENTIAL. The problem names the entry and its variable, and says that the host goes direct with the execution role. There is a rule test.each over the [egress] and [mcp] forms, and a build test.each over your three shapes. The build tests check that agentcore.json is not changed.
  2. Box 0.3.0: re-checked in a container on the pin, with the sha256 checked. All three behaviors are the same as on 0.1.11-preview.10, with the same error texts: routing by host and port only, two overlapping signed routes refused (also the exact same host), and *. matching several labels. The Testing section has the details.

Follow-ups: the CLI README now says that a bedrock-agentcore grant through additionalPolicies is open to code in the box. The network.ts:640 warning, the /identities forbid, and the hasDestination wildcard/cast nits are left for later. #481 still needs to merge first.

@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-review at 833bc69. I reviewed the merge of box-integration (1aab2f3) and the PR's own fix, 833bc69, separately. No blockers remain, so I'm approving.

Earlier findings

  • Credentialed route to the AgentCore host loses its key: fixed. With the default Memory, credentialProblems stops build with RUNTIME_AGENTCORE_HOST_CREDENTIAL. The problem names the [egress] entry or [mcp] server and its variable. I checked all three of tejaskash's shapes with a local build probe, and each one stops. agentcore.json and .env.local (no AGENTCORE_CREDENTIAL_TOOLS) are unchanged, and no egress-tools target is written. Mutation checks: commenting out the call fails 6 tests (3 rule, 3 build), and skipping the network-model record loop fails 4. No false positives: an aws:// route to the host still goes direct (the existing test), and an env:// route to another host still builds with its gateway target (probe).
  • /identities signed with the execution role: non-blocking now. This rests on the L3 point that a boxed role has no credential grants (AgentCoreApplication.ts:758). I can't open that repo, so I haven't verified it. The new README sentence about additionalPolicies helps.
  • Conflict with box-integration: resolved. I checked the resolution with git show --remerge-diff 1aab2f31. It keeps the box 0.3.0 docs line, takes #2887's projectGatewayTargetFor / passthrough.gateway changes and bedrock-api-key naming, and drops the Memory policy file as this PR intends. #2899's IMDS forbid in templates/boxProfile.ts is untouched. GitHub shows MERGEABLE.
  • Header nit: fixed. routesToHost names the routes that reach the host, with a test for a user route.
  • Box 0.3.0 recheck: done. The Testing section lists the three behaviors re-run on the 0.3.0 pin.

New

  • nit: no test pins the new host.host === agentCoreHost guard in writeGatewayTargets (boxNetworkWriters.ts). With it removed, all of src/core/project/ still passes.

Follow-ups (non-blocking, for a later phase or the v1.x merge)

  • A box forbid on /identities and /identities/*, so this doesn't rely on the L3 alone.
  • network.ts:640: the warning direction for a user's own gateway target for the AgentCore host.
  • additions.ts hasDestination wildcard arm, and the cast in memoryRoutes.
  • README: "which only the runtime's role may call through" should stay in line with the endpoint policy of L3 #481. #481 should merge first.
  • China signing inference.

Checklist: tests cover the [egress] and [mcp] forms in the rule and in build, plus the mixed-destination case. No silent fallbacks in the new code: every matched entry yields a problem. The comments match the code. The only new type is a problem code, documented in types.ts.

Local results at 833bc69: bun run typecheck passes. bun test: 6417 pass, 9 skip, 0 fail (6426 tests, 361 files). I did not run the e2e tests. CI: verify on Linux, macOS and Windows, Analyze and CodeQL pass; e2e skipped.

@vvargu
vvargu requested a review from tejaskash November 24, 2026 19:43

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

Approving. Both blocking items are fixed in 833bc69: a route to the AgentCore host with a key of its own now stops build with RUNTIME_AGENTCORE_HOST_CREDENTIAL, naming the entry, its variable and the fix, for the [mcp], [egress] and multi-host [egress] shapes, and removing the check fails 6 tests. The box 0.3.0 recheck is recorded in the Testing section. L3 #481 is merged, so the order holds.

Follow-ups for a later PR:

  1. src/core/project/boxNetwork/network.ts:640: a user's own gateway target for the AgentCore host is left unused, and the warning points the user the wrong way.
  2. A box forbid on /identities and /identities/*, as leo237 suggested, so the exposure stays closed if a later L3 change gives a boxed role a credential grant.
  3. src/core/project/runtimeProfile/rules/additions.ts: the wildcard arm of hasDestination cannot run in build, and the cast near memoryRoutes can go.

@vvargu
vvargu merged commit 7cc8f75 into aws:box-integration Nov 24, 2026
6 checks passed
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