💻

[ADK] What's new in 1.17.0 - Computer Use、ツールの再実行、セッションの巻き戻し

に公開

こんにちは、サントリーこと大橋です。

2025/10/22にAgent Development Kit(以降ADK) 1.17.0がリリースされました。

https://github.com/google/adk-python/releases/tag/v1.17.0

今回のリリースでは、いくつかの目的の異なる機能が追加されています。そのため、本記事ではリリース全体の概要を説明し、いくつかの機能をピックアップして詳しく見ていきます。

本記事では、そのうち以下の機能について説明します。

  • Rewind a session to before a previous invocation
  • Add a service registry to provide a generic way to register custom service implementations to be used in FastAPI server
  • Introduces a new AgentEngineSandboxCodeExecutor class that supports executing agent-generated code using the Vertex AI Code Execution Sandbox API
  • Extend ReflectAndRetryToolPlugin to support hallucinating function calls
  • ComputerUse Toolset

対象

  • ADKを触ったことがあるPythonユーザー
  • AIエージェント向けのUIを作成したいと思っている開発者

なお本記事中ではADKのAgentをAgent、それ以外のAIエージェントをエージェントと表記します。

What's new in 1.17.0

まずは1.17.0のリリースノートを見てみましょう。

Features

  • [Core]

    • Add a service registry to provide a generic way to register custom service implementations to be used in FastAPI server. See short instruction here. (391628f)
    • Add the ability to rewind a session to before a previous invocation (9dce06f)
    • Support resuming a parallel agent with multiple branches paused on tool confirmation requests (9939e0b)
    • Support content union as static instruction (cc24d61)
  • [Evals]

    • ADK cli allows developers to create an eval set and add an eval case (ae139bb)
  • [Integrations]

    • Allow custom request and event converters in A2aAgentExecutor (a17f3b2)
  • [Observability]

    • Env variable for disabling llm_request and llm_response in spans (e50f05a)
  • [Services]

    • Allow passing extra kwargs to create_session of VertexAiSessionService (6a5eac0)
    • Implement new methods in in-memory artifact service to support custom metadata, artifact versions, etc. (5a543c0)
    • Add create_time and mime_type to ArtifactVersion (2c7a342)
    • Support returning all sessions when user id is none (141318f)
  • [Tools]

    • Support additional headers for Google API toolset (ed37e34)
    • Introduces a new AgentEngineSandboxCodeExecutor class that supports executing agent-generated code using the Vertex AI Code Execution Sandbox API (ee39a89)
    • Support dynamic per-request headers in MCPToolset (6dcbb5a)
    • Add bypass_multi_tools_limit option to GoogleSearchTool and VertexAiSearchTool (9a6b850, 6da7274)
    • Extend ReflectAndRetryToolPlugin to support hallucinating function calls (f51380f)
    • Add require_confirmation param for MCP tool/toolset (78e74b5)
  • [UI]

    • Granular per agent speech configuration (409df13)

Bug Fixes

  • Returns dict as result from McpTool to comply with BaseTool expectations (4df9263)
  • Fixes the identity prompt to be one line (7d5c6b9)
  • Fix the broken langchain importing caused their 1.0.0 release (c850da3)
  • Fix BuiltInCodeExecutor to support visualizations (ce3418a)
  • Relax runner app-name enforcement and improve agent origin inference (dc4975d)
  • Improve error message when adk web is run in wrong directory (4a842c5)
  • Handle App objects in eval and graph endpoints (0b73a69)
  • Exclude additionalProperties from Gemini schemas (307896a)
  • Overall eval status should be NOT_EVALUATED if no invocations were evaluated (9fbed0b)
  • Create context cache only when prefix matches with previous request (9e0b1fb)
  • Handle App instances returned by agent_loader.load_agent (847df16)
  • Add support for file URIs in LiteLLM content conversion (85ed500)
  • Only exclude scores that are None (998264a)
  • Better handling the A2A streaming tasks (bddc70b)
  • Correctly populate context_id in remote_a2a_agent library (2158b3c)
  • Remove unnecessary Aclosing (2f4f561)
  • Fix pickle data was truncated error in database session using MySql (36c96ec)

Improvements

  • Improve hint message in agent loader (fe1fc75)
  • Fixes MCPToolset --> McpToolset in various places (d4dc645)
  • Add span for context caching handling and new cache creation (a2d9f13)
  • Checks gemini version for 2 and above for gemini-builtin tools (0df6759)
  • Refactor and fix state management in the session service (8b3ed05)
  • Update agent builder instructions and remove run command details (89344da)
  • Clarify how to use adk built-in tool in instruction (d22b8bf)
  • Delegate the agent state reset logic to LoopAgent (bb1ea74)
  • Adjust the instruction about default model (214986e)
  • Migrate invocation_context to callback_context (e2072af)
  • Correct the callback signatures (fa84bcb)
  • Set default for bypass_multi_tools_limit to False for GoogleSearchTool and VertexAiSearchTool (6da7274)
  • Add more clear instruction to the doc updater agent about one PR for each recommended change (b21d0a5)
  • Add a guideline to avoid content deletion (16b030b)
  • Add an sample agent for the ReflectAndRetryToolPlugin (9b8a4aa)
  • Improve error message when adk web is run in wrong directory (4a842c5)
  • Add an sample agent for the ReflectAndRetryToolPlugin (9b8a4aa)
  • Add span for context caching handling and new cache creation (a2d9f13)
  • Disable the scheduled execution for issue triage workflow (bae2102)
  • Correct the callback signatures (fa84bcb)

Documentation

  • Format README.md for samples (0bdba30)
  • Bump models in llms and llms-full to Gemini 2.5 (ce46386)
  • Update gemini_llm_connection.py - typo spelling correction (e6e2767)
  • Announce the first ADK Community Call in the README (731bb90)

主な和訳は以下の通りです。

機能 (Features)

  • [コア]

    • FastAPIサーバーで使用するカスタムサービス実装を登録するための汎用的な方法として、サービスレジストリを追加。
    • 以前の呼び出し前の状態にセッションを巻き戻す機能を追加。
    • ツール確認リクエストで一時停止した複数のブランチを持つ並列エージェントの再開をサポート。
    • 静的インストラクションとしてコンテントユニオンをサポート。
  • [評価]

    • ADK CLIで評価セットの作成と評価ケースの追加が可能に。
  • [統合]

    • A2aAgentExecutorでカスタムリクエストとイベントコンバーターを許可。
  • [可観測性]

    • スパン内のllm_requestとllm_responseを無効にするための環境変数を追加。
  • [サービス]

    • VertexAiSessionServiceのcreate_sessionに余分なkwargsを渡すことを許可。
    • カスタムメタデータ、アーティファクトバージョンなどをサポートするために、インメモリアーティファクトサービスの新しいメソッドを実装。
    • ArtifactVersionにcreate_timeとmime_typeを追加。
    • ユーザーIDがnoneの場合にすべてのセッションを返すようにサポート。
  • [ツール]

    • Google APIツールセットの追加ヘッダーをサポート。
    • Vertex AI Code Execution Sandbox APIを使用してエージェントが生成したコードの実行をサポートする、新しいAgentEngineSandboxCodeExecutorクラスを導入。
    • MCPToolsetで動的なリクエストごとのヘッダーをサポート。
    • GoogleSearchToolとVertexAiSearchToolにbypass_multi_tools_limitオプションを追加。
    • ReflectAndRetryToolPluginを拡張し、誤った関数呼び出し(hallucinating function calls)をサポート。
    • MCPツール/ツールセットにrequire_confirmationパラメータを追加。
  • [UI]

    • エージェントごとの詳細な音声設定。

バグ修正

  • McpToolからdictを結果として返し、BaseToolの期待に準拠するように修正。
  • IDプロンプトを1行に修正。
  • LangChain 1.0.0リリースによる壊れたインポートを修正。
  • BuiltInCodeExecutorが可視化をサポートするように修正。
  • ランナーのアプリ名強制を緩和し、エージェントのオリジン推論を改善。
  • 間違ったディレクトリでadk webを実行した際のエラーメッセージを改善。
  • evalおよびgraphエンドポイントでAppオブジェクトを処理。
  • GeminiスキーマからadditionalPropertiesを除外。
  • 評価された呼び出しがない場合、全体の評価ステータスをNOT_EVALUATEDにするように修正。
  • プレフィックスが以前のリクエストと一致する場合にのみコンテキストキャッシュを作成するように修正。
  • agent_loader.load_agentから返されるAppインスタンスを処理。
  • LiteLLMのコンテント変換でファイルURIをサポート。
  • Noneのスコアのみを除外するように修正。
  • A2Aストリーミングタスクの処理を改善。
  • remote_a2a_agentライブラリでcontext_idを正しく設定。
  • 不要なAclosingを削除。
  • MySqlを使用したデータベースセッションでのpickleデータ切り捨てエラーを修正。

