← All notes

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.

See also

Claims

Sources

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

Permanent ID: iil:note:3wwkg7cd

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.},
}

Markdown

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.