Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions examples/google_adk/birthday_planner/adk_agent_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,10 @@ async def _process_request(
session_id: str,
task_updater: TaskUpdater,
) -> AsyncIterable[TaskStatus | Artifact]:
session_id = self._upsert_session(
session = await self._upsert_session(
session_id,
).id
)
session_id = session.id
async for event in self._run_agent(
session_id, new_message, task_updater
):
Expand Down Expand Up @@ -243,10 +244,10 @@ async def cancel(self, context: RequestContext, event_queue: EventQueue):
# Ideally: kill any ongoing tasks.
raise ServerError(error=UnsupportedOperationError())

def _upsert_session(self, session_id: str):
return self.runner.session_service.get_session(
async def _upsert_session(self, session_id: str):
return await self.runner.session_service.get_session(
app_name=self.runner.app_name, user_id='self', session_id=session_id
) or self.runner.session_service.create_session(
) or await self.runner.session_service.create_session(
app_name=self.runner.app_name, user_id='self', session_id=session_id
)

Expand Down
4 changes: 2 additions & 2 deletions examples/google_adk/birthday_planner/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ name = "adk-a2a-client-example"
version = "0.1.0"
description = "Birthday planner agent example"
readme = "README.md"
requires-python = ">=3.10"
requires-python = ">=3.12"
dependencies = [
"a2a-sdk",
"click>=8.1.8",
"dotenv>=0.9.9",
"httpx>=0.28.1",
"google-genai>=1.9.0",
"google-adk>=0.0.3",
"google-adk>=1.0.0",
"pydantic>=2.11.4",
"python-dotenv>=1.1.0",
]
Expand Down
5 changes: 3 additions & 2 deletions examples/google_adk/calendar_agent/__main__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import asyncio
import logging
import os

Expand Down Expand Up @@ -66,10 +67,10 @@ def main(host: str, port: int):
skills=[skill],
)

adk_agent = create_agent(
adk_agent = asyncio.run(create_agent(
client_id=os.getenv('GOOGLE_CLIENT_ID'),
client_secret=os.getenv('GOOGLE_CLIENT_SECRET'),
)
))
runner = Runner(
app_name=agent_card.name,
agent=adk_agent,
Expand Down
8 changes: 4 additions & 4 deletions examples/google_adk/calendar_agent/adk_agent.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import datetime

from google.adk.agents import LlmAgent # type: ignore[import-untyped]
from google.adk.tools.google_api_tool import calendar_tool_set # type: ignore[import-untyped]
from google.adk.tools.google_api_tool import CalendarToolset # type: ignore[import-untyped]


def create_agent(client_id, client_secret) -> LlmAgent:
async def create_agent(client_id, client_secret) -> LlmAgent:
"""Constructs the ADK agent."""
calendar_tool_set.configure_auth(client_id, client_secret)
toolset = CalendarToolset(client_id=client_id, client_secret=client_secret)
return LlmAgent(
model='gemini-2.0-flash-001',
name='calendar_agent',
Expand All @@ -23,5 +23,5 @@ def create_agent(client_id, client_secret) -> LlmAgent:

Today is {datetime.datetime.now()}.
""",
tools=calendar_tool_set.get_tools(),
tools=await toolset.get_tools(),
)
13 changes: 7 additions & 6 deletions examples/google_adk/calendar_agent/adk_agent_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ async def _process_request(
session_id: str,
task_updater: TaskUpdater,
) -> None:
session_id = self._upsert_session(
session = await self._upsert_session(
session_id,
).id
)
session_id = session.id
auth_details = None
async for event in self._run_agent(session_id, new_message):
# This agent is expected to do one of two things:
Expand Down Expand Up @@ -229,10 +230,10 @@ async def cancel(self, context: RequestContext, event_queue: EventQueue):
async def on_auth_callback(self, state: str, uri: str):
self._awaiting_auth[state].set_result(uri)

def _upsert_session(self, session_id: str):
return self.runner.session_service.get_session(
async def _upsert_session(self, session_id: str):
return await self.runner.session_service.get_session(
app_name=self.runner.app_name, user_id='self', session_id=session_id
) or self.runner.session_service.create_session(
) or await self.runner.session_service.create_session(
app_name=self.runner.app_name, user_id='self', session_id=session_id
)

Expand Down Expand Up @@ -317,7 +318,7 @@ def get_auth_config(
) -> AuthConfig:
"""Extracts the AuthConfig object from the arguments of the auth request function call."""
if not auth_request_function_call.args or not (
auth_config := auth_request_function_call.args.get('auth_config')
auth_config := auth_request_function_call.args.get('authConfig')
):
raise ValueError(
f'Cannot get auth config from function call: {auth_request_function_call}'
Expand Down
4 changes: 2 additions & 2 deletions examples/google_adk/calendar_agent/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ name = "adk-auth-example"
version = "0.1.0"
description = "Calendar agent example"
readme = "README.md"
requires-python = ">=3.10"
requires-python = ">=3.12"
dependencies = [
"a2a-sdk",
"click>=8.1.8",
"dotenv>=0.9.9",
"httpx>=0.28.1",
"google-genai>=1.9.0",
"google-adk>=0.0.3",
"google-adk>=1.0.0",
"pydantic>=2.11.4",
"python-dotenv>=1.1.0",
"uvicorn>=0.34.2",
Expand Down