Skip to content

Agent2Agentプロトコル

Agent2Agent (A2A)プロトコルは、AIエージェント間の相互運用性を実現します。 DataRobotのモデルレジストリに外部エージェントを登録し、エージェントカードを添付することで、そのエージェントを検出できるようになります。

このページでは、以下の概要に示すように、エンドツーエンドのワークフローについて説明します。

  1. モデルレジストリに外部モデルを登録する。
  2. 外部予測環境を作成する。
  3. 登録モデルのバージョンをデプロイする。
  4. エージェントカードをデプロイにアップロードする。

これらの手順を完了すると、エージェントはDataRobot内でA2Aインタラクションを利用できるようになります。

前提条件

import datarobot as dr

# Authenticate with the DataRobot API
dr.Client(token="YOUR_API_TOKEN", endpoint="https://app.datarobot.com/api/v2") 

外部モデルの登録

外部エージェントのために登録モデルバージョンを作成するには、RegisteredModelVersion.create_for_externalを使用します。 targetパラメーターは、ExternalTarget型の辞書を使用します。

DataRobotでは、エージェント専用のターゲットタイプが用意されています。type"AgenticWorkflow"に設定してください。

import datarobot as dr

registered_model_version = dr.RegisteredModelVersion.create_for_external(
    name="My A2A Agent v1",
    target={"name": "target", "type": "AgenticWorkflow"},
    registered_model_name="My A2A Agent",
)

registered_model_version.id
>>> '66a1b2c3d4e5f6a7b8c9d0e1'
registered_model_version.registered_model_id
>>> '66a1b2c3d4e5f6a7b8c9d0e2' 

すでに登録済みのモデルがあり、新しいバージョンを追加したい場合は、registered_model_nameの代わりにregistered_model_idを渡します。

new_version = dr.RegisteredModelVersion.create_for_external(
    name="My A2A Agent v2",
    target={"name": "target", "type": "AgenticWorkflow"},
    registered_model_id=registered_model_version.registered_model_id,
) 

登録モデルの管理の詳細については、モデルレジストリのドキュメントを参照してください。

外部予測環境の作成

外部のエージェントワークフローモデルは、外部予測環境にデプロイする必要があります。 通常のDataRobot予測サーバーへのデプロイはサポートされておらず、422エラーが発生します。

外部予測環境を作成するには、PredictionEnvironment.createを使用します。 エージェントがホストされている環境に合わせて、platformの値を選択します(例:"aws""gcp""azure"、または"other")。

import datarobot as dr
from datarobot.enums import PredictionEnvironmentPlatform

prediction_environment = dr.PredictionEnvironment.create(
    name="A2A Agent Environment",
    platform=PredictionEnvironmentPlatform.OTHER,
    description="External prediction environment for A2A agents",
)

prediction_environment.id
>>> '66a0b1c2d3e4f5a6b7c8d9e0' 

適切な外部予測環境がすでにある場合は、それを再利用できます。

prediction_environments = dr.PredictionEnvironment.list()
prediction_environment = prediction_environments[0] 

登録されたモデルのデプロイ

登録モデルのバージョンからデプロイを作成するには、Deployment.create_from_registered_model_versionを使用します。 (default_prediction_server_idではなく)prediction_environment_idを渡します。これは、エージェントワークフローのターゲットに必須です。

import datarobot as dr

deployment = dr.Deployment.create_from_registered_model_version(
    model_package_id=registered_model_version.id,
    label="My A2A Agent Deployment",
    description="External A2A agent deployment",
    prediction_environment_id=prediction_environment.id,
)

deployment.id
>>> '66b2c3d4e5f6a7b8c9d0e1f2' 

デプロイ管理の詳細については、デプロイのドキュメントを参照してください。

エージェントカードのアップロード

A2Aエージェントカードをデプロイに添付するには、Deployment.upload_agent_cardを使用します。 エージェントカードは、A2Aエージェントカードの仕様に従った、エージェントの機能とメタデータを記述する辞書です。

