Skip to content

feat(project): add project-aware invoke - #2115

Merged
aidandaly24 merged 22 commits into
aws:refactorfrom
aidandaly24:feat/project-aware-invoke
Aug 31, 2026
Merged

feat(project): add project-aware invoke#2115
aidandaly24 merged 22 commits into
aws:refactorfrom
aidandaly24:feat/project-aware-invoke

Conversation

@aidandaly24

@aidandaly24 aidandaly24 commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Description

Add project-aware invocation for Runtimes and Harnesses declared by the project enclosing the current directory.

  • add agentcore project invoke as an interactive picker for deployed project Runtimes and Harnesses on the default target
  • add explicit headless child commands:
    • agentcore project invoke runtime --name <name> --payload <payload>
    • agentcore project invoke harness --name <name> --prompt <prompt>
  • allow --name to be omitted when the project declares exactly one resource of that type
  • resolve logical project names to deployed physical IDs and regions through the selected deployment target and live CloudFormation stack
  • preserve the existing Runtime payload, content-type, response, output-file, and JSON behavior
  • preserve the existing Harness prompt, session, transcript, and chat behavior
  • reuse the Runtime and Harness invoke operations and TUI consoles instead of adding a third transport or presentation path
  • document project invoke in the CLI and generated Runtime templates

This PR intentionally does not define a project-specific Runtime payload or response contract. Runtime responses retain the existing raw invoke behavior, including raw SSE. Gateway project invoke remains outside this scope.

The project deployment prerequisites are already present on refactor:

Related Issue

N/A

Documentation PR

N/A - documentation is included.

Type of Change

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

Testing

  • bun test src: 2560 pass, 0 fail
  • focused project invoke/menu/CDK stack suites: 70 pass, 0 fail
  • bun run typecheck
  • bun run lint:check
  • bun run format:check
  • bun run secrets:check
  • bun run build
  • git diff --check

Live verification in account 603141041947, region us-west-2, using the retained InvokeMatrix827 project:

  • Runtime headless invoke omitted --name, preserved the native raw SSE response, and returned REBASED_RUNTIME_OK
  • Harness headless invoke omitted --name, preserved the transcript response, and returned REBASED_HARNESS_OK
  • the 120x40 TUI harness listed only deployed project Runtime and Harness resources
  • an undeployed project showed one deployment error with no selectable configured resources
  • Runtime selection opened the existing endpoint picker and JSON console
  • Harness selection opened the existing chat
  • Escape returned from both embedded consoles to the project picker without leaving the TUI process
  • Escape returned from the project invoke picker and its error state to the project command menu

Checklist

  • I have added tests that prove the feature works
  • I have updated relevant documentation
  • I have verified direct Runtime and Harness behavior remains green
  • I have run live deployment and TUI verification
  • Dependent changes have been merged and published

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

codecov-commenter commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.92058% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.14%. Comparing base (8ac7702) to head (fde1e27).

Files with missing lines Patch % Lines
src/handlers/project/invoke/screen.tsx 97.12% 5 Missing ⚠️
src/handlers/project/invoke/runtime.tsx 97.14% 4 Missing ⚠️
src/handlers/project/invoke/selection.ts 85.71% 4 Missing ⚠️
src/handlers/project/invoke/index.tsx 87.50% 3 Missing ⚠️
src/core/project/backends/cdk.ts 96.66% 2 Missing ⚠️
src/handlers/project/invoke/harness.tsx 98.36% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           refactor    #2115      +/-   ##
============================================
- Coverage     97.15%   97.14%   -0.01%     
============================================
  Files           498      505       +7     
  Lines         33004    33555     +551     
============================================
+ Hits          32065    32597     +532     
- Misses          939      958      +19     

☔ 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 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 split: the shared invokeRuntimeTarget / invokeHarnessTurn helpers cleanly refactor the existing handlers into reusable operations, the new project-level invoke composes those without duplication, and the resolveDeployedResource layering (manager → backend → deployment helpers) is easy to follow. Tests use real temp dirs + fake backends, and only mock at true I/O boundaries (readStack, per the guidelines).

One thing worth double-checking before this fully lights up end-to-end:

  • src/core/project/backends/cdk/deployment.ts:28 looks up harnesses by CloudFormation export name ${stackName}-Harness-${resourceName}-Id. Scanning agentcore-l3-cdk-constructs, the harness constructs (AgentCoreHarnessEnvironment, AgentCoreHarnessRole, AgentCoreApplication) currently only emit Harness-<name>-RoleArn and Harness-<name>-ImageUri outputs — no Harness-<name>-Id. Runtime lookup will work today (AgentEnvironment.ts emits <agentName>-RuntimeId), but agentcore invoke --harness ... will always fail with the "not deployed" error until the L3 emits that export. If a coordinated L3 change is in flight this is fine; if not, this handler and its export-name contract will need to land together with the construct change (and ideally the runtime path in AgentEnvironment.ts should probably also be prefixed like -Runtime-<name>-Id for symmetry with Harness-<name>-Id, but that's a naming choice).

Not blocking — tests all pass with a fake backend, and if the harness export is a known follow-up this is just a heads-up. Everything else (validation, mutual-exclusion, --json requiring content, session-id length rule, bearer-token restricted to runtime, TUI launch with inputMode: "prompt", region override from the resolved target) reads correctly.

@agentcore-devx-automation agentcore-devx-automation Bot removed the agentcore-harness-reviewing AgentCore Harness review in progress label Aug 26, 2026
@aidandaly24
aidandaly24 force-pushed the feat/project-aware-invoke branch from f2c164c to c6796be Compare August 26, 2026 22:02
@github-actions github-actions Bot added size/xl PR size: XL and removed size/xl PR size: XL labels Aug 26, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Aug 26, 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 26, 2026
@github-actions github-actions Bot added size/xl PR size: XL and removed size/xl PR size: XL labels Aug 26, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Aug 26, 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 26, 2026
@github-actions github-actions Bot added size/xl PR size: XL and removed size/xl PR size: XL 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)

@agentcore-devx-automation agentcore-devx-automation Bot removed 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)

@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

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

@AlexanderRichey AlexanderRichey 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.

How does invoke work today? Do customers have to specify runtime or harness?

@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

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

@Hweinstock Hweinstock 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.

Thanks for simplifying this one! Code looks good, few small things I noticed when playing around:

  • the back doesn't seem to work on the invoke page. When i got to project > invoke in the TUI then press esc, the TUI exits rather than goes back to the project commands.
  • I'm able to see resources that aren't yet deployed. if I click on them, I see, which isn't intuitive.
Image

Comment thread src/core/project/backends/cdk.test.ts Outdated
@@ -122,6 +127,7 @@ type HarnessOptions = {
bootstrapError?: Error;
/** Whether CloudFormation still holds the target's stack. Defaults to present. */
stackExists?: boolean;

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.

would it always be true that stackExists represents whether stack is present?

stack?: StackProbe;
resolveAccount?: AccountResolver;
loadBootstrapTemplate?: BootstrapTemplateLoader;
describeStack?: StackDescriber;

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.

what exactly is the difference between StackProbe and StackDescriber?

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.

StackProbe just returns a boolean whereas StackDescriber returns the full stack. But you're right that it doesn't make much sense to have both of them. They should just share the existing underlying CFN reader/client.

@@ -0,0 +1,48 @@
import type { CoreOptions } from "../../../core/types";

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.

is this still breaking the dependency inversion by importing core from handlers? I see Alex approved, so perhaps this is an acceptable exception.

Comment thread README.md Outdated
│ ├── get # get an evaluator by id (type-agnostic)
│ ├── list # list evaluators (server-side paginated)
│ └── delete # delete an evaluator by id
├── project # manage an AgentCore project

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.

thanks for adding all of this!

@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

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

@aidandaly24

Copy link
Copy Markdown
Contributor Author

Implemented the latest review feedback:

  • Esc from the project invoke picker and its error/loading states now routes back to the project command menu.
  • The picker resolves deployed resources in one bulk stack read and only lists Runtimes/Harnesses with deployed ID outputs.
  • Configured-but-undeployed resources are no longer selectable. An undeployed project now shows one focused deployment error instead.
  • Removed the separate StackProbe, stackExists, and duplicate CloudFormation read path. Teardown and invoke now use the same stack describer/client path.

Verified with the full source suite (2560 pass), focused project/CDK suites (70 pass), typecheck, lint, formatting, secrets, build, and live TUI runs for both deployed and undeployed projects.

Project invoke undeployed state after the fix

@Hweinstock Hweinstock 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.

LGTM, thanks for addressing comments.

Noticed two small things, that could be future improvements.

When going to invoke in the TUI with no deployed resoruces, I see

No deployment targets are configured for project 'helloThere'. Add at least one to /local/home/hkobew/gh-repos/agentcore-cli/helloThere/agentcore/aws-targets.json, for example:
[{ "name": "default", "account": "111122223333", "region": "us-east-1" }]

I wonder if this should show something like "no invokable resources" rather than deploy error.

Also, I don't think this is specific to this PR but the invoke "resolving project" hangs when used outside of a project.

Image

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

Labels

size/xl PR size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants