feat(dev): positional prompt arg for invoking dev server#707
Merged
Hweinstock merged 7 commits intoaws:mainfrom Mar 27, 2026
Merged
feat(dev): positional prompt arg for invoking dev server#707Hweinstock merged 7 commits intoaws:mainfrom
Hweinstock merged 7 commits intoaws:mainfrom
Conversation
Replace `agentcore dev --invoke "Hello"` with `agentcore dev "Hello"`. The dev command now accepts an optional positional [prompt] argument that invokes a running dev server directly. The --invoke/-i flag is removed entirely — this is a breaking change for scripts using it. Rejected: keep --invoke as deprecated alias | adds UX confusion with two ways to do the same thing Confidence: high Scope-risk: narrow
Contributor
Package Tarballaws-agentcore-0.3.0-preview.9.0.tgz How to installnpm install https://github.com/aws/agentcore-cli/releases/download/pr-707-tarball/aws-agentcore-0.3.0-preview.9.0.tgz |
vivdalal
previously approved these changes
Mar 27, 2026
When running `agentcore dev "Hello"`, the CLI now automatically starts a dev server if none is running, invokes it, and shuts it down after. If a server is already running (via --logs or TUI), it reuses it. - Export waitForServerReady from dev operations barrel - Probe target port before invoking; auto-start if nothing listening - Use Promise.race to bail early if server crashes during startup - Silent startup (no "Starting dev server..." output) - Helpful error when outside project with no server running - Update tests, docs, and command descriptions Constraint: Must not add latency when server is already running Rejected: Always require separate terminal for dev server | poor UX parity with agentcore invoke Confidence: high Scope-risk: narrow
Fixes found during bugbash of auto-start feature:
- Register process.on('exit') handler to kill auto-started server,
ensuring cleanup even when invoke helpers call process.exit(1)
- Initialize resolveServerExit with safe default to prevent
potential undefined call if Promise executor changes
- Add unref() to SIGKILL timer in DevServer.kill() so Node.js
exits promptly instead of hanging 2 seconds
- Use !== undefined check for prompt so empty string "" enters
invoke path instead of falling through to interactive TUI
Constraint: process.on('exit') handlers are synchronous; cannot await server shutdown
Rejected: Modify invoke helpers to throw instead of process.exit | too many callers to change
Confidence: high
Scope-risk: narrow
Not-tested: rapid consecutive invocations (port TIME_WAIT race)
After the TCP port probe finds something listening, do a lightweight HTTP GET to the endpoint. If the response is HTML (text/html), the server is not an agentcore dev server — show a clear error instead of sending a POST and dumping raw HTML as the error message. Constraint: Cannot add a /health endpoint without modifying all Python agent templates Rejected: HEAD request probe | some servers return different headers for HEAD vs GET Confidence: high Scope-risk: narrow
- Spawn child processes with detached:true and kill the entire process group (-pid) to clean up uvicorn workers and other grandchild processes on shutdown - Fix SIGKILL fallback that never fired: child.killed is set when the signal is sent, not when the process exits. Use child.exitCode to check actual termination. - Add explicit SIGINT handler in auto-start invoke path so Ctrl+C kills the server before Node exits - Improve port identity probe: detect non-HTTP processes (e.g., raw TCP listeners) by treating probe failures as port conflicts instead of silently falling through - Guard kill() in finally block with try-catch and remove exit listener to prevent leaks Constraint: process.kill(-pid) requires detached:true so child is its own process group leader Rejected: child.killed for exit check | set on signal send, not on actual termination Rejected: process.exit(130) in SIGINT handler | kills Node before child cleanup completes Confidence: high Scope-risk: moderate Not-tested: SIGINT during waitForServerReady phase (before invoke starts)
Reverts the detached:true, process group kill, and exitCode changes from dev-server.ts. These affected all dev server modes (TUI, --logs, auto-start) but were only needed for an edge case in auto-start SIGINT cleanup. Too much blast radius for the benefit. The command.tsx fixes (port probe, SIGINT handler, exit listener cleanup) remain — they are scoped to the invoke path only.
…ssages Remove auto-start logic from the invoke path. Users must now start the dev server in a separate terminal with `agentcore dev --logs` before invoking with `agentcore dev "prompt"`. Improve connection error detection by adding isConnectionRefused() helper that checks ConnectionError name, cause chain, and common fetch failure messages instead of only checking err.message for ECONNREFUSED. Constraint: Node fetch wraps ECONNREFUSED in TypeError cause chain Rejected: Auto-start server on invoke | orphaned processes, complexity Confidence: high Scope-risk: narrow
Hweinstock
approved these changes
Mar 27, 2026
15 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a positional
[prompt]argument toagentcore devso users can invoke a running dev server with natural CLI syntax:Key changes:
[prompt]argument replaces the hidden--invokeflagisConnectionRefused()helper — properly handles Node'sTypeError: fetch failed→ECONNREFUSEDcause chain and theConnectionErrorwrapper from invoke.ts"Dev server not running on port 8080"+"Start it with: agentcore dev --logs"Related Issue
Closes #8
Type of Change
Testing
How have you tested the change?
npm run test:unitandnpm run test:integnpm run typechecknpm run lintsrc/assets/, I rannpm run test:update-snapshotsand committed the updated snapshotsManual E2E testing performed:
--logsstarts dev server → server listening--streaminvoke → streamed response-Hheaders → forwarded correctlydevwithout prompt outside project → requireProject guard fires--help→ correct descriptionsChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the
terms of your choice.