agent_card = {
    "name": "My A2A Agent",
    "description": "An agent that performs data analysis tasks.",
    "version": "1.0.0",
    "url": "https://my-agent.example.com/a2a",
    "capabilities": {
        "streaming": True,
        "pushNotifications": False,
    },
    "skills": [
        {
            "id": "data-analysis",
            "name": "Data Analysis",
            "description": "Analyzes datasets and provides statistical summaries.",
        }
    ],
}

uploaded_card = deployment.upload_agent_card(agent_card) 

アップロード後、エージェントはA2AエージェントとしてDataRobotレジストリで利用可能になります。

エージェントカードの取得

既存のデプロイからエージェントカードを取得するには、Deployment.get_agent_cardを使用します。

agent_card = deployment.get_agent_card()
agent_card["name"]
>>> 'My A2A Agent' 

エージェントカードの削除

デプロイからエージェントカードを削除するには、Deployment.delete_agent_cardを使用します。 この操作はべき等です。エージェントカードが存在しない場合でも、正常に返されます。

deployment.delete_agent_card() 

A2Aエージェントのデプロイを検出する

A2Aエージェントカードを持つデプロイのみを一覧表示するには、DeploymentListFiltersis_a2a_agentフィルターを使用します。

import datarobot as dr
from datarobot.models.deployment import DeploymentListFilters

filters = DeploymentListFilters(is_a2a_agent=True)
a2a_deployments = dr.Deployment.list(filters=filters)
a2a_deployments
>>> [Deployment('My A2A Agent Deployment'), Deployment('Another A2A Agent')] 

その後、検出されたデプロイからエージェントカードを取得し、A2Aインタラクションを開始する前にその機能を確認することができます。

for dep in a2a_deployments:
    card = dep.get_agent_card()
    print(f"{card['name']} (v{card['version']}): {card['description']}") 

完全な例

次に、外部A2Aエージェントを登録する完全なフローの例を示します。

import datarobot as dr
from datarobot.enums import PredictionEnvironmentPlatform
from datarobot.models.deployment import DeploymentListFilters

# 1. Connect to DataRobot
dr.Client(token="YOUR_API_TOKEN", endpoint="https://app.datarobot.com/api/v2")

# 2. Register an external model
registered_model_version = dr.RegisteredModelVersion.create_for_external(
    name="Research Assistant Agent v1",
    target={"name": "target", "type": "AgenticWorkflow"},
    registered_model_name="Research Assistant Agent",
)

# 3. Create an external prediction environment
prediction_environment = dr.PredictionEnvironment.create(
    name="A2A Agent Environment",
    platform=PredictionEnvironmentPlatform.OTHER,
    description="External prediction environment for A2A agents",
)

# 4. Deploy the registered model
deployment = dr.Deployment.create_from_registered_model_version(
    model_package_id=registered_model_version.id,
    label="Research Assistant Agent",
    description="An A2A agent that assists with research tasks.",
    prediction_environment_id=prediction_environment.id,
)

# 5. Upload the agent card
agent_card = {
    "name": "Research Assistant",
    "description": "Assists with literature review, summarization, and citation management.",
    "version": "1.0.0",
    "url": "https://research-agent.example.com/a2a",
    "capabilities": {
        "streaming": True,
        "pushNotifications": False,
    },
    "skills": [
        {
            "id": "literature-review",
            "name": "Literature Review",
            "description": "Searches and summarizes academic papers on a given topic.",
        },
        {
            "id": "citation-management",
            "name": "Citation Management",
            "description": "Formats and organizes citations in various styles.",
        },
    ],
}
deployment.upload_agent_card(agent_card)

# 6. Verify the agent is available for A2A protocol
filters = DeploymentListFilters(is_a2a_agent=True)
a2a_deployments = dr.Deployment.list(filters=filters)
for dep in a2a_deployments:
    card = dep.get_agent_card()
    print(f"{card['name']} (v{card['version']}): {card['description']}")