Repository navigation
Conversation
Package TarballHow to installgh release download pr-2719-tarball --repo aws/agentcore-cli --pattern "*.tgz" --dir /tmp/pr-tarball
npm install -g /tmp/pr-tarball/aws-agentcore-1.2.0.tgz |
|
Claude Security Review: no high-confidence findings. (run) |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## v1.x #2719 +/- ##
==========================================
- Coverage 96.57% 96.57% -0.01%
==========================================
Files 734 734
Lines 60950 61201 +251
==========================================
+ Hits 58863 59105 +242
- Misses 2087 2096 +9 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
AgentCore Harness Review
Verdict: Changes requested
Reviewed against base refactor (head 2fbdf13). The schema/sync/prepare changes themselves are clean, well-scoped, and the tests use real temp dirs rather than fs mocks — good. Three things need resolving before this lands.
1. agentcore dev is left undefined for a pre-built runtime
runtimeProblems now returns early for any containerUri runtime (src/core/project/runtimeBuild.ts:589) and prepareRuntimes skips the code-folder check (src/core/project/runtimeBuild.ts:551) for both purposes, including "dev". But runner selection still routes build: "Container" to ContainerDevRunner (src/handlers/project/index.ts:66), which unconditionally builds from a local Dockerfile (src/core/dev/container.ts:78-91). So for a pre-built runtime:
- with no local source (the normal pre-built case, which this PR explicitly makes legal):
agentcore devnow fails with the low-levelno container build context directory exists at <path>/no container Dockerfile exists at <path>instead of the README-pointingProjectStateErrorthe prepare step used to produce; - with a leftover
DockerfileincodeLocation: dev silently builds and runs an image that has nothing to do with thecontainerUrithat will be deployed.
Options:
- gate it like the BMA case — make
supportsLocalDev(src/handlers/project/dev/index.ts:71) false forcontainerUriruntimes and raise the existingNotImplementedErrorwith a clear message; - keep the Dockerfile/code-folder checks when
purpose === "dev"and only skip them for"deploy", so the existing guidance still fires; - teach
ContainerDevRunnertodocker runthe pre-built image instead of building.
Any of these is fine, but the current state is an unhandled path for the config this PR introduces.
2. Confirm the relaxed VPC rules are mirrored in the released CDK
src/projectSchemas/runtime.ts:339 makes both the CodeBuild vpcId requirement and the five-security-group cap conditional on containerUri === undefined. In the currently published @aws/[email protected], AgentEnvSpecSchema still gates both on data.build === 'Container' alone, so a networkMode: "VPC" pre-built runtime without vpcId (or with 6+ SGs) would pass CLI validation and then fail inside readAgentCoreProject at synth. Please confirm aws/agentcore-l3-cdk-constructs#440 relaxes the schema side identically — these are explicitly mirrored schemas, and the design doc requires both to enforce the same rules.
Related consistency point: HarnessSpecSchema still uses isContainerBuild(data) (true when containerUri is set) for the SG cap, so runtime and harness now disagree about whether a pre-built image is subject to CodeBuild limits. Worth aligning or noting why they differ.
3. Bumping src/assets/cdk/package.json is not enough — old pins silently drop containerUri
AgentEnvSpecSchema in the published CDK is a non-strict z.object, so an unknown containerUri on a runtime is stripped, not rejected. The vended agentcore/cdk/package.json is only written at create/migrate time, so an existing project still pinned to @aws/[email protected] that adds containerUri will not error: the CLI now skips the Dockerfile existence check, the CDK ignores the field, and the build falls back to the source-asset → CodeBuild path (failing at build time, or worse, succeeding against a stale local Dockerfile and deploying the wrong image).
There is already a mechanism for this: MINIMUM_COMPATIBLE_CDK_VERSION / cdkCompatibilityWarning in src/core/project/backends/cdk/compatibility.ts (surfaced at src/core/project/backends/cdk.ts:219). Options:
- bump
MINIMUM_COMPATIBLE_CDK_VERSIONto the release containing #440 when you bump the vended pin; - or add a feature-specific check that hard-fails (not just warns) when any runtime has
containerUriand the installed@aws/agentcore-cdkpredates support, with an "updateagentcore/cdk/package.json" message.
Silent misdeployment is the failure mode here, so I'd lean toward an error rather than a warning.
Minor (non-blocking)
runtimeProblemscomputesfolder/folderLabelbefore thecontainerUriearly return (src/core/project/runtimeBuild.ts:586-589) — dead work.- A pre-built runtime with a
Dockerfilesitting incodeLocationnow gets no feedback that the file is ignored; a sync warning would make the chosen image source obvious (and would also explain the dev behavior if you pick option 3 above for #1).
|
Claude Security Review: no high-confidence findings. (run) |
|
Claude Security Review: no high-confidence findings. (run) |
There was a problem hiding this comment.
AgentCore Harness Review
Verdict: Changes requested
Reviewed against base v1.x (merge base 659176f0, head 2011d39b). The schema split into src/projectSchemas/container.ts, the strict --advanced-configuration parsing with duplicate-flag detection, and the sync/prepare short-circuits look good, and the new tests use real temp dirs and a real spawned node rather than fs/process mocks. Three things need changes; the earlier review's CDK-release dependency is still open.
1. agentcore dev now fails for the whole project when any runtime is pre-built
src/handlers/project/dev/index.ts:231-238 throws as soon as one selected runtime has containerUri. When --agent is omitted, selectedRuntimes is every runtime in the project (:217), so a mixed project — exactly the configuration the PR's own test matrix covers ("ordinary Dockerfile build … while the pre-built image skips it") — can no longer run agentcore dev at all. The BMA case directly below handles this correctly: it filters with supportsLocalDev and only errors when nothing is left (:239-246), and runRuntimeDev prints a per-runtime Skipping runtime '<name>': … status for the excluded ones (:374-383).
Options:
- filter pre-built runtimes out of the selection the same way (
supportsLocalDevreturning false forcontainerUri, or a second filter) and only throw whensupportedRuntimesis empty, adding a "Skipping runtime '': it deploys a pre-built image" status for the mixed, no---agentcase; - keep the hard error but restrict it to the explicit
--agent <prebuilt>case.
The added test (src/handlers/project/dev/index.test.ts:273) only exercises --agent image; the no---agent mixed-project path — the one that regresses — is untested. Please cover it.
2. The user-facing error (and the docs) point at a PR users cannot see
src/core/project/backends/cdk/compatibility.ts:51-56 tells the user to "Install a release containing aws/agentcore-l3-cdk-constructs#440". That repo is not publicly readable (GET /repos/aws/agentcore-l3-cdk-constructs/pulls/440 → 404 unauthenticated), so the error names something the reader cannot resolve, and it gives no actionable version. Same for docs/runtime-prebuilt-images.md:53 and e2eTest/README.md:34, which are shipped user documentation.
Please name the minimum @aws/agentcore-cdk version instead and say where to change it (agentcore/cdk/package.json, then npm install). compatibility.test.ts:104 asserts on "#440" and will need updating with the message.
3. The probe reports "CDK does not support pre-built images" for failures that have nothing to do with the CDK version
assertPrebuiltRuntimeSupport treats any non-zero exit or spawn failure as "the installed schema strips containerUri": node not on PATH (only npm is checked, cdk.ts:210), a partially installed node_modules, a throw while require-ing @aws/agentcore-cdk (it loads aws-cdk-lib transitively), or a future rename of AgentEnvSpecSchema all produce the same misleading diagnosis. compatibility.test.ts:99-102 ("fails for missing or broken feature dependencies") codifies that conflation.
Options:
- have the probe exit with a distinct code for the stripped-field case (e.g.
process.exitCode = 3) and only claim "unsupported" for that code, rethrowing/surfacing the underlying error otherwise; requireTool("node", …)before probing, and wrap therequirein the probe so a load failure reports itself;- once #440 is released, drop the subprocess entirely and gate on the installed version with
semver, the waycdkCompatibilityWarningalready readsnode_modules/@aws/agentcore-cdk/package.json— that also removes the need for the newactions/setup-nodesteps inverify.yml.
Still open from the earlier review
src/assets/cdk/package.json still pins @aws/agentcore-cdk 1.0.0, which has no runtime containerUri, and the PR is no longer a draft. As it stands, a project created by this CLI documents a feature that fails at agentcore build/deploy with the message from #2. The probe correctly turns the previously-silent misdeploy into a hard failure — good — but the pin bump (and confirmation that the CDK relaxes the CodeBuild vpcId/5-security-group rules identically, per src/projectSchemas/runtime.ts:339,365 and the 6-SG/no-vpcId expectation in add/runtime/index.test.ts) remains a merge gate.
Minor (non-blocking)
compatibility.ts:39: "Only the image URI is passed, never the Runtime's environment or credentials" —runProcesspasses noenv, so the child inherits the CLI's full environment. The comment claims isolation the code does not provide; either pass a minimalenvor drop the claim.compatibility.test.ts:126-128asserts the literal argv prefix["node", "--input-type=commonjs", "-e"], which restates the implementation rather than a behavior.docs/runtime-prebuilt-images.mdis not linked from the docs list inREADME.md:181-182.
2011d39 to
be3bba4
Compare
|
Claude Security Review: no high-confidence findings. (run) |
be3bba4 to
ecb6020
Compare
|
Claude Security Review: no high-confidence findings. (run) |
ecb6020 to
6e4aedf
Compare
tejaskash
left a comment
There was a problem hiding this comment.
Thanks for this, the schema, sync and add flow read well and the contract matches the CDK PR. Requesting changes for four items:
src/assets/cdk/package.jsonstill pins@aws/agentcore-cdk1.2.0, which has nocontainerUri.add runtimesucceeds and the next deploy fails. The pin bump needs to land with this PR.- Bare
agentcore devfails for the whole project once one runtime is pre-built. - Moving a deployed CodeBuild runtime to
containerUriwith its own image URI deletes the repository that holds the image. - Public ECR URI validation counts the registry alias as part of the repository name.
Details and smaller notes are inline. Not live tested on my side: cross-account pulls, cross-region pulls and public image invocation.
| throw new ProjectStateError( | ||
| 'This project requires an @aws/agentcore-cdk package that supports "ContainerLocal". ' + | ||
| `Update the dependency in ${cdkDirectory} and run npm install.`, | ||
| `This project uses ${missing.join(" and ")}, which its @aws/agentcore-cdk package does not ` + | ||
| `support. Install a release that includes ${missing.map((feature) => CDK_FEATURE_RELEASES[feature]).join(" and ")} ` + | ||
| `in ${cdkDirectory} (npm install), then rebuild or redeploy.`, |
There was a problem hiding this comment.
Two problems with this advice:
- It names a PR in a private repo, so a user has no version to install. Could
CDK_FEATURE_RELEASEShold the minimum@aws/agentcore-cdkversion instead? - The dependency sync rejects a pin newer than the one the CLI vends (
dependencies.ts:180), so a user who follows this gets a second error on the next deploy. "Update the CLI" is the advice that works for managed projects.
compatibility.test.ts asserts on #440 and will need the same update.
| const prebuilt = selectedRuntimes.find((runtime) => runtime.containerUri !== undefined); | ||
| if (prebuilt) { | ||
| throw new InputValidationError( | ||
| `Runtime '${prebuilt.name}' uses a pre-built containerUri. ` + | ||
| "Deploy it with agentcore deploy, then use agentcore invoke. " + | ||
| "For local dev, select a runtime with local source using --agent <name>.", | ||
| ); | ||
| } |
There was a problem hiding this comment.
Without --agent, selectedRuntimes is every runtime, so a project with local runtimes a and b and one pre-built runtime can no longer run bare agentcore dev.
Suggestion: have supportsLocalDev return false for containerUri runtimes, print the existing skip status, and throw only when nothing is left, the same way the BMA case below does. That also fixes the reload path at line 506, which filters with supportsLocalDev and today passes a newly added pre-built runtime to the local container runner.
A test for the mixed project without --agent would cover it.
| if ( | ||
| key.startsWith("runtime/") && | ||
| pair.has("CodeZip") && | ||
| (pair.has("Container") || pair.has("ContainerUri")) | ||
| ) { |
There was a problem hiding this comment.
Container to ContainerUri is allowed here. If the user sets containerUri to the image already in the CLI-managed repository (a natural way to stop rebuilding), the CDK drops that repository from the stack, and it is created with RemovalPolicy.DESTROY and emptyOnDelete: true. The runtime then points at a deleted image.
Could we reject a containerUri that refers to a repository this deploy removes, and tell the user to copy the image to their own repository first?
| const [, registry, , , , repository = "", tag, digest] = match; | ||
| const maxRepositoryLength = | ||
| registry === "public.ecr.aws" | ||
| ? MAX_PUBLIC_REPOSITORY_NAME_LENGTH | ||
| : MAX_PRIVATE_REPOSITORY_NAME_LENGTH; | ||
| if (repository.length < MIN_REPOSITORY_NAME_LENGTH || repository.length > maxRepositoryLength) { |
There was a problem hiding this comment.
For public.ecr.aws the captured group is alias/repository, so:
- a valid public repository name near 205 characters is rejected because the alias is counted
public.ecr.aws/abcdefgh:v1, which has no repository segment, is accepted
Suggestion: split off the alias for public URIs, require a repository segment, and apply the length check to the repository only. The boundary tests currently omit the alias.
| * The rules for a pre-built image (`containerUri`): it is the whole container | ||
| * artifact, so it needs `build: "Container"` and excludes every local build | ||
| * setting. Shared by agentcore.json and `add runtime --build-config`; the CDK | ||
| * package's schema enforces the same rules. |
There was a problem hiding this comment.
This holds for the cross-field rules only. The CDK ContainerUriSchema applies just the CloudFormation regex, so tag, digest, length and whitespace rules differ. I left a matching comment on the CDK PR. Aligning the two would be best, otherwise please reword this.
| - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 | ||
| with: | ||
| node-version: "22" |
There was a problem hiding this comment.
The setup-node step for 20.12.0 a few lines below runs after this one and replaces it, so the build and tests still run on Node 20.12.0. Is Node 22 needed here? If not, this step can go. The same applies to the second job.
| This feature requires an `@aws/agentcore-cdk` package that includes CDK PR #440. Older packages can | ||
| silently strip unknown schema properties, so before building or deploying, the CLI checks that the | ||
| project's package supports every feature the project uses (pre-built Runtime images, | ||
| `ContainerLocal`) and fails with the missing feature named. A package that is installed but fails | ||
| to load is reported with its own load error instead. Release the CDK change and update the | ||
| vended package pin before releasing the CLI change. |
There was a problem hiding this comment.
Could this name the minimum @aws/agentcore-cdk version instead of the PR number? The last sentence is a note for maintainers and should not be in user docs. A sentence on the repository policy needed for cross-account images would help here too.
A Runtime can deploy an existing private or public ECR image: set containerUri
in agentcore.json, or with agentcore add runtime --build-config
'{"containerUri":"..."}'. The image is deployed as is: no local source,
Dockerfile, CodeBuild, or managed ECR repository.
- containerUri requires build Container and excludes dockerfile,
buildContextPath, and customDockerBuildArgs, matching @aws/agentcore-cdk
- add runtime --build-config accepts containerUri, defaults build to
Container, and needs no --language; with containerUri it skips the
Dockerfile requirement for Container builds
- a containerUri Runtime resolves to workload build mode ContainerUri, so it
triggers no local image build, Dockerfile sync, or ARM64 builder check
- dev skips pre-built Runtimes (with a status line) and runs the rest, also on
reload; selecting only pre-built Runtimes explains how to deploy and invoke
- the switch guard rejects a deployed Runtime changing between CodeZip and
ContainerUri in either direction (the service rejects artifact-type
changes); Container or ContainerLocal to ContainerUri stays allowed, except
Container to an image in the ECR repository the stack created for that
build, which the deploy deletes
- public.ecr.aws URIs need an alias and a repository; the 2-205 length applies
to the repository only
- one Node probe checks the CDK package for every feature the project uses
(ContainerLocal, Runtime containerUri); a missing feature names the minimum
@aws/agentcore-cdk version and, when the CLI manages the dependencies, asks
to update the CLI; a package that fails to load is reported with its own
error
- workload build mode ContainerUri is counted in telemetry
6e4aedf to
b50a019
Compare
tejaskash
left a comment
There was a problem hiding this comment.
Thanks for the quick turnaround. All seven comments are addressed, and typecheck and the changed tests pass for me locally.
Two things to close before merge:
- The vended
@aws/agentcore-cdkpin is still 1.2.0. Please bump it once the CDK release is out, and confirm the release number matches the 1.3.0 inCDK_FEATURE_RELEASES. verify / Windowsfailed on a timeout intoolkit.test.ts, which this PR does not touch. A rerun should tell us if it is a flake.
Small follow-up, not blocking: the new repository guard covers a runtime moving from Container to containerUri. Removing the Container runtime and adding a new one that points at the old repository is not caught.
|
Claude Security Review: no high-confidence findings. (run) |
Description
Implements the CLI portion of the pre-built Runtime image design from #2718. Users can add an existing ECR image through the
--build-configJSON flag:agentcore add runtime --name agent \ --build-config '{"containerUri":"123456789012.dkr.ecr.us-west-2.amazonaws.com/agent:v1"}' agentcore deployThe Runtime deploys the supplied private or public ECR image without local source preparation or CodeBuild. Dockerfile deployments continue using CodeBuild by default. Toolkit-managed local builds and private-only invocation remain separate proposals.
Implementation
containerUrivalidation, matching Harness. Rejects CodeZip, ContainerLocal, and Dockerfile/build-context/build-argument combinations withcontainerUri. The URI is validated against the service's image grammar ataddtime (tag,sha256:/sha512:digest, repository-name length, no whitespace), so bad values fail locally instead of at CloudFormation.containerUrias a key of the strict--build-configJSON onadd runtime;builddefaults toContainer. Unknown keys and invalid combinations fail before project changes.ContainerUri: no local image build, Dockerfile sync, or builder/ARM64 check. A deployed Runtime cannot switch between CodeZip and ContainerUri (the service rejects artifact-type changes); ContainerUri and Container can switch.containerUri; a package that fails to load is reported with its own error. Works with the npm bundle and the compiled Linux binary without passing Runtime environment secrets to the probe.agentcore devskips pre-built runtimes (with a status line) and runs the rest; selecting only a pre-built runtime explains how to deploy/invoke it instead of attempting a local build.Containerruntime to acontainerUrithat points at the CLI-managed repository the deploy removes (the image would be deleted); copy the image to your own repository first.Related work
Delivery dependency
This PR remains draft until the companion CDK change is released. Before merge,
src/assets/cdk/package.jsonmust be updated from@aws/agentcore-cdk1.2.0 to a release containing aws/agentcore-l3-cdk-constructs#440 (and the merged ContainerLocal support). Live tests use a locally packed package built from #440 rebased on the latestv1.x.Type of Change
Testing
v1.xat v1.2.0 (after feat(build): add ContainerLocal build mode (re-land #2814) #2855, fix(build): address ContainerLocal bug bash findings #2856, feat(project): sync vended CDK dependencies on build and deploy #2861); single commitbun test— 5,191 passed; 6 Windows-only tests skippedbun run typecheck,bun run lint:check,bun run format:checkbun run secrets:check, npm bundle build, Linux x64 binary compilationv1.x): 1,343 tests passed; build/typecheck/format/lint passed (five existing lint warnings)networkConfig.vpcIdor CodeBuild resourcesb50a0190: pendingminimatchversions in the lint toolchain triggerGHSA-g3hv-75wg-m249; root dependencies and lockfile are unchanged fromv1.x. The audit gate remains enabled.Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.