改善

  • エージェントローダーのヒントメッセージを改善。
  • MCPToolset -> McpToolsetへの修正(様々な箇所)。
  • コンテキストキャッシュ処理と新しいキャッシュ作成のためのスパンを追加。
  • gemini-builtinツール用にgeminiバージョン「2以上」をチェック。
  • セッションサービスのステート管理をリファクタリング・修正。
  • エージェントビルダーのインストラクションを更新し、実行コマンドの詳細を削除。
  • ADK組み込みツールの使用方法をインストラクションで明確化。
  • エージェントの状態リセットロジックをLoopAgentに委任。
  • デフォルトモデルに関するインストラクションを調整。
  • invocation_contextをcallback_contextに移行。
  • コールバックのシグネチャを修正。
  • GoogleSearchToolとVertexAiSearchToolのbypass_multi_tools_limitのデフォルトをFalseに設定。
  • ドキュメント更新エージェントに、推奨される変更ごとに1つのPRを出すよう、より明確な指示を追加。
  • コンテンツ削除を避けるためのガイドラインを追加。
  • ReflectAndRetryToolPluginのサンプルエージェントを追加。
  • 間違ったディレクトリでadk webを実行した際のエラーメッセージを改善。
  • コンテキストキャッシュ処理と新しいキャッシュ作成のためのスパンを追加。
  • Issueトリアージワークフローのスケジュール実行を無効化。
  • コールバックのシグネチャを修正。

ドキュメント

  • サンプル用のREADME.mdをフォーマット。
  • llmsとllms-fullのモデルをGemini 2.5に引き上げ。
  • gemini_llm_connection.pyのタイポを修正。
  • READMEに初のADK Community Callを告知。

Pick up Feature

以降は今回のリリースからいくつかの機能をピックアップして解説していきます。

1. Add the ability to rewind a session to before a previous invocation

Runnerに対して、特定の実行ID(invocation_id)より以前の状態にsessionを巻き戻す、rewind_async が追加されました。
これにより、特定のツール実行後やLLMの応答の後に状態を巻き戻し、別のツールを実行したり、異なるプロンプトで再度LLMを呼び出すといったことが可能になります。

これまでもセッションの状態を直接操作することで同様のことは実現できましたが、より公式で安全な方法が提供されたことになります。

from google.adk.runners import Runner

runner: Runner = ...
invocation_id_to_rewind: str = ...

# 指定したinvocation_idの直前の状態までセッションを巻き戻す
await runner.rewind_async(
    user_id="user_id",
    session_id="session_id",
    invocation_id=invocation_id_to_rewind,
)

この機能により、UI上でユーザーが「この操作を取り消して、代わりにこちらを実行する」といったインタラクティブな操作を実現する際のバックエンド実装が容易になります。
なお、現状この機能はadk webなどには実装されていないため、ADK FastAPIサーバーに組み込む場合は、自分でAPIを追加する必要があります。

2. Add a service registry

ADKのFastAPIサーバーで、独自のカスタムサービス実装を登録するための汎用的な方法として、サービスレジストリが追加されました。

これまで、InMemorySessionServiceVertexAiSessionService以外のSessionService(例: DatabaseSessionService等)を利用したい場合、自前でRunnerを実装する必要がありました。

今回のアップデートで追加されたServiceRegistryを利用することで、adk webコマンドの仕組みにカスタムサービスを注入できるようになりました。これにより、例えば redis_session_service のようなコミュニティ提供のカスタムセッションサービスを、ADKのFastAPIサーバーで利用できるようになります。

以下のように、起動用のスクリプト(例: test_run.py)で、使用したいサービスを事前に登録します。

test_run.py
from google.adk.cli import cli_tools_click
from google.adk.cli.service_registry import get_service_registry
# この例ではコミュニティ提供のRedisSessionServiceを利用
from google.adk_community.sessions import redis_session_service

def redis_session_service_factory(uri: str, **kwargs):
    """Factory for creating a RedisSessionService."""
    kwargs_copy = kwargs.copy()
    kwargs_copy.pop("agents_dir", None)
    return redis_session_service.RedisSessionService(**kwargs_copy)

# グローバルなサービスレジストリを取得し、"redis"という名前でファクトリを登録
registry = get_service_registry()
registry.register_session_service("redis", redis_session_service_factory)


if __name__ == '__main__':
    # ADKのCLIツールを実行
    cli_tools_click.main()

そしてこのスクリプト経由を実行し、--session_service_uri で登録したサービスを指定します。

python test_run.py web contributing/samples/ --session_service_uri=redis://

