fix(cli): Add --endpoint <name> to agentcore invoke, thread it ... (#986, #1554)#39
Draft
aidandaly24 wants to merge 4 commits into
Draft
fix(cli): Add --endpoint <name> to agentcore invoke, thread it ... (#986, #1554)#39aidandaly24 wants to merge 4 commits into
--endpoint <name> to agentcore invoke, thread it ... (#986, #1554)#39aidandaly24 wants to merge 4 commits into
Conversation
agentcore invoke had no --endpoint flag and the SigV4 InvokeAgentRuntimeCommand was built without a qualifier, so named runtime endpoints (version aliases like prod/staging) could not be targeted and every SigV4 invoke silently hit DEFAULT. Register --endpoint on invoke, thread it through InvokeOptions -> resolve.ts (validated against project.runtimes[].endpoints and deployed runtimeEndpoints) -> action.ts, and set qualifier on both the streaming and non-streaming SigV4 commands in agentcore.ts. Fixes aws#986 Fixes aws#1554
Coverage Report
|
Resolve the invoke endpoint (--endpoint flag -> AGENTCORE_RUNTIME_ENDPOINT
env var -> DEFAULT) before the CLI-mode gate so a non-DEFAULT endpoint
forces CLI mode instead of silently dropping into the TUI and hitting
DEFAULT. Thread the resolved endpoint through the TUI flow (App route ->
InvokeScreen -> useInvokeFlow) into invokeAgentRuntimeStreaming so the
SigV4 qualifier reaches the SDK in TUI mode too.
Add endpoint_source ('flag' | 'env' | 'default') telemetry to InvokeAttrs
via a new EndpointSource enum and computeEndpointSource helper, threaded
through computeInvokeAttrs at both invoke entry points.
invokeAguiRuntime built InvokeAgentRuntimeCommand without a qualifier, so --endpoint was silently ignored for AGUI-protocol agents (routing to DEFAULT) — the same bug this PR fixes for HTTP/streaming. Add an endpoint field to AguiInvokeOptions, set the qualifier on the command, and thread the resolved endpoint through the CLI (action.ts) and TUI (useInvokeFlow.ts) AGUI call sites. Add qualifier tests for the AGUI path.
The endpoint regression test passed --json, which already forces CLI mode on its own, so it never exercised the new 'endpoint !== undefined' gate clause. Drop --json (and every other CLI flag) so the env-var-resolved endpoint is the ONLY trigger, and assert the action-layer 'No deployed targets found' error appears (not the TUI requireTTY guard). Verified the test fails when the gate clause is removed (routes to TUI) and passes with it.
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.
Refs aws#986
Refs aws#1554
Issues
agentcore invokehas no--endpointflag, so users who create named runtime endpoints (version aliases likeprod/stagingviaagentcore add runtime-endpoint) cannot target a specific endpoint from the CLI — invoke always hits the DEFAULT endpoint over SigV4. This is a missing-convenience feature gap, not a malfunction: a complete workaround exists today via--bearer-token(whose path already threads the endpoint qualifier) or by calling the API directly withqualifier.agentcore invoke --endpoint <name>aws/agentcore-cli#1554 —agentcore invokecan only ever hit a runtime's DEFAULT endpoint; there is no--endpointflag, so named runtime endpoints created viaagentcore add runtime-endpoint(e.g. control/treatment version aliases for A/B testing) cannot be smoke-tested directly. The only workaround is routing through a gateway. As a bonus, the same SigV4-qualifier gap meansrun eval --dataset --endpoint <name>against a SigV4 agent silently invokes DEFAULT while reading spans from the named-endpoint log group, so it can collect zero spans.Root cause
The endpoint/qualifier is never carried from the CLI surface through resolution into the SigV4 SDK call. Verified at v0.20.2: no --endpoint registered on invoke (command.tsx:128-200); no endpoint field on InvokeOptions (types.ts:3-75); resolveInvokeTarget neither accepts nor returns one and ResolvedInvokeTarget has no endpoint field (resolve.ts:24-33,37-164); action.ts calls invokeAgentRuntimeStreaming (710) and invokeAgentRuntime (748) without passing endpoint; the SigV4 InvokeAgentRuntimeCommand is built without qualifier at agentcore.ts:362 and :458 even though InvokeAgentRuntimeOptions.endpoint exists (agentcore.ts:74) and the bearer-token path honors it via buildInvokeUrl (agentcore.ts:203-204). Premise real: deploy persists endpoints to runtimeEndpoints keyed ${agentName}/${endpointName} (outputs.ts:498); runtimes[].endpoints[name] modeled (agent-env.ts:345-346).
See root_cause field: verified at v0.20.2 HEAD e92c79a. invoke has no --endpoint (command.tsx/types.ts/action.ts), and the SigV4 InvokeAgentRuntimeCommand at agentcore.ts:362-370 & 458-466 omits the SDK-supported
qualifier(models_0.d.ts:390-393); endpoint is only honored in the bearer path (buildInvokeUrl, agentcore.ts:201-205). Latent same-cause bug at scenario-executor.ts:75.The fix
Add
--endpoint <name>to invoke and plumb it through to the SDK qualifier. (1) Register the flag in command.tsx and add it to cliOptions/InvokeOptions (types.ts). (2) In resolveInvokeTarget (resolve.ts), accept an endpointName, validate it against project.runtimes[].endpoints[name] and/or deployedState...runtimeEndpoints[${agent}/${name}], and return it as endpoint/qualifier. (3) Pass endpoint into both invokeAgentRuntime (action.ts:748) and invokeAgentRuntimeStreaming (action.ts:710). (4) In agentcore.ts, add...(options.endpoint && { qualifier: options.endpoint })to the two SigV4 InvokeAgentRuntimeCommand builders (lines 362 and 458). DESIGN NOTE confirmed in SDK: the AWS InvokeAgentRuntime API targets endpoints viaqualifier, which is the endpoint NAME, not the ARN (@aws-sdk/client-bedrock-agentcore models_0.d.ts:390-393: "an endpoint name that points to a specific version"); the runtime ARN is unchanged and deployed-state is used only to validate existence. The issue body's wording ("resolve the endpoint ARN and route to it") is technically loose. Also mirror this in the invoke TUI flow (useInvokeFlow.ts) for parity.See the_fix field: register --endpoint on invoke, thread through InvokeOptions->action, AND set
qualifier: options.endpointon the SigV4 InvokeAgentRuntimeCommand (agentcore.ts:362-370,458-466). Reuse existing resolveEndpointName (cloudwatch.ts:9-11) for the AGENTCORE_RUNTIME_ENDPOINT fallback rather than re-implementing it at the command layer.Files touched: src/cli/commands/invoke/command.tsx (register --endpoint, thread into InvokeOptions ~128-200, 425-462); src/cli/commands/invoke/types.ts (add endpoint to InvokeOptions ~3-75); src/cli/commands/invoke/resolve.ts (resolveInvokeTarget: accept+validate, return qualifier ~24-33,37-164); src/cli/commands/invoke/action.ts (pass endpoint into invokeAgentRuntime/Streaming ~710,748); src/cli/aws/agentcore.ts (add qualifier to both SigV4 InvokeAgentRuntimeCommand builders, lines 362 and 458). Optional parity: src/cli/tui/screens/invoke/useInvokeFlow.ts.
CLI only. src/cli/commands/invoke/command.tsx (register --endpoint, cliOptions type, options object); src/cli/commands/invoke/types.ts (add endpoint to InvokeOptions); src/cli/commands/invoke/action.ts (thread endpoint into invokeAgentRuntime / invokeAgentRuntimeStreaming, ~710-760); src/cli/aws/agentcore.ts (add qualifier: options.endpoint to InvokeAgentRuntimeCommand at 362-370 and 458-466 — the SigV4 fix; optionally MCP/A2A/AGUI builders too); reuse src/cli/aws/cloudwatch.ts resolveEndpointName for the env fallback. Note: run eval's --endpoint is registered in src/cli/commands/run/command.tsx (lines 92, 209), NOT commands/eval/ as the brief stated.
Validation evidence
The fix was verified by reproducing the original symptom and re-running after the change:
Test suite: green.
Staged on the fork as a draft for human review. Promote to aws/agentcore-cli after vetting.