Use session memory to keep conversation history across agent runs
Answer: Built-in session memory maintains conversation history across multiple agent runs, so you do not have to handle that history by hand between turns.
Why it matters
The Agents SDK provides built-in session memory. It automatically maintains conversation history across multiple agent runs. That removes the need to manually handle .to_input_list() between turns. Each session keeps its own conversation history, so agents can keep context without explicit manual memory management. This is particularly useful for chat applications or multi-turn conversations. Use sessions when you want the SDK to manage client-side memory for you. A session cannot be combined, in the same run, with the run-level continuation options conversation_id or previous_response_id.
Pydantic AI provides access to messages exchanged during an agent run. Those messages can be used to continue a coherent conversation, and to understand how an agent performed. After running an agent, you can access the messages from the result object. all_messages() returns all messages, including messages from prior runs. new_messages() returns only the messages from the current run.
Automatic memoryBuilt-in session memory automatically maintains conversation history across multiple agent runsClient-sideUse sessions when you want the SDK to manage client-side memory for youMessage accessMessages exchanged during an agent run can continue a coherent conversation
See also
Claims
- id: C1 claim: Built-in session memory maintains conversation history across multiple agent runs. source: S1 evidence: "built-in session memory to automatically maintain conversation history across multiple agent runs"
- id: C2 claim: Use sessions when you want the SDK to manage client-side memory. source: S1 evidence: "Use sessions when you want the SDK to manage client-side memory for you."
- id: C3 claim: Messages from an agent run can be used to continue a coherent conversation. source: S2 evidence: "used both to continue a coherent conversation, and to understand how an agent performed."
Sources
- [S1] Sessions. OpenAI Agents SDK. https://openai.github.io/openai-agents-python/sessions/ . License: MIT. Accessed 2026-11-22.
- [S2] Messages and chat history. Pydantic AI. https://pydantic.dev/docs/ai/core-concepts/message-history/ . License: MIT. Accessed 2026-11-22.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: OpenAI Agents SDK Sessions; Pydantic AI Messages and chat history. MIT. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: OpenAI Agents SDK Sessions (MIT); Pydantic AI Messages and chat history (MIT). Text was condensed and changed from the originals.
Cite this
iinventedlight. 2026. "Use session memory to keep conversation history across agent runs." iinventedlight Library, iil:note:3wwkg7cd, version of 2026-11-22. https://iinventedlight.com/library/notes/agents-sdk-sessions/. License: CC-BY-4.0.
@misc{iil_note_3wwkg7cd,
author = {{iinventedlight}},
title = {{Use session memory to keep conversation history across agent runs}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-22},
url = {https://iinventedlight.com/library/notes/agents-sdk-sessions/},
note = {Permanent ID iil:note:3wwkg7cd. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/agents-sdk-sessions.md.