Skip to content

fix(a2a): use the final streamed answer as RemoteA2aAgent node output - #7671

Open
llalitkumarrr wants to merge 1 commit into
google:mainfrom
llalitkumarrr:fix-issue_7589-streaming-output-none
Open

llalitkumarrr wants to merge 1 commit into
google:mainfrom
llalitkumarrr:fix-issue_7589-streaming-output-none

Conversation

@llalitkumarrr

Copy link
Copy Markdown
Collaborator

Link to Issue or Description of Change

Problem:
When RemoteA2aAgent runs as a Workflow node with streaming, the remote executor streams the answer as artifact updates while the task is working, then closes with a completed status update that has no content. As a result:

  • a2a-sdk 0.3: no event was eligible to become the output, so the node output (and the downstream JoinNode value) was None.
  • a2a-sdk 1.x: task states are serialized as protobuf enum names (TASK_STATE_WORKING, ...). These weren't in _NON_FINAL_TASK_STATES, so the first intermediate text (e.g. a "Let me look that up." preamble) became the node output.

Solution:

  • Add the A2A 1.x enum names to _NON_FINAL_TASK_STATES. Add _IN_PROGRESS_TASK_STATES (submitted/working) and _COMPLETED_TASK_STATES.
  • In _run_impl, track the latest task state and remember the last non-thought answer text from this node seen while the task is in progress.
  • After the stream ends, if nothing was promoted and the task reached completed, set the remembered text on ctx.output. The framework then emits it as the node output.
  • Every streamed event is still yielded unchanged and immediately, so streaming behavior isn't affected.
  • Turns that pause for input/auth, fail, are canceled or rejected, raise an error event, or are still working when the stream ends keep producing no output, the same as before. The fallback is also skipped if the context has pending interrupts or an output is already set.
  • _get_task_state handles both plain strings and the a2a-sdk 0.3 TaskState str-enum stored in event metadata.

Testing Plan

Unit Tests:

  • Added or updated unit tests for my change.
  • All unit tests pass locally.

Additional context

The change is limited to RemoteA2aAgent._run_impl and two new private helpers (_get_task_state, _get_answer_text); there are no public API changes. AgentMode.TASK behavior is unchanged.

When RemoteA2aAgent runs as a Workflow node with streaming, the remote
executor streams the answer as artifact updates while the task is
`working`, then closes with a `completed` status update that has no
content. Nothing could become the node output on a2a-sdk 0.3, so it was
None. On a2a-sdk 1.x, the protobuf state names (`TASK_STATE_WORKING`,
etc.) were not recognized as non-final, so the first intermediate text
became the output.

Recognize the A2A 1.x task-state names. Remember the last answer text
seen while the task is submitted/working, and set it as the node output
after the stream ends, but only if the task reached `completed`. Turns
that pause for input/auth, fail, are canceled or rejected, or are still
running keep producing no output.

Fixes google#7589
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RemoteA2aAgent as a Workflow node: streaming output is None on a2a-sdk 0.3 and an intermediate text on 1.x

1 participant