From 07a87b45aa5fdd391642ff4fca1477025a5fa7b2 Mon Sep 17 00:00:00 2001 From: Bicheng Wang Date: Sat, 3 Oct 2026 16:27:12 -0700 Subject: [PATCH] Persist the session in the hosting quickstart --- python/packages/hosting/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python/packages/hosting/README.md b/python/packages/hosting/README.md index 05f42da4bb0..1910c7c615c 100644 --- a/python/packages/hosting/README.md +++ b/python/packages/hosting/README.md @@ -81,8 +81,12 @@ agent = OpenAIChatClient().as_agent(name="Assistant") state = AgentState(agent, session_store=FileSessionStore("storage/sessions")) session = await state.get_or_create_session("conversation-1") result = await (await state.get_target()).run("Hello", session=session) +await state.set_session("conversation-1", session) ``` +`get_or_create_session(...)` returns a working copy. Save the updated session after +each successful run so the next request with the same id retains its state. + If a protocol mints a new continuation id on every response, store the session explicitly after `run(...)` returns. `run(...)` may update the session, so store the post-run object: