From cf632847261723aac67243d1707beee80453fff4 Mon Sep 17 00:00:00 2001 From: Pang Luo Date: Fri, 2 Jan 2026 12:55:38 +1100 Subject: [PATCH] Fix state update --- .../snippets/agents/custom-agent/storyflow_agent.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/examples/python/snippets/agents/custom-agent/storyflow_agent.py b/examples/python/snippets/agents/custom-agent/storyflow_agent.py index 4f19cd9bb..54998124d 100644 --- a/examples/python/snippets/agents/custom-agent/storyflow_agent.py +++ b/examples/python/snippets/agents/custom-agent/storyflow_agent.py @@ -248,17 +248,11 @@ async def call_agent_async(user_input_topic: str): session_service, runner = await setup_session_and_runner() - current_session = await session_service.get_session(app_name=APP_NAME, - user_id=USER_ID, - session_id=SESSION_ID) - if not current_session: - logger.error("Session not found!") - return - + current_session = session_service.sessions[APP_NAME][USER_ID][SESSION_ID] current_session.state["topic"] = user_input_topic logger.info(f"Updated session state topic to: {user_input_topic}") - content = types.Content(role='user', parts=[types.Part(text=f"Generate a story about: {user_input_topic}")]) + content = types.Content(role='user', parts=[types.Part(text=f"Generate a story about the preset topic.")]) events = runner.run_async(user_id=USER_ID, session_id=SESSION_ID, new_message=content) final_response = "No final response captured."