🤖

Agentspace を使用したエージェント開発

に公開6

alt text

tl;dr

  • Agentspace は Google Cloud のエージェント開発プラットフォームで、Custom Agent(Agent Engine)を登録して機能を拡張できる

はじめに

この blog では、Agentspace を使用したエージェント開発について書きます。AI エージェントの開発環境は日々進化しており、適切なツールとフレームワークの選択が開発の効率と品質に影響すると考えています。

今回は、Agentspace において、自ら作成した Agent Engine(Custom Agent)を使用して、自然言語での指示を与えることで、エージェントがタスクを実行する方法を紹介します。

Agentspace の概要

https://cloud.google.com/agentspace/docs

Agentspace は、エージェント開発のためのプラットフォームであり、さまざまなデータソースを統合して、エージェントの作成と管理を容易にします。Agentspace を使用することで、開発者はユーザーのニーズに合わせた Custom Agent を迅速に提供することができます。

https://cloud.google.com/agentspace/docs/release-notes

2025年7月31日に GA となりました。

Custom Agent の登録

Agentspace は、Custom Agent を登録することで、Agentspace の機能を拡張できます。Custom Agent は、特定のタスクやデータソースに特化したエージェントであり、以下の手順で登録できます。現時点では、Console 上での登録はできないため、CLI を使用して登録します。(2025年8月12日時点)

https://github.com/VeerMuchandi/agent_registration_tool

config.json の設定

config.json の設定例は、以下の通りです。Custom Agent の登録時に必要な情報のみを設定します。

config.json
{
    "project_id": "project-id",
    "location": "us-central1", 
    "app_id": "agentspace-xxxxxxxxxxxxx_yyyyyyyyyyyyy",
    "ars_display_name": "my-agent",
    "description": "Weather and time answering agent",
    "tool_description": "Agent to answer questions about the time and weather in a city.",
    "adk_deployment_id": "1234567890123456789",
    "auth_id": "",
    "api_location": "global",
    "re_location": "us-central1"
}

Custom Agent を登録する

(.venv) node ➜ /workspaces/agent_registration_tool (main) $ python3 as_registry_client.py register_agent
Enter icon URI (optional): 
INFO:root:Create Agent Command: ['curl', '-X', 'POST', '-H', 'Authorization: Bearer [REDACTED_TOKEN]', '-H', 'Content-Type: application/json', '-H', 'X-Goog-User-Project: [PROJECT_ID]', 'https://discoveryengine.googleapis.com/v1alpha/projects/[PROJECT_ID]/locations/global/collections/default_collection/engines/[ENGINE_ID]/assistants/default_assistant/agents', '-d', '{"displayName": "my-agent", "description": "Weather and time answering agent", "adk_agent_definition": {"tool_settings": {"tool_description": "Agent to answer questions about the time and weather in a city."}, "provisioned_reasoning_engine": {"reasoning_engine": "projects/[PROJECT_ID]/locations/us-central1/reasoningEngines/[ENGINE_ID]"}, "authorizations": []}}']
{
  "status_code": 0,
  "stdout": "{\n  \"name\": \"projects/[PROJECT_NUMBER]/locations/global/collections/default_collection/engines/[ENGINE_ID]/assistants/default_assistant/agents/[AGENT_ID]\",\n  \"displayName\": \"my-agent\",\n  \"description\": \"Weather and time answering agent\",\n  \"createTime\": \"2025-08-12T00:35:52.186193605Z\",\n  \"adkAgentDefinition\": {\n    \"toolSettings\": {\n      \"toolDescription\": \"Agent to answer questions about the time and weather in a city.\"\n    },\n    \"provisionedReasoningEngine\": {\n      \"reasoningEngine\": \"projects/[PROJECT_ID]/locations/us-central1/reasoningEngines/[ENGINE_ID]\"\n    }\n  },\n  \"state\": \"ENABLED\"\n}\n",
  "stderr": "  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current\n                                 Dload  Upload   Total   Spent    Left  Speed\n\n  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0\n100   382    0     0  100   382      0    316  0:00:01  0:00:01 --:--:--   316\n100  1038    0   656  100   382    447    260  0:00:01  0:00:01 --:--:--   708\n",
  "agent": {
    "name": "projects/[PROJECT_NUMBER]/locations/global/collections/default_collection/engines/[ENGINE_ID]/assistants/default_assistant/agents/[AGENT_ID]",
    "displayName": "my-agent",
    "description": "Weather and time answering agent",
    "createTime": "2025-08-12T00:35:52.186193605Z",
    "adkAgentDefinition": {
      "toolSettings": {
        "toolDescription": "Agent to answer questions about the time and weather in a city."
      },
      "provisionedReasoningEngine": {
        "reasoningEngine": "projects/[PROJECT_ID]/locations/us-central1/reasoningEngines/[ENGINE_ID]"
      }
    },
    "state": "ENABLED"
  }
}
(.venv) node ➜ /workspaces/agent_registration_tool (main) $ 

Summary

Agent Engine を Agentspace へ登録することで、Agentspace の機能を拡張できます。Custom Agent を使用することで、特定のタスクやデータソースに特化したエージェントを迅速に提供できます。

