Skip to content

feat(dev): use deployed resources in local runtimes - #2586

Closed
notgitika wants to merge 1 commit into
aws:refactorfrom
notgitika:feat/dev-deployed-resource-env
Closed

notgitika wants to merge 1 commit into
aws:refactorfrom
notgitika:feat/dev-deployed-resource-env

Conversation

@notgitika

@notgitika notgitika commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Description

Makes agentcore dev populate the v0-compatible resource discovery variables for local runtimes:

  • MEMORY_<NAME>_ID
  • AGENTCORE_GATEWAY_<NAME>_URL and _AUTH_TYPE
  • eligible Python HTTP runtimes' AGENTCORE_PAYMENT_<NAME>_* values

For translated v0 projects, values come from the selected target in agentcore/.cli/deployed-state.json. This includes resources that remain deployed in state after being removed from agentcore.json, matching v0 behavior. For native v1 projects, values are resolved from the deployed CloudFormation stack outputs.

--target selects the deployment whose resources local dev should use. Without it, the default target or the sole configured target is selected; multiple non-default targets require an explicit choice. The selected target is authoritative for AWS_REGION and AWS_DEFAULT_REGION.

Runtime env declarations are the base, deployed values override them, and .env.local can override resource discovery values. Target region remains authoritative. Conflicting resource names that normalize to the same environment key fail instead of selecting an arbitrary value.

Inspector mode refreshes deployed resource values on every agent start attempt, matching v0 browser behavior. Concurrent multi-agent starts share one in-flight resolution.

This builds on merged #2575. It uses the naming contract restored by aws/agentcore-l3-cdk-constructs#418 and the generated memory lookup change in #2583 rather than duplicating either. It also implements the refactor equivalent of #2439; that PR targets the removed src/cli architecture on main.

Related to #1457.

Intentional differences from v0

  • v0 combines every deployment target with last-write-wins behavior. v1 selects one unambiguous target.
  • v0 silently drops resource variables when deployed state cannot be read. v1 surfaces actionable errors.
  • Native v1 reads stack outputs from CloudFormation because its local state stores the stack reference rather than every deployed value.
  • Payment variables are limited to runtime types supported by the v1 CDK contract.

Datasets and knowledge bases are not included because v0 agentcore dev does not export local discovery variables for them.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Testing

  • Affected suites — 266 passed
  • bun run typecheck
  • bun run lint:check
  • bun run format:check
  • bun run build
  • bun run secrets:check

The full local suite completed with 4,107 passing and one environment-only failure: the workstation install is missing the optional @napi-rs/keyring Linux native binding used by scripts/keyring.test.ts. The affected suites pass, and the prior PR revision passed Linux, Windows, macOS, CodeQL, and e2e CI.

bun audit reports the repository's existing transitive braces@3.0.3 advisory. This PR does not change dependencies or bun.lock.

Checklist

  • I have read the CONTRIBUTING document
  • I added tests for v0 state, state-only deployed resources, v1 stack outputs, target selection, refresh behavior, precedence, payment eligibility, and normalized-name collisions
  • I regenerated the relevant agentcore dev command reference
  • My changes generate no new warnings

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

@github-actions github-actions Bot added the size/xl PR size: XL label Oct 13, 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 Oct 13, 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 Oct 13, 2026
@codecov-commenter

codecov-commenter commented Oct 13, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.63602% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.31%. Comparing base (b77f1fa) to head (0ce88de).
⚠️ Report is 1 commits behind head on refactor.

Files with missing lines Patch % Lines
src/core/project/manager.tsx 10.00% 9 Missing ⚠️
src/handlers/project/dev/index.ts 92.98% 4 Missing ⚠️
src/core/project/backends/cdk/devEnvironment.ts 99.38% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           refactor    #2586      +/-   ##
============================================
- Coverage     96.32%   96.31%   -0.02%     
============================================
  Files           671      672       +1     
  Lines         51273    51528     +255     
============================================
+ Hits          49390    49629     +239     
- Misses         1883     1899      +16     

☔ 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 added agentcore-harness-reviewing AgentCore Harness review in progress and removed agentcore-harness-reviewing AgentCore Harness review in progress labels Oct 13, 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, focused change. The v0-state-first / CFN-outputs-fallback split in projectDevEnvironment, the writer() collision detection, and the entrypoint-based supportsPayments gate are all well tested. A few things I verified while reading, not blocking:

  • paymentId() in src/core/project/backends/cdk/devEnvironment.ts matches cdkId() in cdk.ts (both strip _), so CFN output-key lookups like Payment${paymentId(name)}ManagerArn stay in sync with how the stack writes them.
  • resolveDevEnvironment correctly skips describeStack for v0 projects and for v1 projects without a stackReference, so a never-deployed target just returns {}.
  • The region precedence change in src/handlers/project/dev/environment.ts is intentional: input.region (from the selected target) now overrides AWS_REGION from .env. Worth flagging in release notes since it's a behavior change for users relying on .env to set region during dev, but it's consistent with the feature intent.
  • supportsPayments only treats runtimes with a .py entrypoint (and HTTP/undefined protocol) as payment-capable. TS/JS runtimes silently drop AGENTCORE_PAYMENT_* vars even if payments are declared — the test covers this, and the behavior matches the Python-only payments SDK, but it would be nice to surface a hint to the user when payments are declared but suppressed.

Looks good to merge.

@agentcore-devx-automation agentcore-devx-automation Bot removed the agentcore-harness-reviewing AgentCore Harness review in progress label Oct 13, 2026
@notgitika
notgitika force-pushed the feat/dev-deployed-resource-env branch from 371b5f8 to 0ce88de Compare October 13, 2026 19:20
@github-actions github-actions Bot added size/l PR size: L and removed size/xl PR size: XL size/l PR size: L labels Oct 13, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Oct 13, 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 Oct 13, 2026
@notgitika

Copy link
Copy Markdown
Contributor Author

to be discussed post release

@notgitika notgitika closed this Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/l PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants