Agent Development Kit
Google Cloud Next '25 で発表されたやつ
Quickstart - Agent Development Kit
google/adk-python: An open-source, code-first Python toolkit for building, evaluating, and deploying sophisticated AI agents with flexibility and control.
google/adk-samples: A collection of sample agents built with Agent Development (ADK)
https://google.github.io/adk-docs/tutorials/coding-with-ai/
https://google.github.io/adk-docs/llms.txt
https://google.github.io/adk-docs/llms-full.txt
Cloud Run - Agent Development Kit
みる
Agent Engine 内で直接 Node.js の MCP サーバーを動かす方法 #Python - Qiita
Agent Engine の Session & MemoryBank
実行は Cloud Run やローカルで行いたい、Session や MemoryBank は独立して呼び出せる
1度 $ adk deployagent_engine でデプロイする (GCS bucket 等必要)
作成したリソース URL からゲット
short: agentengine://AGENT_ENGINE_ID
long: agentengine://projects/$PROJECT_NUMBER/locations/$REGION/reasoningEngines/$AGENT_ENGINE_ID
これを get_fast_api_app(session_service_uri="agentengine://...", memory_service_uri="...") に渡したり、google.adk.sessions.VertexAiSessionService として使う、同じ URL を Session にも MemoryBank にも指定できる
Overview - Agent Development Kit
2025/12/14 今のところ無料
Vertex AI の料金 | Google Cloud
現在、Agent Engine ランタイムの料金が設定されています。セッション、Memory Bank、コード実行などの他の Agent Engine サービスの料金は、後日公開されます(現在は無料でご利用いただけます)。
読む
google.adk.tools.load_memory_tool.LoadMemoryTool を渡すと必要に応じて読む
こういう system_instruction が追加される
You have memory. You can use it to answer questions. If any questions need you to look up the memory, you should call load_memory function with a query.
google.adk.tools.preload_memory_tool.PreloadMemoryTool は毎回読む
書く
コールバックで設定する
callback_context.add_session_to_memory() 呼ぶだけ
code:agent.py
async def auto_save_session_to_memory_callback(ctx: CallbackContext) -> None:
await ctx.add_session_to_memory()
root_agent = Agent(
name="sample",
model="gemini-2.5-flash",
instruction="あなたは優秀なアシスタントです。Memory を活用しつつユーザと会話してください",
tools=LoadMemoryTool(),
after_agent_callback=auto_save_session_to_memory_callback,
)
AgentLoader
{agent_name}.py, {agent_name}/__init__.py, {agent_name}/agent.py を見ていって
app: App, root_agent: BaseAgent を参照して使う
code:tree.md
agents_dir/
├── sample.py # 方法1: 単一ファイル
│ └── root_agent = Agent(...)
│
├── sample/ # 方法1: パッケージ
│ └── __init__.py
│ └── app = App(...) または root_agent = Agent(...)
│
├── sample/ # 方法2: サブモジュール
│ └── agent.py
│ └── app = App(...) または root_agent = Agent(...)
│
└── sample/ # 方法3: YAML (実験的)
└── root_agent.yaml
なので Agent を定義しつつ App をスコープにおいておけばそちららが使われる
例えば EventsCompaction を使うときなど
code:events_compaction.py
root_agent = Agent(...)
app = App(
name="sample",
root_agent=root_agent,
events_compaction_config=EventsCompactionConfig(
compaction_interval=10,
overlap_size=2,
),
)
---.icon
リリース当初触ったメモ
Web Console がついてるのがいいね
before_model_callback で出力前のチェック
from google.adk.tools.langchain_tool import LangchainTool
$ adk deploy cloud_run で反映するの意欲的すぎるだろ
起動
$ adk web
$ adk run DIR
どのように agent インスタンスを探す?
実行したサブディレクトリから agent.py, __init__.py をロードして root_agent を採用する?
ツール
単なる関数、docstring は LLM に渡る
引数はどうもらう?
返り値はどう返す
単機能なパーツを作るには、1ツール1agent て感じかな?
tool_context を受け取る
tool_context.state.get("key", default)
Agent
https://google.github.io/adk-docs/agents/
コードから単に呼ぶには?
Runner(agent).run_async(...) ?
https://google.github.io/adk-docs/tutorials/agent-team/#step-4-adding-memory-and-personalization-with-session-state
入力は google.genai.types.Content
before_model_callback
before_tool_callback
def fn(tool: BaseTool, args: Dict[str, Any], tool_context: ToolContext) -> Optional[Dict]:
LLM agents - Agent Development Kit
ちゃんと input_schema, output_schema 使えるじゃん
include_contents none なら history 受け取らない
State - Agent Development Kit
なんか並列実行して結果をあつめる MapReduce 的なの書けなくないか?
長さが不定なリストを入力してもらって仕分けて加工してマージするとか
これで custom agent 要るの...
うーん、並列部分を tool に閉じ込めて複雑なオブジェクト返す感じならまだ書きやすそうだが
この手のは state 管理がムズいのに徒手空拳すぎないか
state に応じて prompt 切り替えたいのに before_model_callback でやるのかこれ...
https://google.github.io/adk-docs/callbacks/design-patterns-and-best-practices/
LangChain & LangGraph でいいなという気持ちになってきた
state を元に instruction を