Closing

AI Agent は従来のアプリと異なり、自律性を持たせるが故に、非決定論的な挙動をすることがあります。「決定論的な考え方」と「非決定論的な考え方」の併用は、AI エージェントの開発において重要なポイントだと思います。なぜなら、言語モデルが推論を重ねることで、予期しない結果を生むことがあるからです。現状の AI エージェントの開発においては、非決定論的な挙動を理解し、適切に制御することが求められると考えます。

GitHubで編集を提案

Discussion

sronnsronn

Agentspace Enterprise Plusの無料トライアルでAgent Spaceを触っているものです。

「現時点では、Console 上での登録はできないため、CLI を使用して登録します。(2025年8月12日時点)」
こちらが気になったので一点質問があります。

Agentspace ウェブアプリの「エージェント」タブにはMade by Googleの3つのデフォルト機能しか表示されず、カスタムエージェントを作成するのボタンがないのですが、この原因をもしご存知でしたらご教授願いたいです。

・一般公開にはそもそもない(早期プログラムのみ)
・無料トライアルだとなくて、課金開始で提供される
など、原因をご存知でしたら、教えていただきたいです。

コメントで質問して恐縮です。。

Daisuke YamamotoDaisuke Yamamoto

Web コンソールからの Custom Agent の登録は未実装だと思います。(この記事作成時点で Google のカスタマーエンジニアに確認しました)
現時点では、CLI 経由でみ Custom Agent を作成(紐付け)できます。
従って、Custom Agent を Agentspace で使えるようにするには、

  1. ADK でエージェントを実装する(この blog に載せている Weahter のエージェントは ADK の公式のサンプルです)
  2. Agent Engine にエージェントを登録する
  3. この記事にある エージェント登録ツールを実行する
    という流れが必要になります。
    ご参考までに。
sronnsronn

Google のカスタマーエンジニアに確認された情報を共有いただき、誠に感謝いたします。
非常に参考になりました、ご返信ありがとうございます!

dddyyydddyyy

この記事を拝見して、勉強になりました。自分CLI 経由でagentを登録するときに、下のerrorが発生しまいました。もし原因をご存知でしたら、教えていただきたいです。ありがとうございました
{
"status_code": 0,
"stdout": "{\n "error": {\n "code": 404,\n "message": "Method not found.",\n "status": "NOT_FOUND"\n }\n}\n",
"stderr": " % Total % Received % Xferd Average Speed Time Time Time Current\n Dload Upload Total Spent Left Speed\n\n 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\n100 660 0 100 100 560 290 1627 --:--:-- --:--:-- --:--:-- 1924\n",
"agent": {
"error": {
"code": 404,
"message": "Method not found.",
"status": "NOT_FOUND"
}
}
}

Daisuke YamamotoDaisuke Yamamoto

僕はそのエラーに遭遇していないため、参考になるか分かりませんが、Location の問題なのかなと推測します。Agentspace は現状全ての Region に展開されておらず、curl の実行先によっては、API が存在しない可能性が考えられます。

dddyyydddyyy

返信ありがとうございます。
上のtools利用したapiを調査してみました. Document中にはこのapiの定義ありそうです。(https://cloud.google.com/agentspace/docs/reference/rest/v1alpha/projects.locations.collections.engines.assistants.agents/create)

でも直接curlでapiを実行すると、同じerrorが発生しました。例えば登録したagentsをlistする場合に
(location: global)

% curl -X GET \                              
  -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  -H "Content-Type: application/json" \
  -H "X-Goog-User-Project: xxx" \
  "https://discoveryengine.googleapis.com/v1alpha/projects/xxx/locations/global/collections/default_collection/engines/xxx/assistants/default_assistant/agents"
{
  "error": {
    "code": 404,
    "message": "Method not found.",
    "status": "NOT_FOUND"
  }
}

agentを登録:

% curl -X POST \
>   -H "Authorization: Bearer $(gcloud auth print-access-token)" \
>   -H "Content-Type: application/json" \
>   -H "X-Goog-User-Project: xxx" \
>   "https://discoveryengine.googleapis.com/v1alpha/projects/xxx/locations/globa
l/collections/default_collection/engines/xxx/assistants/default_assist
ant/agents"
{
  "error": {
    "code": 404,
    "message": "Method not found.",
    "status": "NOT_FOUND"
  }
}

Assistant levelまでは実行できそうですが, /agents までのapiはなさそうです。

% curl -X GET \            
  -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  -H "Content-Type: application/json" \
  -H "X-Goog-User-Project: xxx" \
  "https://discoveryengine.googleapis.com/v1alpha/projects/dxxx/locations/global/collections/default_collection/engines/xxx/assistants/default_assistant"
{
  "name": "projects/xxx/locations/global/collections/default_collection/engines/xxx/assistants/default_assistant",
  "webGroundingType": "WEB_GROUNDING_TYPE_ENTERPRISE_WEB_SEARCH",
  "customerPolicy": {},
  "generationConfig": {
    "systemInstruction": {}
  }
}

Locationは globalで設定していますが、googleは今apiの開発まだ完成してない、previewの状態の可能性ありますでしょうか (機能は申請ベースで使えるかなど)