fix(unit-only): Add bearer-token support to the A2A invoke path, mirrorin... (#815)#34
Draft
aidandaly24 wants to merge 3 commits into
Draft
fix(unit-only): Add bearer-token support to the A2A invoke path, mirrorin... (#815)#34aidandaly24 wants to merge 3 commits into
aidandaly24 wants to merge 3 commits into
Conversation
…M_JWT runtimes A2A-protocol agents configured with CUSTOM_JWT authorization could not be invoked: the CLI auto-fetched a bearer token but invokeA2ARuntime always used the SigV4 client, dropping the token and triggering an "Authorization method mismatch" service error. Add bearerToken support to A2AInvokeOptions and, when set, send a raw HTTP POST of the JSON-RPC body with an Authorization: Bearer header via buildInvokeUrl / buildBearerInvokeHeaders, parsing the response through parseA2AResponse. Thread the token through all three call sites (invoke action, TUI invoke flow, dev web-UI invocations handler). Fixes aws#815
Coverage Report
|
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#815
Issues
Root cause
A2A invoke path has no bearerToken support: A2AInvokeOptions (agentcore.ts:926-934) lacks the field and invokeA2ARuntime (942-986) always uses SigV4 (createAgentCoreClient line 943), with no bearer dispatch like the HTTP path (356-357). The token is auto-fetched in resolve.ts:116-145 and stored at action.ts:306 but dropped by the A2A option literals at action.ts:592-601, useInvokeFlow.ts:782-792, and invocations.ts:456-463/552-560 (MCP/AGUI/HTTP siblings all pass it). No add-time guard (validate.ts:319-335).
The fix
Add bearer-token support to the A2A invoke path, mirroring HTTP. (1) Add
bearerToken?: string;to A2AInvokeOptions (agentcore.ts:926-934). (2) In invokeA2ARuntime (agentcore.ts:942), when options.bearerToken is set, send a raw HTTP POST of the JSON-RPC body with Authorization: Bearer via buildInvokeUrl/buildBearerInvokeHeaders (agentcore.ts:201-233) instead of the SigV4 createAgentCoreClient + InvokeAgentRuntimeCommand, then parse the response through the existing parseA2AResponse. A2A uses the same InvokeAgentRuntime data plane and /runtimes/{arn}/invocations endpoint as HTTP, which already supports bearer auth, so this is sound. (3) Pass the token at the three call sites: bearerToken: options.bearerToken at action.ts:592-601, bearerToken: bearerToken || undefined at useInvokeFlow.ts:782-792, and thread bearerToken through DeployedInvokeParams to the A2A dispatch and handler at invocations.ts:456-463 / 552-560. Minimal-effort fallback only if the service truly rejects CUSTOM_JWT for A2A: add a fail-loud guard at the top of invokeA2ARuntime like AGUI's (agentcore.ts:1080-1082), or reject A2A+CUSTOM_JWT in validate.ts:319-335 — but the full fix is preferred.Files touched: src/cli/aws/agentcore.ts (A2AInvokeOptions interface lines 926-934; invokeA2ARuntime lines 942-986), src/cli/commands/invoke/action.ts:592-601, src/cli/tui/screens/invoke/useInvokeFlow.ts:782-792, src/cli/operations/dev/web-ui/handlers/invocations.ts (DeployedInvokeParams 498-506, dispatch 456-463, handleDeployedA2AInvocation 552-560)
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.