molecule-core/workspace/adapters/google-adk
molecule-ai[bot] 35bcad9204
feat(workspace): migrate a2a-sdk from 0.3.x to 1.0.0 (KI-009) (#1974)
* feat(workspace): migrate a2a-sdk from 0.3.x to 1.0.0 (KI-009)

Migrates all workspace code from a2a-sdk v0.3.x to v1.0.0, following the
official migration guide from a2aproject/a2a-python.

Breaking changes applied:
- A2AStarletteApplication → Starlette route factory
  (create_agent_card_routes + create_jsonrpc_routes)
- AgentCard.url removed; url+protocol now in supported_protocols[].url
- AgentCapabilities fields renamed to snake_case
  (pushNotifications→push_notifications,
   stateTransitionHistory→state_transition_history)
- AgentCard.defaultInputModes/outputModes → default_input_modes/output_modes
- TaskState.canceled → TaskState.TASK_STATE_CANCELED
- a2a.utils → a2a.helpers
- Part(root=TextPart(text=t)) → Part(text=t) (TextPart removed)

Files changed:
- requirements.txt: pinned >=1.0.0,<2.0
- main.py: Starlette route factory + AgentCard restructure
- a2a_executor.py: Part() + TaskState + helpers import
- hermes_executor.py: TaskState + helpers import
- google-adk/adapter.py: TaskState + helpers import
- cli_executor.py: helpers import
- claude_sdk_executor.py: helpers import
- tests/conftest.py: a2a.helpers mock stub
- tests/test_a2a_executor.py: TaskState enum key
- adapters/google-adk/test_adapter.py: Part + helpers stub

Refs: KI-009
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(test): update _TaskState mock to a2a-sdk v1 enum name (TASK_STATE_CANCELED)

---------

Co-authored-by: Molecule AI Tech Researcher <tech-researcher@agents.moleculesai.app>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: molecule-ai[bot] <276602405+molecule-ai[bot]@users.noreply.github.com>
2026-04-24 04:43:17 +00:00
..
adapter.py feat(workspace): migrate a2a-sdk from 0.3.x to 1.0.0 (KI-009) (#1974) 2026-04-24 04:43:17 +00:00
README.md chore: open-source restructure — rename dirs, remove internal files, scrub secrets 2026-04-18 00:24:44 -07:00
requirements.txt chore: open-source restructure — rename dirs, remove internal files, scrub secrets 2026-04-18 00:24:44 -07:00
test_adapter.py feat(workspace): migrate a2a-sdk from 0.3.x to 1.0.0 (KI-009) (#1974) 2026-04-24 04:43:17 +00:00

Google ADK Adapter

Molecule AI workspace adapter for Google Agent Development Kit (ADK) — Google's official multi-agent Python SDK (~19k , Apache-2.0).

Overview

This adapter bridges the A2A protocol used by the Molecule AI platform to Google ADK's runner/session model. Agents are backed by Google Gemini models via AI Studio or Vertex AI. Each workspace gets an LlmAgent wrapped in a Runner with an InMemorySessionService; sessions are tied to A2A task context IDs for stable, isolated per-conversation state.

Runtime key: google-adk

Installation

The adapter dependencies are installed automatically by entrypoint.sh from this directory's requirements.txt:

pip install -r adapters/google-adk/requirements.txt

You'll also need a Google API key (AI Studio) or Vertex AI credentials.

Configuration

config.yaml

runtime: google-adk
model: google:gemini-2.0-flash        # or gemini-1.5-pro, gemini-2.5-flash, etc.
runtime_config:
  agent_name: my-agent                # optional, default: molecule-adk-agent
  max_output_tokens: 8192             # optional, default: 8192
  temperature: 1.0                    # optional, default: 1.0

Environment Variables

Variable Required Description
GOOGLE_API_KEY Yes (unless Vertex AI) Google AI Studio API key
GOOGLE_GENAI_USE_VERTEXAI No Set to "1" to use Vertex AI instead of AI Studio
GOOGLE_CLOUD_PROJECT When using Vertex AI GCP project ID
GOOGLE_CLOUD_LOCATION When using Vertex AI GCP region, e.g. "us-central1"

Usage Example

import asyncio
from adapter_base import AdapterConfig
from adapters.google_adk.adapter import GoogleADKAdapter

async def main():
    config = AdapterConfig(
        model="google:gemini-2.0-flash",
        system_prompt="You are a helpful assistant.",
        runtime_config={
            "agent_name": "demo-agent",
            "max_output_tokens": 1024,
            "temperature": 0.7,
        },
        workspace_id="ws-demo",
    )

    adapter = GoogleADKAdapter()
    await adapter.setup(config)              # validates keys, loads plugins/skills

    executor = await adapter.create_executor(config)  # returns GoogleADKA2AExecutor
    # executor.execute(context, event_queue) is called by the A2A server per turn
    print(f"Adapter: {adapter.display_name()} — model {config.model}")

asyncio.run(main())

Running via A2A

Once the workspace is provisioned, send A2A messages as normal:

curl -X POST http://localhost:8000 \
  -H 'Content-Type: application/json' \
  -d '{
    "method": "message/send",
    "params": {
      "message": {
        "role": "user",
        "parts": [{"kind": "text", "text": "What is 2 + 2?"}]
      }
    }
  }'

Supported Models

Any model supported by Google ADK and available through your credential path:

Model Notes
gemini-2.0-flash Recommended — fast, cost-effective
gemini-2.5-flash Latest preview, strong reasoning
gemini-1.5-pro Higher capability, higher latency
gemini-1.5-flash Fast, lower cost

Use the google: prefix in config.yaml — the adapter strips it before passing the model name to ADK.

Architecture

A2A Request
    │
    ▼
GoogleADKA2AExecutor.execute()
    │
    ├── extract_message_text()   ← shared_runtime helper
    ├── _ensure_session()        ← create/reuse InMemorySessionService session
    ├── _build_content()         ← wrap text in google.genai.types.Content
    │
    ▼
runner.run_async(session_id, user_id, new_message)
    │
    ▼
ADK Event stream → filter is_final_response() → extract text
    │
    ▼
event_queue.enqueue_event(new_agent_text_message(reply))
    │
    ▼
A2A Response

License

Apache-2.0 — same as google/adk-python.