Repository navigation
feat(box): Send a boxed agent's Memory calls to Memory directly - #2889
Conversation
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.
leo237
left a comment
There was a problem hiding this comment.
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
-
Conflicts with
box-integration. A trial merge conflicts insrc/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), andsrc/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. -
Projects built before this change keep sending Memory through the gateway role, and nothing tells the user. Build saves its targets and
additionalPoliciesintoagentcore.json, so an existing Box project already has theagentcorepassthrough target on its Box gateway,agentcore/box-memory-policy.jsonin that gateway'sadditionalPolicies, and the file on disk. After this PR:- Nothing removes the
agentcoretarget. It is not anegress-target, so the gateway rule treats it as the user's, keeps it, and writes[egress.agentcore]with a${{ inputs.gateway.url }}/agentcorebackend. - 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.jsonis no longer inBUILD_POLICY_FILES, so the IAM check now reads it as a user policy. It grantsbedrock-agentcore:*data-plane actions, soboxGatewayIamWarningsstays 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
agentcorethat matches{ passthrough https://bedrock-agentcore.<r>.<dnsSuffix>, CUSTOM, GATEWAY_IAM_ROLE bedrock-agentcore <r> }for some region (the shape the oldgetBoxGatewayAgentCoreTargetSpecproduced), remove it with a step message. Also dropagentcore/box-memory-policy.jsonfromadditionalPoliciesand emit{ path, remove: true }for the file, whichBoxNetworkFilealready supports. Leave a target the user changed, asplaceTargetalready 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. - Nothing removes the
Non-blocking
hasHostreturns early for any route to the Memory host, including one that goes through the gateway. A user[egress.x]withdestinations = ["bedrock-agentcore.<r>.amazonaws.com"]andsecret.ref = "aws://"becomes a managedegress-xtarget withGATEWAY_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 nobackends, or report a problem when the route to the Memory host goes through the gateway. The unit test callsapplydirectly, so it doesn't cover what the gateway rule does before the additions rule runs.- 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. hasHostmatchesdestinationsby exact string, so an entry forbedrock-agentcore.<r>.amazonaws.com:443or a wildcard isn't counted, and box would then refuse two routes to one host. It's an edge case, buthostKey/buildHostMapcould do the matching instead.- 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.
…-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
left a comment
There was a problem hiding this comment.
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 Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
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
left a comment
There was a problem hiding this comment.
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:
removeLegacyMemoryAccessfinds the old target withisDeepStrictEqualagainst the exact shape the oldgetBoxGatewayAgentCoreTargetSpecwrote: nameagentcore, passthrough to the AgentCore data-plane host of the target's own region,CUSTOMprotocol, andGATEWAY_IAM_ROLE/bedrock-agentcoreauth. 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 ownagentcoretarget with a different shape, and the same shape on a non-Box gateway (both tested). If a user's ownagentcoretarget remains, build stops withRUNTIME_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.jsonentry is dropped fromadditionalPolicies, andadditionalPoliciesitself is removed if that was its only entry. The file is deleted through{ remove: true }with aremoving <file>step, so the deletion is visible to the user. The delete usesunlinkSyncbehindexistsSync, 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
hasHostalso skipped the direct route when a gateway route already covered the Memory host: addressed. A route or MCP server withbackendsto the Memory host is nowRUNTIME_MEMORY_THROUGH_GATEWAYand 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. hasHostmatched only the exact string: addressed.hasDestinationnow 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)
hasDestinationtreats a*.wildcard as matching any number of subdomain levels (*.amazonaws.comcoversbedrock-agentcore.<region>.amazonaws.com). Please confirm box matches wildcards the same way. If box's*matches only one label, a user's*.amazonaws.comroute 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 withoutsecret = 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.- 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. - A second
buildrun 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.
tejaskash
left a comment
There was a problem hiding this comment.
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.
… 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
left a comment
There was a problem hiding this comment.
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.comacross several labels, which is whathasDestinationdoes. A direct route to the host that isn't signed withaws://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.tsbuilds 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
/memoriespath 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_GATEWAYis removed. A gateway route to the AgentCore host is now rewritten to go direct withaws://, and build warns that the route signs every API of that host.gatewayRoutedTargetsdrops theegress-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
agentcoretarget 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.
…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
left a comment
There was a problem hiding this comment.
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 withRUNTIME_AGENTCORE_HOST_ROUTED. The problem names the local entry orThe permit "<id>". Anenv://bearer key on such a route can no longer be swapped silently foraws://. 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
agentcoretarget: moot. Now that the rewrite is gone, a leftover old-shapeagentcoretarget to the AgentCore host does stop build, throughRUNTIME_AGENTCORE_HOST_ROUTED. A target of that name for another host still getsRUNTIME_ROUTE_NAME_TAKEN. gatewayRoutedTargetscoupling: 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.dwis written next to the Runtime profile and listed last inpolicies. Its rules deny every path on the host except/memoriesand/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 oflike, 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 thepoliciesorder. 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.
…-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.
…rant and data-plane endpoint
leo237
left a comment
There was a problem hiding this comment.
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_ROUTEDand dropssecretagain. I ran a build probe: an[mcp.tools]HTTP server tobedrock-agentcore.us-west-2.amazonaws.comwithsecret.ref = "env://TOOLS_TOKEN"builds withwarnings: []. The Runtime[mcp.tools]getssecret = aws://, noegress-target is written, and build still adds API key credentialtoolsto agentcore.json and writesAGENTCORE_CREDENTIAL_TOOLSto.env.local. The token is never sent, and the user gets no hint why. directbranch inboxNetworkWriters.tsis dead code: moot. It is live again, because the rewrite once more moves routes off the gateway. My coupling nit (tiedirecttoagentCoreDataPlaneHost(network.region)) still applies but is non-blocking.endsWith(MEMORY_POLICY_FILE)and the reuse ofRUNTIME_ROUTE_NAME_TAKENfor a policy file: moot. The policy file is gone.- China signing inference: still open, fine for a later phase.
New findings
- 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]withenv://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 getsGetWorkloadAccessToken*andGetApiKeyCredential. 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 inhttp:requestand that it normalises.,..and%2efirst. So a denylist policy keeps Code Interpreter, Browser and Memory working and closes this gap:forbidon/identitiesand/identities/*for the AgentCore host, plus the dot-segment and%25rule from 84e0efa. The other option is for the L3 to skipgrantCredentialAccess()for a boxed runtime. If neither lands here, please get an explicit sign-off on the open thread and record it for thev1.xmerge. - Blocking: the env:// / API key case above (inline on
additions.ts:273). - Blocking: conflicts with
box-integrationagain. A trial merge conflicts insrc/core/project/runtimeProfile/rules/additions.test.tsagainst #2899 (6d009cf, IMDS forbid in every box profile). GitHub shows the PR asCONFLICTING. When you resolve it, please check that #2899's forbid policy still sits in the Runtimepolicieswith this PR's changes. - 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_VPCis 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 allowsbedrock-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
left a comment
There was a problem hiding this comment.
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.
- 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:273and it reproduces in three shapes:[mcp.tools](type = "http") to the host withsecret.ref = "env://TOOLS_TOKEN",[egress.tools]to the host with the same secret, and[egress.tools]with the host andapi.github.comas destinations. In each, the Runtime profile sends the host direct withaws://, 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 aRUNTIME_*problem that names the entry and says the host goes direct with the execution role. Add one rule test and one build test as atest.eachover the[egress]and[mcp]forms. - 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 anybedrock-agentcore:*grant added throughadditionalPoliciesis callable by code in the box, as the L3 README does. - A box
forbidon/identitiesand/identities/*, as leo237 suggested, would hold if a later L3 change gives a boxed role a credential grant. additions.ts:317: the wildcard arm ofhasDestinationcannot 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.
|
@tejaskash thanks. Addressed in 833bc69, after a merge of the latest
Follow-ups: the CLI README now says that a |
leo237
left a comment
There was a problem hiding this comment.
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,
credentialProblemsstops build withRUNTIME_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(noAGENTCORE_CREDENTIAL_TOOLS) are unchanged, and noegress-toolstarget 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: anaws://route to the host still goes direct (the existing test), and anenv://route to another host still builds with its gateway target (probe). /identitiessigned 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 aboutadditionalPolicieshelps.- Conflict with
box-integration: resolved. I checked the resolution withgit show --remerge-diff 1aab2f31. It keeps the box 0.3.0 docs line, takes #2887'sprojectGatewayTargetFor/passthrough.gatewaychanges andbedrock-api-keynaming, and drops the Memory policy file as this PR intends. #2899's IMDS forbid intemplates/boxProfile.tsis untouched. GitHub shows MERGEABLE. - Header nit: fixed.
routesToHostnames 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 === agentCoreHostguard inwriteGatewayTargets(boxNetworkWriters.ts). With it removed, all ofsrc/core/project/still passes.
Follow-ups (non-blocking, for a later phase or the v1.x merge)
- A box
forbidon/identitiesand/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.tshasDestinationwildcard arm, and the cast inmemoryRoutes.- 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.
tejaskash
left a comment
There was a problem hiding this comment.
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:
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.- A box
forbidon/identitiesand/identities/*, as leo237 suggested, so the exposure stays closed if a later L3 change gives a boxed role a credential grant. src/core/project/runtimeProfile/rules/additions.ts: the wildcard arm ofhasDestinationcannot run in build, and the cast nearmemoryRoutescan go.
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:
[egress.agentcore]to the Runtime profile: the AgentCore data-plane hostbedrock-agentcore.<region>.<suffix>, withsecret.ref = "aws://"and no backend.aws://, with its name and other keys, and adds no second route beside it.RUNTIME_AGENTCORE_HOST_CREDENTIALwhen such a route sends a key of its own (anenv://secret), because the direct route cannot send it. The problem names the entry and its variable.agentcoretarget 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
/memoriesdirectly and/code-interpretersthrough 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
agentcorename stays reserved on Box gateways, now as the Memory route's name. Build writes a managedegress-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_VPCruntime the AgentCore data-plane endpoint, which only the runtime's role may call through. Without it, the box's Memory calls getAccessDenied.Documentation PR
Included: README and
docs/box-local-testing.md.Type of Change
Testing
bun test: 6417 pass, 3 fail. The failures are thethe box on PATHtests, which run the localboxon 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*.amazonaws.comroute matchessts.us-east-1.amazonaws.com, for the permit and the secret;aws://route to the AgentCore host signs Memory and Code Interpreter calls, and box normalizes the path before anhttp:requestpolicy rule sees it.