Skip to content

Commit c664c20

Browse files
LaurentMnr95zboyles
authored andcommitted
feat: postgresql task store
1 parent 20f0826 commit c664c20

File tree

5 files changed

+618
-560
lines changed

5 files changed

+618
-560
lines changed

.github/workflows/unit-tests.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ jobs:
1515
runs-on: ubuntu-latest
1616

1717
if: github.repository == 'google/a2a-python'
18+
services:
19+
postgres:
20+
image: postgres:15-alpine
21+
env:
22+
POSTGRES_USER: postgres
23+
POSTGRES_PASSWORD: postgres
24+
POSTGRES_DB: a2a_test
25+
ports:
26+
- 5432:5432
27+
volumes:
28+
- ${{ github.workspace }}/docker/postgres/init.sql:/docker-entrypoint-initdb.d/init.sql
1829

1930
strategy:
2031
matrix:
@@ -28,6 +39,9 @@ jobs:
2839
uses: actions/setup-python@v5
2940
with:
3041
python-version: ${{ matrix.python-version }}
42+
- name: Set postgres test DSN
43+
run: |
44+
export POSTGRES_TEST_DSN="postgresql://postgres:postgres@localhost:5432/a2a_test"
3145
3246
- name: Install uv
3347
run: |

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ authors = [{ name = "Google LLC", email = "[email protected]" }]
88
requires-python = ">=3.10"
99
keywords = ["A2A", "A2A SDK", "A2A Protocol", "Agent2Agent"]
1010
dependencies = [
11+
"asyncpg>=0.30.0",
1112
"httpx>=0.28.1",
1213
"httpx-sse>=0.4.0",
1314
"opentelemetry-api>=1.33.0",
@@ -73,6 +74,7 @@ members = [
7374

7475
[dependency-groups]
7576
dev = [
77+
"asyncpg-stubs>=0.30.1",
7678
"datamodel-code-generator>=0.30.0",
7779
"mypy>=1.15.0",
7880
"pytest>=8.3.5",

src/a2a/server/tasks/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from a2a.server.tasks.inmemory_push_notifier import InMemoryPushNotifier
44
from a2a.server.tasks.inmemory_task_store import InMemoryTaskStore
5+
from a2a.server.tasks.postgresql_task_store import PostgreSQLTaskStore
56
from a2a.server.tasks.push_notifier import PushNotifier
67
from a2a.server.tasks.result_aggregator import ResultAggregator
78
from a2a.server.tasks.task_manager import TaskManager
@@ -12,6 +13,7 @@
1213
__all__ = [
1314
'InMemoryPushNotifier',
1415
'InMemoryTaskStore',
16+
'PostgreSQLTaskStore',
1517
'PushNotifier',
1618
'ResultAggregator',
1719
'TaskManager',

src/a2a/types.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ class TaskResubscriptionRequest(BaseModel):
731731
"""
732732

733733

734-
class TaskState(Enum):
734+
class TaskState(str, Enum):
735735
"""
736736
Represents the possible states of a Task.
737737
"""
@@ -1086,7 +1086,9 @@ class Artifact(BaseModel):
10861086

10871087

10881088
class GetTaskPushNotificationConfigResponse(
1089-
RootModel[JSONRPCErrorResponse | GetTaskPushNotificationConfigSuccessResponse]
1089+
RootModel[
1090+
JSONRPCErrorResponse | GetTaskPushNotificationConfigSuccessResponse
1091+
]
10901092
):
10911093
root: JSONRPCErrorResponse | GetTaskPushNotificationConfigSuccessResponse
10921094
"""
@@ -1237,7 +1239,9 @@ class SendStreamingMessageRequest(BaseModel):
12371239

12381240

12391241
class SetTaskPushNotificationConfigResponse(
1240-
RootModel[JSONRPCErrorResponse | SetTaskPushNotificationConfigSuccessResponse]
1242+
RootModel[
1243+
JSONRPCErrorResponse | SetTaskPushNotificationConfigSuccessResponse
1244+
]
12411245
):
12421246
root: JSONRPCErrorResponse | SetTaskPushNotificationConfigSuccessResponse
12431247
"""
@@ -1530,7 +1534,9 @@ class SendStreamingMessageSuccessResponse(BaseModel):
15301534
"""
15311535

15321536

1533-
class CancelTaskResponse(RootModel[JSONRPCErrorResponse | CancelTaskSuccessResponse]):
1537+
class CancelTaskResponse(
1538+
RootModel[JSONRPCErrorResponse | CancelTaskSuccessResponse]
1539+
):
15341540
root: JSONRPCErrorResponse | CancelTaskSuccessResponse
15351541
"""
15361542
JSON-RPC response for the 'tasks/cancel' method.
@@ -1569,7 +1575,9 @@ class JSONRPCResponse(
15691575
"""
15701576

15711577

1572-
class SendMessageResponse(RootModel[JSONRPCErrorResponse | SendMessageSuccessResponse]):
1578+
class SendMessageResponse(
1579+
RootModel[JSONRPCErrorResponse | SendMessageSuccessResponse]
1580+
):
15731581
root: JSONRPCErrorResponse | SendMessageSuccessResponse
15741582
"""
15751583
JSON-RPC response model for the 'message/send' method.

0 commit comments

Comments
 (0)