Pythonで Agent2Agent Protocol

Event:

みんなのPython勉強会#116

Presented:

2025/07/17 nikkie

AI Agent どうし の話

(略) Agentic AI systems represent a paradigmatic shift marked by multi-agent collaboration, (略)

論文「AI Agents vs. Agentic AI: A Conceptual Taxonomy, Applications and Challenges」によれば、単体のエージェントをAgentic AIとは呼びません

A2A、ご存知ですか?🙋

A2Aのページ より

Build with ADK (or any framework), equip with MCP (or any tool), and communicate with A2A, to remote agents, local agents, and humans.

A2Aのコンセプト

  • フレームワーク(ADK など)を使って、エージェントを構築

  • エージェントに ツール を持たせる(MCP)

  • A2Aでリモートエージェント、ローカルエージェント、 人類やりとり

リモート エージェントと ローカル エージェント

../_images/Agent2Agent-announcement-how-works.png

Announcing the Agent2Agent Protocol (A2A) より引用

サーバとクライアント

リモートエージェント:

A2Aサーバ

ローカルエージェント:

A2Aクライアント

HTTP でやり取り

A2Aサーバの実装

  • GET /.well-known/agent.json

  • POST / (※Agent Cardに記載)

    • JSON RPCでクライアントから呼び出す

agent.json (抜粋)

{
  "name": "Hello World Agent",
  "description": "Just a hello world agent",
  "url": "http://localhost:9999/",
  "skills": [
    {
      "description": "just returns hello world",
      "examples": [
        "hi",
        "hello world"
      ],
      "id": "hello_world",
      "name": "Returns hello world",
      "tags": [
        "hello world"
      ]
    }
  ]
}

JSON RPC

% curl http://0.0.0.0:9999/ --json '{"id": 1, "jsonrpc": "2.0", "method": "message/send", "params": {"message": {"role": "user", "parts": [{"kind": "text", "text": "Hi"}], "messageId": "abc"}}}'
{"id":1,"jsonrpc":"2.0","result":{"kind":"message","messageId":"13c44c32-1fcf-4d27-a3c5-d5fd46583390","parts":[{"kind":"text","text":"Hello World"}],"role":"agent"}}

a2a-sdk

Hello World エージェントとA2A

  • リモート:Hello World (a2a-sdk実装)

  • ローカル: (ADKでつなぎこみ)

ADK: Agent Development Kit

Add A2A support as experimental features (1.6.1)

root_agent = RemoteA2aAgent(
    name="Hello_World_Agent",
    agent_card="http://0.0.0.0:9999/.well-known/agent.json",
)

デモ:ローカル(人)からリモートにメッセージを送信

../_images/A2A-hello-world.png

デモ:ローカル(人)からリモートにメッセージを送信

A2Aサーバ:

uv run . (a2a-samples の Hello World)

A2Aクライアント:

uvx --from 'google-adk[a2a]' adk web (call_from_adk agent)

デモ:ローカル(人)からリモートにメッセージを送信

プロトコル ということは

  • フレームワークによらない

  • プログラミング言語によらない(Python以外)

a2a-sdkを使わない例

  • リモート:オウム返し(FastAPI 実装)

  • ローカル:人(ADKでつなぎこみ)

A2Aに則るので、メッセージをやり取りできます!

% curl http://0.0.0.0:9999/ --json '{"id": 1, "jsonrpc": "2.0", "method": "message/send", "params": {"message": {"role": "user", "parts": [{"kind": "text", "text": "Hi"}], "messageId": "abc"}}}'
{"id":1,"jsonrpc":"2.0","result":{"kind":"message","messageId":"4d1dfebee3af46c8b2c726074de3b536","parts":[{"kind":"text","text":"Hi"}],"role":"agent"}}

デモ:a2a-sdkを使わない例

../_images/A2A-parrot.png

デモ:a2a-sdkを使わない例

A2Aサーバ:

uv run minimum_server.py

A2Aクライアント:

uvx --from 'google-adk[a2a]' adk web (call_from_adk)(再掲)

まとめ🌯:Pythonで Agent2Agent Protocol

  • A2Aは リモートエージェントローカルエージェント のやり取りのためのプロトコル

  • Pythonには a2a-sdk がある

  • ADKなどフレームワークでもサポートが進む(PydanticAI

以上、nikkie(にっきー)でした!

../_images/uzabase-white-logo.png

Thank you for your attention!

Appendix(拙ブログ記事)