fix(dev): support multiple A2A runtime ports#1818
Conversation
Package TarballHow to installgh release download pr-1818-tarball --repo aws/agentcore-cli --pattern "*.tgz" --dir /tmp/pr-tarball
npm install -g /tmp/pr-tarball/aws-agentcore-0.24.1.tgz |
|
Claude Security Review: no high-confidence findings. (run) |
Coverage Report
|
agentcore-cli-automation
left a comment
There was a problem hiding this comment.
LGTM. The port allocation change is well-structured and consistent across the four entry points (CLI --logs, TUI hook, web-UI handleStart, and invoke). A few observations from the review, none blocking:
- Container A2A works standalone (the
9001:9000port mapping is done at the Docker layer), but CodeZip A2A depends on aws/bedrock-agentcore-sdk-python#593 to actually honorPORT. Worth double-checking that PR merges before/with this one is released widely, otherwise users on the current SDK will see the CLI report port 9001 while the server still binds to 9000. - The invoke flow now recomputes
getDevPorton the client side and uses that to reach the server. If a server auto-shifted off the index-derived port (e.g., 9001 was taken → bound to 9002), invoke against the second A2A runtime will fail the same way it does for HTTP today. Pre-existing behavior for HTTP, but new for A2A. Not blocking. getDevPorttests only cover A2A and MCP; a couple of HTTP / null-project cases would round it out, butgetAgentPortalready has that coverage so it's fine.
No new telemetry needed — agent_protocol is already recorded on the existing cli.command_run emissions. Tests reuse the established spawn/fs mocks at true I/O boundaries. Approving.
jariy17
left a comment
There was a problem hiding this comment.
Pretty good just need some changes.
| `Port ${fixedPort} is in use. ${config.protocol} agents require port ${fixedPort}.` | ||
| ); | ||
| const actualPort = await findAvailablePort(targetPort); | ||
| if (isMcp && actualPort !== targetPort) { |
There was a problem hiding this comment.
Now, A2A startup could shift from 9000 to 9001. A later agentcore dev --runtime "" recomputes the original port and still targets 9000. That can fail or send the prompt to the wrong local process. Can we still fail fast?
| if (agentBasePort !== undefined && agentName === selectedAgent) { | ||
| return agentBasePort; | ||
| } | ||
| if (protocol === 'A2A') return A2A_DEFAULT_PORT + safeIndex; |
There was a problem hiding this comment.
with one A2A runtime, agentcore dev --port 9100 falls through here and uses 9000. browser mode only sets selectedAgent when --runtime is provided, even though the only runtime is implicitly selected.
can we default selectedAgent to the sole supported runtime?
selectedAgent:
agentName ?? (supportedAgents.length === 1 ? supportedAgents[0]?.name : undefined)
| @@ -120,14 +122,11 @@ async function doStartAgent( | |||
| const agentIndex = ctx.options.agents.findIndex(a => a.name === agentName); | |||
There was a problem hiding this comment.
ctx.options.agents contains only dev-supported agents, but getDevPort() calculates the offset from the full project.runtimes list. if an unsupported runtime appears before an A2A runtime, browser mode assigns 9000 while terminal mode assigns 9001.
Can we carry the original runtime index into AgentInfo or reuse the shared port resolver here? we should also add a test with an unsupported runtime before the A2A runtime.
Summary
9000 + runtime index, while honoring an explicit--portfor the selected runtime.PORTandAGENTCORE_RUNTIME_URLto CodeZip A2A processes.Closes #1657.
SDK dependency
Container A2A runtimes work independently because each container still binds internally to
9000. CodeZip A2A runtimes require aws/bedrock-agentcore-sdk-python#593 soserve_a2ahonors the CLI-providedPORT; that PR is stacked on the A2A v1 migration in aws/bedrock-agentcore-sdk-python#591.Agent Inspector requires no change: it routes start, invocation, and agent-card requests through the CLI backend by agent name, and the backend stores each runtime's resolved port.
Testing
npm run buildnpm test(415 files, 5,980 tests passed)npm run typechecknpm run lint -- --no-cache(no errors; existing warnings only)