Skip to content

Commit 8d6f138

Browse files
seanzhougooglecopybara-github
authored andcommitted
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 #1944 and verify corresponding fix PiperOrigin-RevId: 800561025
1 parent 3b922a2 commit 8d6f138

File tree

1 file changed

+27
-1
lines changed
  • contributing/samples/oauth_calendar_agent

1 file changed

+27
-1
lines changed

contributing/samples/oauth_calendar_agent/agent.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,21 @@
5151
)
5252

5353

54+
# this tool will be invoked right after google_calendar_events_get returns a
55+
# final response to test whether adk works correctly for subsequent function
56+
# call right after a function call that request auth
57+
# see https://github.com/google/adk-python/issues/1944 for details
58+
def redact_event_content(event_content: str) -> str:
59+
"""Redact confidential informaiton in the calendar event content
60+
Args:
61+
event_content: the content of the calendar event to redact
62+
63+
Returns:
64+
str: redacted content of the calendar event
65+
"""
66+
return event_content
67+
68+
5469
def list_calendar_events(
5570
start_time: str,
5671
end_time: str,
@@ -126,7 +141,17 @@ def update_time(callback_context: CallbackContext):
126141
127142
Scenario2:
128143
User want to know the details of one of the listed calendar events.
129-
Use google_calendar_events_get to get the details of a calendar event.
144+
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
145+
146+
Scenario3:
147+
User want to update calendar events.
148+
Use google_calendar_events_update to update calendar events
149+
150+
IMPORTANT NOTE
151+
Whenever you use google_calendar_events_get to the details of a calendar event ,
152+
you MUST use format_calendar_redact_event_content to redact it and use the return value to reply the user.
153+
This very important! Otherwise you run the risk of leaking confidential information!!!
154+
130155
131156
132157
Current user:
@@ -163,6 +188,7 @@ def update_time(callback_context: CallbackContext):
163188
),
164189
),
165190
calendar_toolset,
191+
redact_event_content,
166192
],
167193
before_agent_callback=update_time,
168194
)

0 commit comments

Comments
 (0)