Skip to content

fix(cli-integ): pin the AgentCore hotswap test runtime to platformVersion:V1 - #2198

Merged
aws-cdk-automation merged 1 commit into
mainfrom
sai/pin-agentcore-runtime-v1
Dec 3, 2026
Merged

aws-cdk-automation merged 1 commit into
mainfrom
sai/pin-agentcore-runtime-v1

Conversation

@sai-ray

@sai-ray sai-ray commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Addresses #2185

The integ test hotswap deployment supports Bedrock AgentCore Runtime fails on its first deploy with this error:

Agent runtime creation failed with status: CREATE_FAILED for runtime: test_runtime-XXXXXXXXXX.
Reason: The agent must remain running and respond to health requests for the lifetime of the session.
(HandlerErrorCode: NotStabilized)

The test's Dockerfile is a single line, FROM public.ecr.aws/docker/library/alpine:latest. Alpine's default command is /bin/sh, so the container starts a shell and exits with code 0.

  • On platform version V1: AgentCore starts the container on the first InvokeAgentRuntime call. The test never invokes the runtime, so the container never runs and the create succeeds.
  • On platform version V2: AgentCore starts the container while the runtime is CREATING and sets CREATE_FAILED if the health check doesn't pass (docs). With this image, the container exits, the health check fails, and CloudFormation reports NotStabilized.

The test doesn't set platformVersion. The docs say V1 is the default, but deploying this stack without platformVersion returned platformVersion: V2 from GetAgentRuntime in eu-west-1 and `platformVersion: V2' in us-east-1. The test runs in one of nine regions, so the failure looks intermittent.

This PR sets platformVersion: 'V1' on the test's CfnRuntime. The test checks that the CLI hotswaps a runtime's description and environment variables. The CLI hotswaps AWS::BedrockAgentCore::Runtime with Cloud Control UpdateResource (hotswap-deployments.ts), and toolkit-lib has no code that reads platformVersion. So the pin doesn't change what the test covers.

Testing

Deployed the test's stack in eu-west-1 manually.

  • Without platformVersion: GetAgentRuntime returned platformVersion: V2, and the create failed with the NotStabilized error above.
  • With platformVersion: 'V1': GetAgentRuntime returned platformVersion: V1, and the create completed in 8 seconds. cdk deploy --hotswap with a new description and environment variable printed hotswapped!. The stack status stayed CREATE_COMPLETE, and GetAgentRuntime returned the new description and environment variable.

Checklist

  • This change contains a major version upgrade for a dependency and I confirm all breaking changes are addressed
    • Release notes for the new version:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@sai-ray
sai-ray requested a review from a team December 3, 2026 00:18
@sai-ray
sai-ray deployed to automation December 3, 2026 00:18 — with GitHub Actions Active
@github-actions github-actions Bot added the p2 label Dec 3, 2026
@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@maintainer-for-aws

Copy link
Copy Markdown

Automated review

A maintainer will still review this — treat the notes below as a starting point.

📌 Commit 9f2e4ef

This PR tries to fix the intermittent first-deploy failure of the hotswap deployment supports Bedrock AgentCore Runtime integ test (#2185). It pins the test's CfnRuntime to platformVersion: 'V1' so the runtime no longer depends on the service default. The change is small and doesn't affect what the CLI hotswap path exercises. The fix rests on the claim that an unpinned runtime can default to V2, and that claim contradicts the AgentCore developer guide. Until the two are brought into line, it isn't clear the pin addresses the root cause.

Open findings: 🔴 0 blocking · 🟡 1 recommended · ⚪ 0 optional.

Files with findings (1)
File Findings
packages/@aws-cdk-testing/cli-integ/resources/cdk-apps/app/app.js 🟡 1

Generated automatically. React 👍 or 👎 to tell us whether this review helped, so we can improve these reviews.

@maintainer-for-aws maintainer-for-aws Bot 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.

See the review summary comment for the overview; the notes below are inline.


const runtime = new bedrockagentcore.CfnRuntime(this, 'Runtime', {
agentRuntimeName: 'test_runtime',
platformVersion: 'V1',

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Recommended — This fix assumes a CfnRuntime created without platformVersion can come up as V2. Per the PR, V2 starts the single-line Alpine container during CREATING, the container exits, and the health check fails. The AgentCore developer guide says the opposite: "If you omit platformVersion when you create a runtime, the runtime uses V1" (runtime-how-it-works). The PR cites no source for a V2 default, and it is unclear whether the docs or the service behavior it describes is current. If the docs are right, this line changes nothing and the NotStabilized failure in #2185 has another cause. The issue lists several: a slow first pull from public ECR, AgentCore-side stabilization, IAM propagation, and the AccessDenied on logs:CreateLogGroup. This PR rules out none of them.

Suggested change: Bring the PR's premise and the documented behavior into line. If the service really defaults to V2 in some regions or accounts, cite a source in the PR so reviewers can see the pin targets the real cause (the developer guide would then need correcting). If the docs are current, treat the root cause of #2185 as still open and don't present the pin as the fix. Either way, a fixture image that serves the AgentCore HTTP contract (GET /ping, POST /invocations on :8080), like the aws-cdk V2 integ fixtures, would make the test pass on both platform versions.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.55%. Comparing base (66286b8) to head (9f2e4ef).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2198   +/-   ##
=======================================
  Coverage   92.55%   92.55%           
=======================================
  Files          81       81           
  Lines       13224    13224           
  Branches     1917     1917           
=======================================
  Hits        12240    12240           
  Misses        946      946           
  Partials       38       38           
Flag Coverage Δ
suite.unit 92.55% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@aws-cdk-automation
aws-cdk-automation added this pull request to the merge queue Dec 3, 2026
Merged via the queue into main with commit bec3768 Dec 3, 2026
50 checks passed
@aws-cdk-automation
aws-cdk-automation deleted the sai/pin-agentcore-runtime-v1 branch December 3, 2026 05:58

This branch was successfully deployed

1 active and 2 inactive deployments
run-tests — 9f2e4ef2 Deployed Dec 3, 2026 by sai-ray via integ_init-templates (init-python, 24.19) #7836
no-approval — 9f2e4ef2 Deployed Dec 3, 2026 by sai-ray via prepare #7836
automation — 9f2e4ef2 Deployed Dec 3, 2026 by sai-ray via Set AutoQueue on PR #2198 #4075
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants