feat: persistent A2A task store via DatabaseTaskStore; deprecate server.py#1
Merged
STHITAPRAJNAS merged 3 commits intomainfrom Mar 22, 2026
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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