Skip to content

fix(scaffold): allow certain template values to be overriden - #2130

Open
Hweinstock wants to merge 2 commits into
aws:refactorfrom
Hweinstock:feat/allow-flag-overrides
Open

fix(scaffold): allow certain template values to be overriden#2130
Hweinstock wants to merge 2 commits into
aws:refactorfrom
Hweinstock:feat/allow-flag-overrides

Conversation

@Hweinstock

@Hweinstock Hweinstock commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Problem

Not all template fields that we'd expect to be able to overwrite are able to be overwritten. For example, in the create flow runtimeName is fixed since passing runtimeName + template is invalid.

Solution

Testing

  • unit tests
> agentcore project create --template strands-python --runtimeName bob --name testP 

{
  "name": "testP",
  "version": 1,
  "managedBy": "CDK",
  "runtimes": [
    {
      "name": "bob",
      "build": "CodeZip",
      "entrypoint": "main.py",
      "codeLocation": "app/bob",
      "runtimeVersion": "PYTHON_3_14",
      "protocol": "HTTP"
    }
  ]
}

> agentcore project deploy 
...

went to console and verified the name is now generated from bob with name testP_bob.

@github-actions github-actions Bot added size/m PR size: M and removed size/m PR size: M labels Aug 27, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added agentcore-harness-reviewing AgentCore Harness review in progress claude-security-reviewing Claude Code /security-review in progress labels Aug 27, 2026
@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label Aug 27, 2026
@codecov-commenter

codecov-commenter commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.22%. Comparing base (2595b9d) to head (c9761e1).
⚠️ Report is 5 commits behind head on refactor.

Additional details and impacted files
@@            Coverage Diff            @@
##           refactor    #2130   +/-   ##
=========================================
  Coverage     97.22%   97.22%           
=========================================
  Files           463      464    +1     
  Lines         28160    28203   +43     
=========================================
+ Hits          27378    27421   +43     
  Misses          782      782           

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

@agentcore-devx-automation agentcore-devx-automation Bot removed the agentcore-harness-reviewing AgentCore Harness review in progress label Aug 27, 2026

@agentcore-devx-automation agentcore-devx-automation Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AgentCore Harness Review

Verdict: Looks good

Nice refactor. Moving RUNTIME_TEMPLATE_SHORTCUTS and the new resolveRuntimeTemplateShortcut into their own shortcuts.ts cleans up types.ts, and the "compatible flag overrides" semantics are consistent between create and add runtime.

A few things I verified while reviewing:

  • The --build override path spreads runtimeVersion: undefined when switching a CodeZip template to Container, which correctly clears the template's PYTHON_3_14 and satisfies ScaffoldRuntimeInputSchema.superRefine (Container must not have a runtimeVersion). Going the other way (Container template + --build CodeZip) sets PYTHON_3_14, also validated.
  • language and framework remain locked when a template is chosen, which is the right call since the template asset tree is keyed on ${framework}/${language} in runtime.ts.
  • apiKey override with a Bedrock template correctly falls through to the schema's cross-field refine, and the new test covers this.
  • In add/runtime, always forcing runtimeName: flags.name in the template branch is a behavior change from the previous hard-coded hello_world/strands_agent, but it matches how the resource name is already used downstream (codeLocation: app/${name}) and how the non-template branch behaves.

No new user-facing surface, so no new telemetry needed. No excessive mocking — the new tests operate on real temp directories through the handler.

Nothing blocking; feel free to merge.

@Hweinstock

Copy link
Copy Markdown
Contributor Author

No new user-facing surface, so no new telemetry needed

I think we might need to adjust its prompt. I can take a look.

@Hweinstock
Hweinstock marked this pull request as ready for review August 27, 2026 20:25

@notgitika notgitika left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Very easy to follow through PR I just added one comment about build also becoming a locked param imo lmk what you think

Comment on lines +112 to 137
const lockedFlag = (["language", "framework"] as const).find(
(flagName) => flags[flagName] !== undefined,
);
if (isTemplate && lockedFlag) {
throw new InputValidationError(`--${lockedFlag} cannot override a template`);
}

const isCustom = presentScaffoldingFlags.length > 0;

const source = new SourceResolver({ stdin: config.io.stdin });
const apiKey = await source.resolveSecret("api-key", flags["api-key"]);

const scaffoldRuntimeInput = isTemplate
? RUNTIME_TEMPLATE_SHORTCUTS[flags.template!]
? resolveRuntimeTemplateShortcut(flags.template!, {
runtimeName: flags.name,
...(flags.build !== undefined && {
build: flags.build,
runtimeVersion: flags.build === "CodeZip" ? "PYTHON_3_14" : undefined,
}),
...(flags["model-provider"] !== undefined && {
modelProvider: flags["model-provider"],
}),
...(apiKey !== undefined && { apiKey }),
...(flags.memory !== undefined && { memory: flags.memory }),
})
: isCustom

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

OOS for your PR but would we see any value in making a shared component for the shared functionality b/w create and runtime?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

YES! I'm hoping to come back to this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

wait why are adding the build override? shouldn't that also belong to the "locked" param?

for eg: strands-python template can be override to container but the generated files won't contain Dockerfile, while the agentcore.json config would reference one.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The build override should work since its passed as a parameter to the template. I haven't wired up container support for the strands-python one yet, so if its not rejecting that's a bug.

Update: it is a bug, let me just fix that here.

@github-actions github-actions Bot added size/m PR size: M and removed size/m PR size: M labels Aug 27, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Aug 27, 2026
@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

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

Labels

size/m PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants