85 agentic tools audited for security incidents · Talk to the lab →
MotionticBook a call
Glossary

What is a session in AI agents?

In AI agents, a session is the durable record of one conversation or run, a log of messages, tool calls, results and state kept outside the model's context window and used to rebuild each prompt or resume work.

Checked

A model call is stateless. The session is what makes a conversation or task continuous: it stores everything that happened, so the next call can be built from it and a crashed run can pick up where it stopped.

All three major labs now use the word, and they mean much the same thing. Google calls the session the ground truth of an agent run, OpenAI's Agents SDK uses it as the memory object passed to each run, and Anthropic's Managed Agents design describes it as an append-only log of everything that happened.

How the labs implement it

  • Google ADK

    Every user message, agent reply, tool call, tool result, control signal and error is stored as a structured event. A session also carries key-value state. The working context for each call is built from these events.

  • OpenAI Agents SDK

    Before each run the runner loads the session's history into the input, and after the run it saves the new items. Backends include SQLite, Redis, SQLAlchemy, MongoDB and OpenAI's Conversations API, plus wrappers for encryption and compaction.

  • Anthropic Managed Agents

    The session is a durable event log outside both the context window and the sandbox. The harness reads slices of it, writes events during the loop, and a crashed harness can be woken with the session ID and resume from the last event.

Why the log lives outside the window

Anthropic's April 2026 Managed Agents post points out that compaction and trimming are irreversible decisions about what to keep, made without knowing which tokens later turns will need. Keeping the full record in the session means anything removed from the prompt can still be recovered.

The split also separates concerns. The session guarantees durable, queryable storage; the harness decides how to present it, including ordering for prompt cache hits.

Common confusions

  • Session and working context

    The session stores everything; the working context is the slice shown to the model on one call.

  • Session and long-term memory

    A session covers one conversation or run. Long-term memory carries selected facts across many sessions.

  • Session and login session

    An agent session ID selects which history to load. OpenAI's documentation states plainly that it does not authenticate a user, so authorisation stays the application's job.

Where it fails

Replaying a whole session into every prompt stops working as runs get long. Google's May 2026 ADK post lists the costs: old tool outputs pollute the prompt, resending long history is expensive, and after a long pause the model can hallucinate steps that never happened. The fix is to keep the session as storage, track progress in explicit state, and build a smaller working context from both.

How Motiontic's engineers apply it

Motiontic's engineers store sessions in the client's own database with retention rules agreed up front, tie every session to an authenticated user or service identity, and keep the session as the record that audits and evals replay.

Sessions in three agent stacks

Sessions in three agent stacks
Google ADKOpenAI Agents SDKAnthropic Managed Agents
Unit storedEvents plus key-value stateConversation itemsEvents in an append-only log
How prompts use itProcessors build the working contextHistory loaded before each run, optionally cappedHarness reads slices and arranges context
StorageIn-memory, database or managed serviceSQLite, Redis, SQLAlchemy, MongoDB, Conversations API and moreHosted by the platform
ResumeRehydrate from the session servicePass the same session to the next runWake the harness with the session ID

Common questions

What is a session in an AI agent?

A session is the stored history of one conversation or agent run, including messages, tool calls and results, kept outside the model and used to build each prompt and to resume after interruptions.

Is a session the same as agent memory?

A session is short-term memory for one conversation or run. Long-term memory stores selected facts across sessions and is recalled when relevant.

Does a session ID identify the user?

No. It selects which history to load. OpenAI's Agents SDK documentation notes that a session ID does not authenticate a user, so the application must enforce access.

Running agents that have to hold up?

Describe the agent, the systems it touches and what it must never get wrong. The first call is with a lab engineer, who will say plainly whether it is ready for production, and whether Motiontic is the right team.