Skip to content

Commit f9aa0d8

Browse files
authored
Merge branch 'main' into server-call-context
2 parents 2f9ccd9 + c351656 commit f9aa0d8

File tree

6 files changed

+24
-21
lines changed

6 files changed

+24
-21
lines changed

examples/google_adk/birthday_planner/adk_agent_executor.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,10 @@ async def _process_request(
156156
session_id: str,
157157
task_updater: TaskUpdater,
158158
) -> AsyncIterable[TaskStatus | Artifact]:
159-
session_id = self._upsert_session(
159+
session = await self._upsert_session(
160160
session_id,
161-
).id
161+
)
162+
session_id = session.id
162163
async for event in self._run_agent(
163164
session_id, new_message, task_updater
164165
):
@@ -243,10 +244,10 @@ async def cancel(self, context: RequestContext, event_queue: EventQueue):
243244
# Ideally: kill any ongoing tasks.
244245
raise ServerError(error=UnsupportedOperationError())
245246

246-
def _upsert_session(self, session_id: str):
247-
return self.runner.session_service.get_session(
247+
async def _upsert_session(self, session_id: str):
248+
return await self.runner.session_service.get_session(
248249
app_name=self.runner.app_name, user_id='self', session_id=session_id
249-
) or self.runner.session_service.create_session(
250+
) or await self.runner.session_service.create_session(
250251
app_name=self.runner.app_name, user_id='self', session_id=session_id
251252
)
252253

examples/google_adk/birthday_planner/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ name = "adk-a2a-client-example"
33
version = "0.1.0"
44
description = "Birthday planner agent example"
55
readme = "README.md"
6-
requires-python = ">=3.10"
6+
requires-python = ">=3.12"
77
dependencies = [
88
"a2a-sdk",
99
"click>=8.1.8",
1010
"dotenv>=0.9.9",
1111
"httpx>=0.28.1",
1212
"google-genai>=1.9.0",
13-
"google-adk>=0.0.3",
13+
"google-adk>=1.0.0",
1414
"pydantic>=2.11.4",
1515
"python-dotenv>=1.1.0",
1616
]

examples/google_adk/calendar_agent/__main__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import asyncio
12
import logging
23
import os
34

@@ -66,10 +67,10 @@ def main(host: str, port: int):
6667
skills=[skill],
6768
)
6869

69-
adk_agent = create_agent(
70+
adk_agent = asyncio.run(create_agent(
7071
client_id=os.getenv('GOOGLE_CLIENT_ID'),
7172
client_secret=os.getenv('GOOGLE_CLIENT_SECRET'),
72-
)
73+
))
7374
runner = Runner(
7475
app_name=agent_card.name,
7576
agent=adk_agent,

examples/google_adk/calendar_agent/adk_agent.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import datetime
22

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

66

7-
def create_agent(client_id, client_secret) -> LlmAgent:
7+
async def create_agent(client_id, client_secret) -> LlmAgent:
88
"""Constructs the ADK agent."""
9-
calendar_tool_set.configure_auth(client_id, client_secret)
9+
toolset = CalendarToolset(client_id=client_id, client_secret=client_secret)
1010
return LlmAgent(
1111
model='gemini-2.0-flash-001',
1212
name='calendar_agent',
@@ -23,5 +23,5 @@ def create_agent(client_id, client_secret) -> LlmAgent:
2323
2424
Today is {datetime.datetime.now()}.
2525
""",
26-
tools=calendar_tool_set.get_tools(),
26+
tools=await toolset.get_tools(),
2727
)

examples/google_adk/calendar_agent/adk_agent_executor.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,10 @@ async def _process_request(
6565
session_id: str,
6666
task_updater: TaskUpdater,
6767
) -> None:
68-
session_id = self._upsert_session(
68+
session = await self._upsert_session(
6969
session_id,
70-
).id
70+
)
71+
session_id = session.id
7172
auth_details = None
7273
async for event in self._run_agent(session_id, new_message):
7374
# This agent is expected to do one of two things:
@@ -229,10 +230,10 @@ async def cancel(self, context: RequestContext, event_queue: EventQueue):
229230
async def on_auth_callback(self, state: str, uri: str):
230231
self._awaiting_auth[state].set_result(uri)
231232

232-
def _upsert_session(self, session_id: str):
233-
return self.runner.session_service.get_session(
233+
async def _upsert_session(self, session_id: str):
234+
return await self.runner.session_service.get_session(
234235
app_name=self.runner.app_name, user_id='self', session_id=session_id
235-
) or self.runner.session_service.create_session(
236+
) or await self.runner.session_service.create_session(
236237
app_name=self.runner.app_name, user_id='self', session_id=session_id
237238
)
238239

@@ -317,7 +318,7 @@ def get_auth_config(
317318
) -> AuthConfig:
318319
"""Extracts the AuthConfig object from the arguments of the auth request function call."""
319320
if not auth_request_function_call.args or not (
320-
auth_config := auth_request_function_call.args.get('auth_config')
321+
auth_config := auth_request_function_call.args.get('authConfig')
321322
):
322323
raise ValueError(
323324
f'Cannot get auth config from function call: {auth_request_function_call}'

examples/google_adk/calendar_agent/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ name = "adk-auth-example"
33
version = "0.1.0"
44
description = "Calendar agent example"
55
readme = "README.md"
6-
requires-python = ">=3.10"
6+
requires-python = ">=3.12"
77
dependencies = [
88
"a2a-sdk",
99
"click>=8.1.8",
1010
"dotenv>=0.9.9",
1111
"httpx>=0.28.1",
1212
"google-genai>=1.9.0",
13-
"google-adk>=0.0.3",
13+
"google-adk>=1.0.0",
1414
"pydantic>=2.11.4",
1515
"python-dotenv>=1.1.0",
1616
"uvicorn>=0.34.2",

0 commit comments

Comments
 (0)