Skip to content

Commit 3a7a62e

Browse files
committed
docs: make StoryFlowAgent example fully async/await (#379)
1 parent 3dd3436 commit 3a7a62e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

examples/python/snippets/agents/custom-agent/storyflow_agent.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ async def _run_async_impl(
219219
# --- Setup Runner and Session ---
220220
session_service = InMemorySessionService()
221221
initial_state = {"topic": "a brave kitten exploring a haunted house"}
222-
session = session_service.create_session(
222+
session = await session_service.create_session(
223223
app_name=APP_NAME,
224224
user_id=USER_ID,
225225
session_id=SESSION_ID,
@@ -234,12 +234,12 @@ async def _run_async_impl(
234234
)
235235

236236
# --- Function to Interact with the Agent ---
237-
def call_agent(user_input_topic: str):
237+
async def call_agent(user_input_topic: str):
238238
"""
239239
Sends a new topic to the agent (overwriting the initial one if needed)
240240
and runs the workflow.
241241
"""
242-
current_session = session_service.get_session(app_name=APP_NAME,
242+
current_session = await session_service.get_session(app_name=APP_NAME,
243243
user_id=USER_ID,
244244
session_id=SESSION_ID)
245245
if not current_session:
@@ -261,7 +261,7 @@ def call_agent(user_input_topic: str):
261261
print("\n--- Agent Interaction Result ---")
262262
print("Agent Final Response: ", final_response)
263263

264-
final_session = session_service.get_session(app_name=APP_NAME,
264+
final_session = await session_service.get_session(app_name=APP_NAME,
265265
user_id=USER_ID,
266266
session_id=SESSION_ID)
267267
print("Final Session State:")
@@ -270,5 +270,5 @@ def call_agent(user_input_topic: str):
270270
print("-------------------------------\n")
271271

272272
# --- 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")
274274
# --8<-- [end:story_flow_agent]

0 commit comments

Comments
 (0)