-
Notifications
You must be signed in to change notification settings - Fork 370
Description
Currently ClientTaskManager tries to replicate server logic of maintaining task state on the client applying TaskXxxUpdateEvent's.
This logic already diverges from server when it comes to task history: on the client current status update message is added to the history:
a2a-python/src/a2a/client/client_task_manager.py
Lines 120 to 124 in cced34d
| if event.status.message: | |
| if not task.history: | |
| task.history = [event.status.message] | |
| else: | |
| task.history.append(event.status.message) |
while on the server it only contains messages from previous updates:
a2a-python/src/a2a/server/tasks/task_manager.py
Lines 143 to 152 in cced34d
| if task.status.message: | |
| if not task.history: | |
| task.history = [task.status.message] | |
| else: | |
| task.history.append(task.status.message) | |
| if event.metadata: | |
| if not task.metadata: | |
| task.metadata = {} | |
| task.metadata.update(event.metadata) | |
| task.status = event.status |
Having Client returning Task object assembled using this logic can be confusing as it can be different from the actual server-side state. Especially with 1.0 which specifies history behavior to be partially server-side defined:
The Task History field contains Messages exchanged during task execution. However, not all Messages are guaranteed to be persisted in the Task history; for example, transient informational messages may not be stored. Messages exchanged prior to task creation may not be stored in Task history. The agent is responsible to determine which Messages are persisted in the Task History.
In addition, relying heavily on task history is rather a leftover from earlier integrations which used task history to stream the actual LLM response (which should be returned as an artifact instead).
Alternative proposal is to create something like ArtifactsAgregator.from_stream(iterator from send_message) as a side utility to interpret artifact append flag properly.