Skip to content

feat(server): add versioned task store and event stream interfaces - #1244

Open
mykytanetipa wants to merge 1 commit into
mainfrom
multiserver/cluster-schemas
Open

mykytanetipa wants to merge 1 commit into
mainfrom
multiserver/cluster-schemas

Conversation

@mykytanetipa

@mykytanetipa mykytanetipa commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

Adds a2a.server.cluster, the building blocks for running the A2A server as several replicas, with no need to route a task's requests back to the replica that started it. This PR is purely additive nothing uses the new structures yet.

Key changes:

  • VersionedTaskStore - a task store that keeps track of which revision of a task a replica last read. When that replica saves, the store checks the task has not changed in the meantime and refuses the write / retries if it has, instead of quietly overwriting whatever another replica just did. VersionedDatabaseTaskStore is the database-backed implementation.
  • TaskEventStream - a shared record of the events a task produces, so a replica that is not running the agent can still see the event stream. This is lets a client reconnect to any replica and keep receiving updates for a task running elsewhere. DatabaseTaskEventStream is the database-backed implementation.
  • Schema for both: a version column on the tasks table and a new task_events table.

Tested:

Design discussion: #1224

@github-actions

github-actions Bot commented Sep 17, 2026

Copy link
Copy Markdown

🧪 Code Coverage (vs main)

⬇️ Download Full Report

Base PR Delta
src/a2a/server/models.py 97.83% 90.16% 🔴 -7.66%
src/a2a/server/tasks/database_task_store.py 91.19% 92.45% 🟢 +1.26%
src/a2a/server/cluster/database_event_stream.py (new) 93.88%
src/a2a/server/cluster/database_task_store.py (new) 95.12%
src/a2a/server/cluster/event_stream.py (new) 100.00%
src/a2a/server/cluster/task_store.py (new) 100.00%
src/a2a/server/cluster/version.py (new) 100.00%
Total 93.06% 93.12% 🟢 +0.06%

Generated by coverage-comment.yml

@mykytanetipa
mykytanetipa added this pull request to stack #1246 September 17, 2026 08:45
@mykytanetipa mykytanetipa changed the title feat(server/cluster): add clustered task store and event stream build… feat(server): add clustered task store and event stream build… Sep 17, 2026
@mykytanetipa mykytanetipa changed the title feat(server): add clustered task store and event stream build… feat(server): add versioned task store and event stream interfaces Sep 17, 2026
@mykytanetipa
mykytanetipa force-pushed the multiserver/cluster-schemas branch from 56d51d2 to 7f4a2b0 Compare September 17, 2026 09:57
…ing blocks

Introduces the a2a.server.cluster package: the extension points for running
the A2A server as multiple replicas behind a load balancer with no task
affinity. The package is inert at this commit -- nothing in the runtime imports
it yet -- but it also adds a `version` column to the shared tasks schema that
database-backed deployments must provision (see the schema bullet).

* Optimistic concurrency: TaskVersion, VersionedTaskStore (compare-and-set)
  whose `get` returns a `StoredTask` (task + version), with
  ConcurrentTaskModificationError and a LegacyTaskStoreAdapter that runs an
  existing TaskStore under the versioned interface (last-writer-wins).
* Versioned store: VersionedDatabaseTaskStore (CAS on a version column) with a
  configurable bounded retry (max_attempts / retry_delay_s) for transient DB
  contention.
* Cross-replica event stream: TaskEventStream / VersionedEvent and
  DatabaseTaskEventStream tailing a transactional task_events outbox.
* Schema: nullable `version` column on TaskMixin plus the `task_events` outbox
  table. Their VALUES are inert for the non-versioned stores (version stays
  NULL, task_events empty), but DatabaseTaskStore selects and writes every
  mapped column, so the `version` column must exist in the database. Any
  database-backed deployment must run `a2a-db` after upgrading -- versioned or
  not; create_table=True (dev/tests) picks it up automatically.
@mykytanetipa
mykytanetipa force-pushed the multiserver/cluster-schemas branch from 7f4a2b0 to 52df455 Compare September 17, 2026 10:36
@mykytanetipa
mykytanetipa marked this pull request as ready for review September 17, 2026 10:51
@mykytanetipa
mykytanetipa requested a review from a team as a code owner September 17, 2026 10:51
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.

1 participant