fix(flags): A2A streaming - #1889
Conversation
There was a problem hiding this comment.
🟡 Not ready to approve
The new A2A streaming path has correctness gaps (notably text-part format handling and bearer-token streaming behavior) and lacks targeted unit test coverage for the new message/stream branch.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Pull request overview
This PR fixes agentcore invoke --stream for A2A runtimes by plumbing the CLI --stream flag into the A2A invoke path and adding an A2A message/stream (SSE) implementation in the AgentCore client wrapper.
Changes:
- Passes the CLI
--streamoption throughhandleInvoke()intoinvokeA2ARuntime(). - Extends
A2AInvokeOptionswith astream?: booleanflag. - Implements an A2A
message/streamSSE response reader to yield incremental text chunks.
File summaries
| File | Description |
|---|---|
| src/cli/commands/invoke/action.ts | Wires --stream into the A2A invocation options passed to invokeA2ARuntime(). |
| src/cli/aws/agentcore.ts | Adds an A2A streaming option and SSE parsing path for message/stream. |
Review details
Suppressed comments (1)
src/cli/aws/agentcore.ts:1053
- Same as the status-update path: artifact-update streaming currently only recognizes
kind:'text'parts, so streamed output can be silently empty if the runtime usestype:'text'parts (which is already supported in non-streaming parsing).
const text = artifact.parts
.filter(p => p.kind === 'text' && p.text)
.map(p => p.text!)
.join('');
- Files reviewed: 2/2 changed files
- Comments generated: 3
- Review effort level: Lite
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
| // Use message/stream (SSE) for real-time streaming when requested | ||
| if (options.stream) { | ||
| const streamBody = { ...body, method: 'message/stream' }; |
| const text = status.message.parts | ||
| .filter(p => p.kind === 'text' && p.text) | ||
| .map(p => p.text!) | ||
| .join(''); |
| // Use message/stream (SSE) for real-time streaming when requested | ||
| if (options.stream) { | ||
| const streamBody = { ...body, method: 'message/stream' }; | ||
| options.logger?.logSSEEvent(`A2A streaming request: ${JSON.stringify(streamBody)}`); | ||
|
|
Description
The
--streamflag was only working for HTTP agent runtimes and not A2A. This PR adds back the missing arguments needed to connect the flag toinvokeA2ARuntime().Related Issue
Closes #1887
Documentation PR
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 snapshotsChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the
terms of your choice.