# Agent2Agentプロトコル

> Agent2Agentプロトコル - DataRobot内のAIエージェント間の相互運用性を有効にします。

This Markdown file sits beside the HTML page at the same path (with a `.md` suffix). It summarizes the topic and lists links for tools and LLM context.

Companion generated at `2026-07-23T18:01:59.401850+00:00` (UTC).

## Primary page

- [Agent2Agentプロトコル](https://docs.datarobot.com/ja/docs/api/dev-learning/python/mlops/a2a.html.md): Full documentation for this topic (Markdown sidecar).

## Sections on this page

- [前提条件](https://docs.datarobot.com/ja/docs/api/dev-learning/python/mlops/a2a.html.md#prerequisites): In-page section heading.
- [外部モデルの登録](https://docs.datarobot.com/ja/docs/api/dev-learning/python/mlops/a2a.html.md#register-an-external-model): In-page section heading.
- [外部予測環境の作成](https://docs.datarobot.com/ja/docs/api/dev-learning/python/mlops/a2a.html.md#create-an-external-prediction-environment): In-page section heading.
- [登録されたモデルのデプロイ](https://docs.datarobot.com/ja/docs/api/dev-learning/python/mlops/a2a.html.md#deploy-the-registered-model): In-page section heading.
- [エージェントカードのアップロード](https://docs.datarobot.com/ja/docs/api/dev-learning/python/mlops/a2a.html.md#upload-an-agent-card): In-page section heading.
- [エージェントカードの取得](https://docs.datarobot.com/ja/docs/api/dev-learning/python/mlops/a2a.html.md#retrieve-an-agent-card): In-page section heading.
- [エージェントカードの削除](https://docs.datarobot.com/ja/docs/api/dev-learning/python/mlops/a2a.html.md#delete-an-agent-card): In-page section heading.
- [A2Aエージェントのデプロイを検出する](https://docs.datarobot.com/ja/docs/api/dev-learning/python/mlops/a2a.html.md#discover-a2a-agent-deployments): In-page section heading.
- [完全な例](https://docs.datarobot.com/ja/docs/api/dev-learning/python/mlops/a2a.html.md#full-example): In-page section heading.

## Documentation content

[Agent2Agent (A2A)](https://google.github.io/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](https://docs.datarobot.com/ja/docs/api/reference/sdk/datarobot-models.html.md#datarobot.models.model_registry.RegisteredModelVersion.create_for_external) を使用します。 `target` パラメーターは、 [ExternalTarget](https://docs.datarobot.com/ja/docs/api/reference/sdk/datarobot-models.html.md#datarobot.models.model_registry.registered_model_version.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,
) 
```

登録モデルの管理の詳細については、 [モデルレジストリのドキュメント](https://docs.datarobot.com/ja/docs/api/dev-learning/python/mlops/model_registry.html.md#model-registry) を参照してください。

## 外部予測環境の作成

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

外部予測環境を作成するには、 [PredictionEnvironment.create](https://docs.datarobot.com/ja/docs/api/reference/sdk/deployment-management.html.md#datarobot.models.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](https://docs.datarobot.com/ja/docs/api/reference/sdk/deployment-management.html.md#datarobot.models.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' 
```

デプロイ管理の詳細については、 [デプロイのドキュメント](https://docs.datarobot.com/ja/docs/api/dev-learning/python/mlops/deployment.html.md#deployments) を参照してください。

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

A2Aエージェントカードをデプロイに添付するには、 [Deployment.upload_agent_card](https://docs.datarobot.com/ja/docs/api/reference/sdk/deployment-management.html.md#datarobot.models.Deployment.upload_agent_card) を使用します。 エージェントカードは、 [A2Aエージェントカードの仕様](https://google.github.io/A2A/#/documentation?id=agent-card) に従った、エージェントの機能とメタデータを記述する辞書です。

```
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](https://docs.datarobot.com/ja/docs/api/reference/sdk/deployment-management.html.md#datarobot.models.Deployment.get_agent_card) を使用します。

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

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

デプロイからエージェントカードを削除するには、 [Deployment.delete_agent_card](https://docs.datarobot.com/ja/docs/api/reference/sdk/deployment-management.html.md#datarobot.models.Deployment.delete_agent_card) を使用します。 この操作はべき等です。エージェントカードが存在しない場合でも、正常に返されます。

```
deployment.delete_agent_card() 
```

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

A2Aエージェントカードを持つデプロイのみを一覧表示するには、 [DeploymentListFilters](https://docs.datarobot.com/ja/docs/api/reference/sdk/deployment-management.html.md#datarobot.models.deployment.DeploymentListFilters) で `is_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']}") 
```
