From 8d6f138fbe0c3359ab3de98a2239f5cc61f2a912 Mon Sep 17 00:00:00 2001 From: "Xiang (Sean) Zhou" Date: Thu, 28 Aug 2025 12:09:04 -0700 Subject: [PATCH] chore: Update oauth calendar sample agent to test the case when a subsequent tool call happends right after a tool call that requires auth context: this is for reproducing https://github.com/google/adk-python/issues/1944 and verify corresponding fix PiperOrigin-RevId: 800561025 --- .../samples/oauth_calendar_agent/agent.py | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/contributing/samples/oauth_calendar_agent/agent.py b/contributing/samples/oauth_calendar_agent/agent.py index 509dc370..0be3b6e5 100644 --- a/contributing/samples/oauth_calendar_agent/agent.py +++ b/contributing/samples/oauth_calendar_agent/agent.py @@ -51,6 +51,21 @@ calendar_toolset = CalendarToolset( ) +# this tool will be invoked right after google_calendar_events_get returns a +# final response to test whether adk works correctly for subsequent function +# call right after a function call that request auth +# see https://github.com/google/adk-python/issues/1944 for details +def redact_event_content(event_content: str) -> str: + """Redact confidential informaiton in the calendar event content + Args: + event_content: the content of the calendar event to redact + + Returns: + str: redacted content of the calendar event + """ + return event_content + + def list_calendar_events( start_time: str, end_time: str, @@ -126,7 +141,17 @@ root_agent = Agent( Scenario2: User want to know the details of one of the listed calendar events. - Use google_calendar_events_get to get the details of a calendar event. + Use google_calendar_events_get to get the details of a calendar event and use redact_event_content to redact confidential information before sending the details to user + + Scenario3: + User want to update calendar events. + Use google_calendar_events_update to update calendar events + + IMPORTANT NOTE + Whenever you use google_calendar_events_get to the details of a calendar event , + you MUST use format_calendar_redact_event_content to redact it and use the return value to reply the user. + This very important! Otherwise you run the risk of leaking confidential information!!! + Current user: @@ -163,6 +188,7 @@ root_agent = Agent( ), ), calendar_toolset, + redact_event_content, ], before_agent_callback=update_time, )