Repository navigation
fix(server): keep follow-up message when the executor re-emits the current task #1298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
marcinbelczewski
wants to merge
1
commit into
a2aproject:main
Choose a base branch
from
marcinbelczewski:fix/keep-follow-up-message-on-current-task
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ran this locally with an agent like the one in your test. Two things.
['msg-start'].msg-resumeonly lands with the next status update. The final get_task is right, but the first streamed Task is what 3.1.2 is about.message_to_saveis still set for every Task, so enqueueingcurrent_tasktwice drops the second one with no ERROR.Saving the message here fixes both. The first Task then has both messages, the double enqueue logs once, and tests/integration plus tests/server pass:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ConnorMoss02 thanks a lot for taking the time to actually run it and for the patch! You are right on both points and sorry for that. My test only checked that the stream starts with a
Taskand what ends up in history at the end, but never what is inside that firstTask, which is the whole point of 3.1.2... And the claim that a secondTaskstill logs the ERROR I based ontest_scenario_enqueue_task_twice, which only covers a brand new task, not a follow-up. My bad.I applied your approach with one small change: the follow-up message now goes through the same
message_idcheck that_handle_task_modification_eventalready had (from #1106). I moved it to_add_message_to_historyso both paths use it. Without it, if the executor enqueuescurrent_taskand the client resends the same follow-up message (samemessage_id), the message lands in history twice, while for an executor that only sends status updates it's saved once. Let me know if you'd rather keep it exactly as you proposed.Tests:
test_scenario_streaming_resumption_enqueues_current_taskis now parametrized withonce/twice. It checks the history of the first streamedTaskand that the ERROR is logged exactly once when theTaskis enqueued twice.test_scenario_resent_follow_up_message_saved_oncechecks that both executor patterns save a resent message only once.I checked that the streaming test fails on the previous version and the resend one fails with your patch as is. I also broke each part of the change on purpose to make sure some test catches it. Squashed into a single commit and force pushed.
Thanks again for catching this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more thing I noticed after posting the above. The first streamed
Taskis right only if the executor enqueuescontext.current_taskitself (as in the migration guide), because that's the same objectTaskManagerkeeps. If it enqueues a copy, history is fine but the first streamedTaskstill has only['msg-start']. Subscribers get the raw executor event here:a2a-python/src/a2a/server/agent_execution/active_task.py
Lines 280 to 286 in aa8e966
Looks like a leftover from #1053. Before it the consumer sent the stored task to subscribers, but maybe I'm missing something. Passing
handled_eventthere fixes it and all tests pass, but it changes what's streamed for everyTaskevent, so I'd rather not sneak it into this PR. Should I add it here or open a separate issue?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small update: the test now also has an agent message in the INPUT_REQUIRED status, to check the user 1 → agent → user 2 order.