feat: Upgrade ADK stack to use App instead in addition to root_agent

The convention:
- If some fields(like plugin) are defined both at root_agent and app, then a error will be raised.
- app code should be located within agent.py.
- an instance named app should be created

PiperOrigin-RevId: 801084463
This commit is contained in:
Hangfei Lin
2025-08-29 17:33:38 -07:00
committed by Copybara-Service
parent 98b0426cd2
commit a2e89a22a5
11 changed files with 476 additions and 36 deletions
+4 -3
View File
@@ -26,6 +26,7 @@ from typing import List
from typing import Tuple
import click
from google.adk.agents.base_agent import BaseAgent
import google.adk.cli.cli as cli
import pytest
@@ -130,12 +131,12 @@ async def test_run_input_file_outputs(
artifact_service = cli.InMemoryArtifactService()
session_service = cli.InMemorySessionService()
credential_service = cli.InMemoryCredentialService()
dummy_root = types.SimpleNamespace(name="root")
dummy_root = BaseAgent(name="root")
session = await cli.run_input_file(
app_name="app",
user_id="user",
root_agent=dummy_root,
agent_or_app=dummy_root,
artifact_service=artifact_service,
session_service=session_service,
credential_service=credential_service,
@@ -205,7 +206,7 @@ async def test_run_interactively_whitespace_and_exit(
sess = await session_service.create_session(app_name="dummy", user_id="u")
artifact_service = cli.InMemoryArtifactService()
credential_service = cli.InMemoryCredentialService()
root_agent = types.SimpleNamespace(name="root")
root_agent = BaseAgent(name="root")
# fake user input: blank -> 'hello' -> 'exit'
answers = iter([" ", "hello", "exit"])