a2aproject/a2a-python

[Feat]: Race Condition in TaskUpdater for Terminal States

pankaj-bind opened this issue · 0 comments

Is your feature request related to a problem? Please describe.

The TaskUpdater is vulnerable to a race condition when handling terminal states. Concurrent updates (e.g., two simultaneous calls to complete() and failed()) can lead to inconsistent task statuses because the state checks are not atomic.

A locking mechanism is needed to ensure that once a task begins to transition to a terminal state, no other updates can be processed.

Describe the solution you'd like

Steps to reproduce the behavior:

  1. Trigger two simultaneous async calls to update a task's status to two different terminal states.
  2. For example: asyncio.gather(task_updater.complete(), task_updater.failed()).
  3. Observe that it may be possible for both operations to proceed further than they should, creating a race condition.

Describe alternatives you've considered

No response

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct