@@ -219,7 +219,7 @@ async def _run_async_impl(
219
219
# --- Setup Runner and Session ---
220
220
session_service = InMemorySessionService ()
221
221
initial_state = {"topic" : "a brave kitten exploring a haunted house" }
222
- session = session_service .create_session (
222
+ session = await session_service .create_session (
223
223
app_name = APP_NAME ,
224
224
user_id = USER_ID ,
225
225
session_id = SESSION_ID ,
@@ -234,12 +234,12 @@ async def _run_async_impl(
234
234
)
235
235
236
236
# --- Function to Interact with the Agent ---
237
- def call_agent (user_input_topic : str ):
237
+ async def call_agent (user_input_topic : str ):
238
238
"""
239
239
Sends a new topic to the agent (overwriting the initial one if needed)
240
240
and runs the workflow.
241
241
"""
242
- current_session = session_service .get_session (app_name = APP_NAME ,
242
+ current_session = await session_service .get_session (app_name = APP_NAME ,
243
243
user_id = USER_ID ,
244
244
session_id = SESSION_ID )
245
245
if not current_session :
@@ -261,7 +261,7 @@ def call_agent(user_input_topic: str):
261
261
print ("\n --- Agent Interaction Result ---" )
262
262
print ("Agent Final Response: " , final_response )
263
263
264
- final_session = session_service .get_session (app_name = APP_NAME ,
264
+ final_session = await session_service .get_session (app_name = APP_NAME ,
265
265
user_id = USER_ID ,
266
266
session_id = SESSION_ID )
267
267
print ("Final Session State:" )
@@ -270,5 +270,5 @@ def call_agent(user_input_topic: str):
270
270
print ("-------------------------------\n " )
271
271
272
272
# --- Run the Agent ---
273
- call_agent ("a lonely robot finding a friend in a junkyard" )
273
+ await call_agent ("a lonely robot finding a friend in a junkyard" )
274
274
# --8<-- [end:story_flow_agent]
0 commit comments