これにより、ADK FastAPIサーバーが提供する便利な機能はそのままに、バックエンドのサービスだけをRedisベースのセッション管理に切り替えることができます。
なおこの機能も現状adk webなどでは、adk webで起動するFastAPIサーバーが起動する前に、処理を差し込むことが難しいため、上記のように自前で cli_tools_click.main() を呼び出すスクリプトを記載して、起動する必要があります。

3. Introduces a new AgentEngineSandboxCodeExecutor class

ADK Agentに、コードを実行させるためのcode_executorとして、新しくAgentEngineSandboxCodeExecutorが追加されました。
これは、Vertex AIのAgent Engineが提供する安全なサンドボックス環境で、AIが生成したコードを実行するためのものです。

Agent EngineのCode Execution機能は、特定のプログラミング言語、処理能力、メモリ構成を持つサンドボックス環境をVertex AI(Google Cloud)上に作成し、その中でコードを実行します。実行後も状態が保持されるため、変数を引き継いだり、複数ステップにわたる複雑なデータ分析タスクを実行したりするのに非常に強力です。

https://docs.cloud.google.com/agent-builder/agent-engine/code-execution/overview

使い方は、Agentcode_executorAgentEngineSandboxCodeExecutorのインスタンスを渡すだけです。
sandbox_resource_nameには、事前にAgent Engineで作成したサンドボックスのリソース名を指定します。

from google.adk.agents.llm_agent import Agent
from google.adk.code_executors.agent_engine_sandbox_code_executor import AgentEngineSandboxCodeExecutor
import os

project_id = os.getenv("GOOGLE_CLOUD_PROJECT")
location_id = os.getenv("GOOGLE_CLOUD_LOCATION")
agent_engine_id = os.getenv("AGENT_ENGINE_ID")
sandbox_environment_id = os.getenv("SANDBOX_ENVIRONMENT_ID")

root_agent = Agent(
    model="gemini-2.5-flash",
    name="agent_engine_code_execution_agent",
    instruction="あなたはコードを書いて問題を解決するエージェントです。",
    code_executor=AgentEngineSandboxCodeExecutor(
        sandbox_resource_name=f"projects/{project_id}/locations/{location_id}/reasoningEngines/{agent_engine_id}/sandboxEnvironments/{sandbox_environment_id}",
        # または、agent_engine_resource_name=f"projects/{project_id}/locations/{location_id}/reasoningEngines/{agent_engine_id}",
    ),
)

Code Executor Sandbox環境が作成済みの場合はsandbox_resource_namef"projects/{project_id}/locations/{location_id}/reasoningEngines/{agent_engine_id}/sandboxEnvironments/{sandbox_environment_id}"の形式で指定します。
まだ作成していない場合は、agent_engine_resource_namef"projects/{project_id}/locations/{location_id}/reasoningEngines/{agent_engine_id}の形式で、Agent EngineのIDを指定します。
そうするとAgentEngineSandboxCodeExecutorのコンストラクタで、Code Executor Sandbox環境を作成してくれます。

4. Extend ReflectAndRetryToolPlugin to support hallucinating function calls

ReflectAndRetryToolPluginは、ツールの実行が失敗した際に、そのエラー内容をエージェント自身に自動的にフィードバックし、異なる引数で再試行するためのプラグインです。

今回のアップデートでこのプラグインが拡張され、モデルが誤ったツール名でツールを呼び出してしまう「ツール実行のハルシネーション」が発生した際にも、リトライ処理が機能するようになりました。

例えば、search_web(query: str) というツールしかないにも関わらず、モデルがsearch_web(query: "example.com")のようにツールを呼び出そうとした場合に、ReflectAndRetryToolPluginがそのエラーを検知し、正しいツール名で再実行を促す、といった動作が期待できます。

ReflectAndRetryToolPlugin はCallbackにて、ツールのエラーを検知し、Agentが指定しているモデルに対して、エラーがあった旨と、そのエラー内容、問題の解決方法を伝えて、再実行を促します。

adk-pythonリポジトリのサンプルでは、after_model_callbackCallbackを利用して、実行するツール名を書き換えて、ハルシネーションを擬似的に発生させています。
実際にどれだけツール名を誤るようなハルシネーションが発生するかはわかりませんが、特段理由がなければ、ReflectAndRetryToolPluginは設定しておいたほうが良さそうなプラグインですね。

https://github.com/google/adk-python/blob/main/contributing/samples/plugin_reflect_tool_retry/hallucinating_func_name/agent.py

5. ComputerUse Toolset

