Repository navigation
feat(deploy): Run the boxed agent in a box on AgentCore Runtime - #2791
Draft
mquang-amazon wants to merge 4 commits into
Draft
mquang-amazon wants to merge 4 commits into
mquang-amazon wants to merge 4 commits into
Conversation
Templates whose agent calls a model now write "projectType": "box" and a "box" agentCoreGateways entry to agentcore.json. The CDK library owns the Box gateway (AWS_IAM, HTTP only) for a Box project; the entry only adds targets to it. The entry gets a us-west-2 "bedrock" passthrough target when the agent calls Bedrock (the Bedrock provider, or LiteLLM on a bedrock/ model). MCP, BMA and empty templates stay as before. The project schema accepts projectType, with no default, so existing projects are written back unchanged. Needs aws/agentcore-l3-cdk-constructs#454 for the CDK library to read projectType and add the Box gateway.
An MCP server calls no model when created, but its tools, or a model added later, still need a gateway for their outbound calls. mcp-python-fastmcp now writes "projectType": "box" and a box entry with no targets: a template with no model provider gets no Bedrock target.
# Conflicts: # src/handlers/project/shortcuts.ts
create wrote a box profile for `agentcore dev`, but a deployed agent ran unboxed: nothing shipped box to the Runtime or started it there. create now writes start.py and start.sh into every Python CodeZip template and sets entrypoint to start.py, and writes start.sh beside the Strands container template, whose Dockerfile copies box into /opt/box and starts it. On build and deploy, the CDK backend stages box from AGENTCORE_BOX_SOURCE (a staging-boxy checkout with an Amazon Linux 2023 build) into the zip's or the image's .box-dist/, with the AgentCore Runtime profile rendered from agentcore.json: no reload, signed with the execution role through the default AWS chain, and placeholders that start.sh fills in with the Runtime's paths and the deployed resources' variables. If box fails or the agent does not answer in 22s, start.sh serves the agent without box. When a boxed runtime has its default Memory, build and deploy add the Box gateway's `agentcore` passthrough target and route the agent's Memory calls through it, and write agentcore/box-memory-policy.json, listed in the gateway's new additionalPolicies, so the gateway role may call Memory. The local profile is unchanged byte for byte.
10 of 15 tasks
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
agentcore deployruns the agent thatagentcore createboxes in a box on AgentCore Runtime. Before this, onlyagentcore devran it in a box (#2790). Nothing shipped box to the Runtime or started it there.start.pyandstart.shinto every Python CodeZip template (Strands HTTP/A2A/AG-UI, LangChain, minimal, FastMCP) and setsentrypointtostart.py. The Runtime needs a.pyentry point, sostart.pyhands over tostart.sh.start.shfills in the Runtime profile and runsbox runin/tmp/box/workspace. If box fails or the agent does not answer within 22s, it servesmain.pywithout box (the Runtime allows 30s).BOX_START_DISABLE=1skips box.start.shinto/opt/box, and itsENTRYPOINTisstart.sh. Underagentcore dev(LOCAL_DEV=1),start.shonly runsbox runwith the project's profile, which dev stages (feat(dev): Run CodeZip and container agents with box run #2790).CdkBackendstages.box-dist/fromAGENTCORE_BOX_SOURCEbefore synth. That covers each CodeZip runtime whose entry point isstart.pyand each container whose Dockerfile copies.box-dist/. The Linux build comes from a staging-boxy checkout'starget-al2023/, plus the libffi shim for CodeZip. If a boxed runtime has noAGENTCORE_BOX_SOURCE, build fails with an actionable error.renderRuntimeBoxProfilerenders the profile from agentcore.json. It has no reload. Bedrock is signed with a bareaws://, the default chain, i.e. the execution role. It includes placeholders (@CODE@,@PYTHON@,@PYTHON_PREFIX@,@GATEWAY_BOX_URL@,# @AGENT_ENV@) thatstart.shfills in. Only the deployed Memory/Gateway IDs and URLs reach the agent's env. A non-Bedrock provider gets no route yet: on the Runtime its key comes from AgentCore Identity.agentcorepassthrough target,bedrock-agentcore.us-west-2, signed with the gateway role. They also writeagentcore/box-memory-policy.json(Memory data-plane actions on<project>_*<memory>-*) and list it in the gateway's newadditionalPolicies. The raw agentcore.json is patched, assyncRuntimeBuildsdoes, so unknown fields survive. Running it again changes nothing.agentCoreGateways[].additionalPolicies, which cannot be combined withexecutionRoleArn.start.pybut has no.box/profile.tomlis refused, becausestart.pyruns no agent of its own.The local (
agentcore dev) profile is byte-identical to #2788's for every template and model provider (checked across 29 combinations).Out of scope (follow-ups): TypeScript CodeZip/container templates (no TS box profile in #2788 yet), and the Bedrock Managed Agents executor box.
Depends on
a5a5a81b) until it lands. That resolves one conflict inshortcuts.ts/boxProfile.ts(DEFAULT_EGRESS_BEDROCK_REGION→BOX_GATEWAY_BEDROCK_REGION). The diff shows feat(create): Declare the Bedrock target on the runtime's Box gateway #2789's commits until it merges@aws/agentcore-cdkwith Box gatewayadditionalPoliciessupport (agentcore-l3-cdk-constructsbox-v3: "Attach additionalPolicies to the Box gateway role"), not yet released or pinnedAGENTCORE_BOX_SOURCE, until box ships a Linux releaseRelated Issue
N/A (box integration)
Documentation PR
Not applicable.
Type of Change
Testing
bun test: 4903 pass. 3 fail on this host and also fail on an unmodified base:toolAvailable,requireTool,SourceResolver bytes ... under nodebun run test:e2e: not run. A boxed deploy needsAGENTCORE_BOX_SOURCEand the unreleased CDK librarybun run typecheckbun run lint:checkbun run format:checkbun run auditbun run secrets:checkbun run buildsrc/assets/and updatedmanager.test.ts.snap(newstart.py/start.sh,entrypoint: start.py)command.mdChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the
terms of your choice.