Skip to content

feat: persistent A2A task store via DatabaseTaskStore; deprecate server.py#1

Merged
STHITAPRAJNAS merged 3 commits intomainfrom
claude/understand-server-main-modules-DsJZI
Mar 22, 2026
Merged

feat: persistent A2A task store via DatabaseTaskStore; deprecate server.py#1
STHITAPRAJNAS merged 3 commits intomainfrom
claude/understand-server-main-modules-DsJZI

Conversation

@STHITAPRAJNAS
Copy link
Copy Markdown
Owner

ADK v1.27.x hardcodes InMemoryTaskStore in get_fast_api_app with no injection
point (tracked in upstream PR #3839). This adds an interim workaround:

  • code_agent/a2a/stores.py: patch_adk_stores() monkey-patches
    a2a.server.tasks.InMemoryTaskStore (and InMemoryPushNotificationConfigStore)
    with DatabaseTaskStore-backed equivalents when DATABASE_URL is set.
    The patch must run before get_fast_api_app is called since ADK imports the
    class at function-call time inside the if a2a: block.

  • main.py: calls patch_adk_stores() before get_fast_api_app so tasks survive
    pod restarts and are shared across replicas in EKS. Falls back to InMemory
    when DATABASE_URL is absent (local/CI).

  • code_agent/a2a/server.py: marked DEPRECATED with full migration rationale.
    The custom JSON-RPC dispatcher is superseded by ADK's built-in A2A handler +
    the stores patch. File kept for reference until EKS rollout is confirmed.

Remove stores.py + the patch_adk_stores() call in main.py once ADK exposes
a native a2a_task_store parameter in get_fast_api_app.
Track: google/adk-python#3839

https://claude.ai/code/session_01KKh2oYnyYKq4MM7JoDNtvY

claude added 3 commits March 22, 2026 06:01
…er.py

ADK v1.27.x hardcodes InMemoryTaskStore in get_fast_api_app with no injection
point (tracked in upstream PR #3839). This adds an interim workaround:

- code_agent/a2a/stores.py: patch_adk_stores() monkey-patches
  a2a.server.tasks.InMemoryTaskStore (and InMemoryPushNotificationConfigStore)
  with DatabaseTaskStore-backed equivalents when DATABASE_URL is set.
  The patch must run before get_fast_api_app is called since ADK imports the
  class at function-call time inside the `if a2a:` block.

- main.py: calls patch_adk_stores() before get_fast_api_app so tasks survive
  pod restarts and are shared across replicas in EKS. Falls back to InMemory
  when DATABASE_URL is absent (local/CI).

- code_agent/a2a/server.py: marked DEPRECATED with full migration rationale.
  The custom JSON-RPC dispatcher is superseded by ADK's built-in A2A handler +
  the stores patch. File kept for reference until EKS rollout is confirmed.

Remove stores.py + the patch_adk_stores() call in main.py once ADK exposes
a native a2a_task_store parameter in get_fast_api_app.
Track: google/adk-python#3839

https://claude.ai/code/session_01KKh2oYnyYKq4MM7JoDNtvY
Apply upstream PR #3839 changes directly to the installed google-adk package
so get_fast_api_app and to_a2a accept task stores natively instead of
requiring module-level monkey-patching.

scripts/patch_adk.py
  Idempotent script that patches two ADK files in the active .venv:
  - google/adk/a2a/utils/agent_to_a2a.py: adds task_store param to to_a2a()
    (exact change from PR #3839)
  - google/adk/cli/fast_api.py: adds a2a_task_store + a2a_push_config_store
    params to get_fast_api_app() (same pattern extended to the higher-level fn)
  Run after any `pip install --upgrade google-adk` to re-apply.

code_agent/a2a/stores.py
  Replaced patch_adk_stores() monkey-patcher with clean factory functions:
  - build_task_store() -> DatabaseTaskStore | InMemoryTaskStore
  - build_push_config_store() -> DatabasePushNotificationConfigStore | InMemory
  Both key off DATABASE_URL; no module-namespace mutation.

main.py
  Passes stores via native params:
    get_fast_api_app(
        a2a_task_store=build_task_store(),
        a2a_push_config_store=build_push_config_store(),
        ...
    )
  No import-time side effects; clean, explicit, easy to test.

Cleanup path: once google-adk ships these params natively (post PR #3839 merge
+ a follow-up for get_fast_api_app), delete scripts/patch_adk.py and the
patch step from dev setup. stores.py factory functions remain valid.

https://claude.ai/code/session_01KKh2oYnyYKq4MM7JoDNtvY
PR #3839 uses `if task_store is None:` not `task_store or ...`.
Updated both the installed .venv file and the patch script anchor to match.
Confirmed via fetching the merged commit from refs/pull/3839/merge.

https://claude.ai/code/session_01KKh2oYnyYKq4MM7JoDNtvY
@STHITAPRAJNAS STHITAPRAJNAS merged commit 3eabfd4 into main Mar 22, 2026
1 check passed
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.

2 participants