リリースノートには記載されていませんが、ComputerUseToolsetが追加され、利用可能になりました。
これは、エージェントがコンピュータのUI(現時点ではブラウザ)を操作するためのツールセットです。

Computer Useのコード自体は以前からひっそりとadk-python内に含まれていたのですが、
先日Geminiに、このComputerUseが追加され、利用可能な状態になりました。

https://ai.google.dev/gemini-api/docs/computer-use?hl=ja
https://cloud.google.com/vertex-ai/generative-ai/docs/computer-use

このツールセットを利用するには、特別なモデル gemini-2.5-computer-use-preview-10-2025 を使用する必要があります。

ADKにおけるComputer Useの実装は、他のADKサービスなどと同様に抽象化されており、ブラウザの利用に限っているわけではありません。
google.adk.tools.computer_use.base_computer.BaseComputer を継承したクラスを作成すれば、
モデルが対応していれば、どのような環境も操作が可能になる...はずです。
なお現状 gemini-2.5-computer-use-preview-10-2025 モデルはブラウザの利用のみを想定しているようです。

https://github.com/google/adk-python/blob/main/src/google/adk/tools/computer_use/base_computer.py

ただ現状、その実装クラスは adk-python には直接含まれておらず、
adk-pythonのサンプルにPlaywrightを利用した実装クラスが含まれているのみです。

https://github.com/google/adk-python/blob/main/contributing/samples/computer_use/playwright.py

なので、このツールセットを利用するには、まず BaseComputerの実装クラスの準備が必要となります。
今回は、色々大変なので上記サンプル実装を利用してみましょう。

このサンプル実装を利用するには、まずPlaywrightとその他の依存関係が必要となります。

uv add termcolor playwright browserbase rich

またPlaywright自体の依存(Chromium等)もインストールします。

playwright install-deps chromium
playwright install chromium

そしてAgentを作成します。

adk create computer_use_demo

次にBaseComputerの実装クラスを以下からコピーして、作成したagent.pyと同じディレクトリに playwright.py として作成します。

https://github.com/google/adk-python/blob/main/contributing/samples/computer_use/playwright.py

そしてそのクラスを利用するように、Agentを設定します。
モデルは gemini-2.5-computer-use-preview-10-2025 を利用します。

from google.adk import Agent
from google.adk.tools.computer_use.computer_use_toolset import ComputerUseToolset
from .playwright import PlaywrightComputer # Playwrightを操作するカスタムクラス

root_agent = Agent(
    model='gemini-2.5-computer-use-preview-10-2025',
    name='computer_use_agent',
    instruction='あなたはブラウザを操作してユーザーのタスクを完了させるエージェントです。',
    tools=[
        ComputerUseToolset(computer=PlaywrightComputer(screen_size=(1280, 936)))
    ],
)

あとは adk web を立ち上げて、Google経由で検索を行ってみましょう。

Chroniumが立ち上がり、うまく検索ができました。

なお使ってみたところ、Vertex AI経由で gemini-2.5-computer-use-preview-10-2025 モデルを利用しようとすると、モデルが見つからずエラーになりました。**現状(2025年10月29日時点)**はGoogle AI StudioのGeminiを利用したほうが無難かもしれません。
今後は様々な環境に対応したモデルが増え、実装クラスを増やしていくことでブラウザ以外の操作も可能になるでしょう

まとめ

今回のADK 1.17.0では、セッションの巻き戻し機能によるインタラクティブ性の向上、サービスレジストリによる柔軟なバックエンド構成、そしてAgent EngineやComputerUseといった強力なツール連携の追加など、エージェントの応用範囲を大きく広げるアップデートが行われました。

また、日本時間の2025/10/16(木) 1:30amにADK初となるCommunity Callがオンラインで開催されました。
当日の録画やスライドは、以下のIssueで案内されているGoogle Groupに登録することで閲覧可能です。今後も月1で開催予定とのことですので、興味のある方はぜひチェックしてみてください。

https://github.com/google/adk-python/issues/3134

お知らせ/宣伝

ADK開発者が集う日本語のDiscordコミュニティがあります。ADKに関する情報交換や議論に興味がある方は、ぜひご参加ください!

https://discord.gg/BKpGRzjtqZ

また、ADKの最新のコミットログやリリースノートを分かりやすく解説するPodcastを、月・水・金に配信しています。ADKの動向を追いかけたい方は、ぜひ聴いてみてください。

https://www.youtube.com/playlist?list=PL0Zc2RFDZsM_MkHOzWNJpaT4EH5fQxA8n

Discussion