Skip to main content

Persistent, pod-restart-safe A2A task store for Google Agent ADK. Drop-in replacement for InMemoryTaskStore.

Project description

adk-task-persistence

Persistent, pod-restart-safe A2A task store for Google Agent ADK.

Drop-in replacement for ADK's InMemoryTaskStore. Native fit with ADK's A2A stack — fully compatible with RemoteA2aAgent and SSE streaming. Works in multi-pod EKS / Kubernetes deployments today.

pip install adk-task-persistence

The Problem

Google ADK's get_fast_api_app(a2a=True) always creates an in-process InMemoryTaskStore. There is no parameter to inject a persistent one. In any non-trivial deployment this causes:

  1. Pod-restart data loss — every in-flight task vanishes silently when a container restarts
  2. Cross-pod 404s — status polls routed to a different pod return "not found"
  3. No horizontal scaling without sticky sessions — defeats the purpose of stateless web pods

ADK has already solved the equivalent problem for session state via DatabaseSessionService. This library applies the same pattern to A2A task state.


The Solution

SqlAlchemyTaskStore implements ADK's real a2a.server.tasks.TaskStore ABC. Tasks are written to your database (Postgres / MySQL / SQLite) instead of in-process memory.

The HTTP/SSE protocol is unchanged. RemoteA2aAgent callers see exactly the same A2A streaming responses they always have. The only difference is where task state is written.


Quick Start

from sqlalchemy.ext.asyncio import create_async_engine
from adk_task_persistence import SqlAlchemyTaskStore, create_a2a_app

engine = create_async_engine("postgresql+asyncpg://user:pass@db/mydb")
task_store = SqlAlchemyTaskStore(engine)

# Build the ADK A2A stack with persistent task state:
app = create_a2a_app(
    runner=runner,
    agent_card=agent_card,
    task_store=task_store,
)

After ADK PR #4970 merges, pass it directly to get_fast_api_app:

from google.adk.cli.fast_api import get_fast_api_app

app = get_fast_api_app(
    agents_dir="./agents",
    a2a=True,
    a2a_task_store=SqlAlchemyTaskStore(engine),    # ← same class, one parameter
)

SqlAlchemyTaskStore is interface-compatible with the upstream PRs.


Optional: Celery for Agent-Run Survival

If your agents run for minutes and you need execution to survive an HTTP pod crash mid-run, use the optional Celery extension.

pip install "adk-task-persistence[celery]"
from adk_task_persistence.celery import AdkAgentRunner, registry

registry.register(
    "my_agent",
    agent_factory=lambda: AdkAgentRunner(my_runner),
    session_service_factory=lambda: None,
    task_store_factory=lambda: SqlAlchemyTaskStore(engine),
)
celery -A adk_task_persistence.celery worker --loglevel=info

License

Apache 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

adk_task_persistence-0.1.0.tar.gz (17.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

adk_task_persistence-0.1.0-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file adk_task_persistence-0.1.0.tar.gz.

File metadata

  • Download URL: adk_task_persistence-0.1.0.tar.gz
  • Upload date:
  • Size: 17.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for adk_task_persistence-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4152d59103ee906582a26a6f737a04e21faa90b77015001b78da38a23af44338
MD5 78638ce9f2d715625791b30f992be5d0
BLAKE2b-256 90974afb1f86d007b7905538949f520c22dd258b6c65fe816eec05355c860460

See more details on using hashes here.

Provenance

The following attestation bundles were made for adk_task_persistence-0.1.0.tar.gz:

Publisher: publish.yml on STHITAPRAJNAS/adk-task-persistence

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file adk_task_persistence-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for adk_task_persistence-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b34fafa9e52b4d5e3c583cd43eae45bc02e8adf025eeee33c488032781ec487f
MD5 56dad04788470747b7e859186310c64a
BLAKE2b-256 42ca58d9f9a63be086c94daabc5bc42c0ee74edf7e8c694a29e28184c1b14a6d

See more details on using hashes here.

Provenance

The following attestation bundles were made for adk_task_persistence-0.1.0-py3-none-any.whl:

Publisher: publish.yml on STHITAPRAJNAS/adk-task-persistence

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page