Skip to content

fix(server): keep follow-up message when the executor re-emits the current task - #1298

Open
marcinbelczewski wants to merge 1 commit into
a2aproject:mainfrom
marcinbelczewski:fix/keep-follow-up-message-on-current-task
Open

marcinbelczewski wants to merge 1 commit into
a2aproject:mainfrom
marcinbelczewski:fix/keep-follow-up-message-on-current-task

Conversation

@marcinbelczewski

@marcinbelczewski marcinbelczewski commented Oct 2, 2026 •

Copy link
Copy Markdown

Description

Problem

Spec 3.1.2: "If the agent returns a Task, the stream MUST begin with the Task object". On a follow-up to an existing task, on_message_send_stream subscribes with include_initial_task=False, so the leading Task has to come from the executor. The v1.0 migration guide shows how: task = context.current_task or new_task_from_user_message(...), then enqueue_event(task).

When the task already exists, EventConsumer._handle_initial_task logs Task ... already exists. Ignoring task replacement. at ERROR and clears message_to_save. As a result, the follow-up user message never reaches Task.history.

Fix

When the task exists and message_to_save is still pending (the Task is the first task event of the request), _handle_initial_task now keeps message_to_save. The next update event then adds the message to history, which is what already happens when the executor doesn't enqueue the Task. The ERROR is still logged for a real replacement, such as a second Task in the same request (test_scenario_enqueue_task_twice).

Tests

test_scenario_streaming_resumption_enqueues_current_task in test_scenarios.py checks that the follow-up stream starts with a Task, that both user messages end up in history, and that no replacement ERROR is logged. The test fails without the source change. It also fails with either half of the change reverted: clearing message_to_save fails the history assertion, and always logging fails the log assertion.


Fixes #1285 🦕

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

🧪 Code Coverage (vs main)

⬇️ Download Full Report

Base PR Delta
src/a2a/server/agent_execution/active_task.py 95.05% 95.09% 🟢 +0.03%
Total 93.11% 93.11% ⚪️ 0.00%

Generated by coverage-comment.yml

@marcinbelczewski
marcinbelczewski force-pushed the fix/keep-follow-up-message-on-current-task branch from b594be3 to c799aa8 Compare October 2, 2026 13:10
@marcinbelczewski
marcinbelczewski force-pushed the fix/keep-follow-up-message-on-current-task branch from c799aa8 to b8e91b6 Compare October 13, 2026 07:58

This branch has not been deployed

No deployments
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.

[Bug]: Streaming follow-up on an existing task does not begin with a Task; enqueuing the current task drops the follow-up message from history

1 participant