Skip to content

fix(samples): emit Task(TASK_STATE_SUBMITTED) as first streaming event#970

Merged
sokoliva merged 6 commits intoa2aproject:1.0-devfrom
sokoliva:update-sample-cli
Apr 14, 2026
Merged

fix(samples): emit Task(TASK_STATE_SUBMITTED) as first streaming event#970
sokoliva merged 6 commits intoa2aproject:1.0-devfrom
sokoliva:update-sample-cli

Conversation

@sokoliva
Copy link
Copy Markdown
Member

@sokoliva sokoliva commented Apr 14, 2026

Description

Updates the sample agent and CLI to correctly follow the A2A streaming event contract, where the first event in a stream must be a Task or a Message object in TASK_STATE_SUBMITTED state.

Changes

hello_world_agent.py
SampleAgentExecutor.execute() now enqueues a Task(TASK_STATE_SUBMITTED) object as its very first event, before any TaskUpdater calls. The initial user message is included in the Task's history field, since the consumer sets message_to_save = None upon receiving a Task event (expecting the task to carry the message itself).

cli.py
Updates _handle_stream to match the new event contract:
The first event is now expected to be a Message or a Task (not an (event, task) tuple), and its id is used to initialize current_task_id.

README.md
Adds a README.md for the samples.

Tested

uv run samples/cli.py 
Connecting to http://127.0.0.1:41241 (preferred transport: Any)

✓ Agent Card Found:
  Name: Sample Agent
  Picked Transport: JsonRpcTransport

Connected! Send a message or type /quit to exit.
You: hi
Task [state=TASK_STATE_SUBMITTED]
TaskStatusUpdate [state=TASK_STATE_WORKING]: Processing your question... 
TaskArtifactUpdate [name=response]: Hello World! Nice to meet you! 
TaskStatusUpdate [state=TASK_STATE_COMPLETED]: 
--- Task Finished ---
You: /quit

Related issue #965 🦕

BEGIN_COMMIT_OVERRIDE
chore(samples): emit Task(TASK_STATE_SUBMITTED) as first streaming event (#970)
END_COMMIT_OVERRIDE

@sokoliva sokoliva requested a review from a team as a code owner April 14, 2026 13:50
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a README for the SDK samples and updates the sample agent and CLI client to better handle task streaming. Specifically, the agent now enqueues an initial task submission event, and the CLI processes streaming updates by extracting the task ID from the first event. Review feedback suggests expanding the CLI's initial event handling to include Message objects and ensuring the task ID is reset for all terminal task states, such as failures or cancellations, to maintain correct session state.

Comment thread samples/cli.py Outdated
Comment thread samples/cli.py Outdated
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 14, 2026

🧪 Code Coverage (vs 1.0-dev)

⬇️ Download Full Report

No coverage changes.

Generated by coverage-comment.yml

@sokoliva sokoliva requested a review from guglielmo-san April 14, 2026 13:54
Comment thread samples/cli.py Outdated
@sokoliva sokoliva merged commit 57a6624 into a2aproject:1.0-dev Apr 14, 2026
14 checks passed
@sokoliva sokoliva deleted the update-sample-cli branch April 16, 2026 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants