Skip to content

fix(#907): default new agents to PYTHON_3_13 to avoid CloudFormation rejection#1172

Open
aidandaly24 wants to merge 3 commits intomainfrom
fix/907-a15ec7fe
Open

fix(#907): default new agents to PYTHON_3_13 to avoid CloudFormation rejection#1172
aidandaly24 wants to merge 3 commits intomainfrom
fix/907-a15ec7fe

Conversation

@aidandaly24
Copy link
Copy Markdown
Contributor

Description

Fixes the bug reported in #907: the CLI defaulted new agents to PYTHON_3_14,
which CloudFormation rejects with AWS::EarlyValidation::PropertyValidation
in regions other than us-west-2 / us-east-1. The resulting Change Set
fails immediately and leaves the stack stuck in REVIEW_IN_PROGRESS,
requiring manual stack deletion to recover.

Root cause

DEFAULT_PYTHON_VERSION in src/schema/constants.ts was set to PYTHON_3_14,
so any new project created via agentcore add agent (and any consumer that
falls back to the default — e.g. schema-mapper.ts, lib/packaging/python.ts,
lib/packaging/index.ts) baked an unsupported runtime into agentcore.json.

Fix (minimal)

  • Change DEFAULT_PYTHON_VERSION from PYTHON_3_14PYTHON_3_13.
  • Keep PYTHON_3_14 in PythonRuntimeSchema so users in supported regions
    (us-west-2 / us-east-1) can still opt in explicitly.
  • Add JSDoc on both PythonRuntimeSchema and DEFAULT_PYTHON_VERSION that
    references issue PYTHON_3_14 runtime accepted by CLI but rejected by CloudFormation #907 and documents why the default deliberately lags the
    newest enum entry.

Tests

  • New DEFAULT_PYTHON_VERSION (issue #907) describe block in
    src/schema/__tests__/constants.test.ts:
    • asserts the default is PYTHON_3_13 (and not PYTHON_3_14)
    • asserts the default is a valid member of PythonRuntimeSchema
    • asserts PYTHON_3_14 is still accepted as an explicit opt-in
    • regression invariant: the default must NOT equal the newest entry in
      PythonRuntimeSchema — prevents future lockstep bumps from re-opening PYTHON_3_14 runtime accepted by CLI but rejected by CloudFormation #907
  • Updated src/cli/operations/agent/generate/__tests__/schema-mapper.test.ts
    to assert against DEFAULT_PYTHON_VERSION (also pinning the literal
    'PYTHON_3_13' for clarity), exercising the consumer path that produces
    the agentcore.json runtime field.

A companion PR in aws/agentcore-l3-cdk-constructs
on branch fix/907-a15ec7fe applies the same default change to
DEFAULT_MCP_PYTHON_VERSION.

Related Issue

Closes #907

Documentation PR

N/A — no user-facing documentation change required. The behavior change is a
default-value adjustment with explanatory JSDoc added in source.

Type of Change

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

Testing

How have you tested the change?

  • I ran npm run test:unit and npm run test:integ
  • I ran npm run typecheck
  • I ran npm run lint
  • If I modified src/assets/, I ran npm run test:update-snapshots and committed the updated snapshots

Targeted runs:

npx vitest run --project unit \
  src/cli/operations/agent/generate/__tests__/schema-mapper.test.ts \
  src/schema/__tests__/constants.test.ts
# Test Files  2 passed (2)
#      Tests  80 passed (80)

npm run typecheck runs clean.

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the
terms of your choice.

agentcore-bot added 3 commits May 7, 2026 19:44
- Restore deleted unrelated tests in src/schema/__tests__/constants.test.ts
  (matchEnumValue, SDKFrameworkSchema, ModelProviderSchema, etc.) that were
  accidentally overwritten when the new DEFAULT_PYTHON_VERSION test was
  introduced. New tests are now appended, not replacing.
- Add comments to PythonRuntimeSchema and DEFAULT_PYTHON_VERSION explaining
  why PYTHON_3_14 is kept in the enum (supported in us-west-2/us-east-1)
  but not the default (issue #907 / CFN rejection in other regions).
- Note: secretlint version in package.json was not modified by this PR
  (^12.2.0 is already on origin/main); no change needed.
- Update schema-mapper.test.ts to assert against DEFAULT_PYTHON_VERSION
  (resolves stale 'PYTHON_3_14' assertion that would have broken CI).
- Add regression invariants to constants.test.ts:
  * DEFAULT_PYTHON_VERSION must not equal the newest entry in
    PythonRuntimeSchema (prevents future lockstep bumps from re-opening #907).
  * PYTHON_3_14 still accepted as explicit opt-in (documents intent).
@aidandaly24 aidandaly24 requested a review from a team May 7, 2026 19:44
@github-actions github-actions Bot added size/s PR size: S agentcore-harness-reviewing AgentCore Harness review in progress labels May 7, 2026
Copy link
Copy Markdown

@agentcore-cli-automation agentcore-cli-automation left a comment

Choose a reason for hiding this comment

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

Approving — the fix is minimal, targeted, and well-justified.

Verified locally:

  • DEFAULT_PYTHON_VERSION is the single source of truth for the default Python runtime across the CLI: it's re-exported from src/cli/tui/screens/{agent,generate,mcp}/*, used in AddAgentScreen.tsx (3 call sites), GatewayTargetPrimitive.ts (MCP creation), schema-mapper.ts, and both packaging paths (lib/packaging/python.ts, lib/packaging/index.ts). Flipping the constant fixes all of these in one shot.
  • PYTHON_3_14 remains a valid enum member of PythonRuntimeSchema, so users in us-west-2 / us-east-1 who set it explicitly still work. The new JSDoc explains this well.
  • The existing tests that exercise PYTHON_3_14 (e.g. lib/packaging/__tests__/python.test.ts, schema/schemas/__tests__/agent-env.test.ts) only verify enum membership or version-string extraction, so they're unaffected by the default change.
  • The AGENTS.md / snapshot documentation enumerates all valid runtimes (not the default), so no snapshot update is needed.

No issues worth blocking on.

Out of scope for this PR (just flagging for tracking, not requesting changes):

  • DEFAULT_MCP_PYTHON_VERSION in aws/agentcore-l3-cdk-constructs is still PYTHON_3_14. That only matters for consumers who use the CDK constructs directly (without the CLI); the CLI's MCP path in GatewayTargetPrimitive.ts passes DEFAULT_PYTHON_VERSION explicitly, so CLI users are fine. The companion PR mentioned in the description should still land to close the gap for direct-CDK users.
  • PYTHON_VERSION_OPTIONS in src/cli/tui/screens/mcp/types.ts still labels PYTHON_3_14 as 'Latest' and lists it first — but it's currently unused, so harmless.

@github-actions github-actions Bot removed the agentcore-harness-reviewing AgentCore Harness review in progress label May 7, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 43.19% 9034 / 20915
🔵 Statements 42.47% 9592 / 22585
🔵 Functions 40.02% 1558 / 3893
🔵 Branches 40% 5811 / 14527
Generated in workflow #2648 for commit 7d2c584 by the Vitest Coverage Report Action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/s PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PYTHON_3_14 runtime accepted by CLI but rejected by CloudFormation

2 participants