> ## Documentation Index
> Fetch the complete documentation index at: https://docs.onecortex.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Sessions and state

> What a session ID does: it reaches the same running instance of your agent, so in process state survives between calls. What it does not do, and where to keep memory that lasts.

A session is a conversation key. Calls with the same `sessionId` reach the same running instance of your agent, so anything it holds in memory between calls is still there. A session is not stored conversation memory: that is your agent's to keep.

## Use a session

Send your own key, 1 to 256 characters, on every call of a conversation:

```json theme={null}
{ "prompt": "My order number is 1042.", "sessionId": "user-42" }
```

```json theme={null}
{ "prompt": "When will it arrive?", "sessionId": "user-42" }
```

Leave `sessionId` out and Onecortex generates one. It comes back in the response body, in `done`, and in the `X-Onecortex-Session-Id` header, so you can send it next time. Your value is echoed back exactly as you sent it.

Use anything stable for the conversation: a chat ID, a ticket number, a user ID. Onecortex never passes your value to the runtime as it is. It derives an internal identifier from the agent and your key, so the same key used with two agents reaches two separate instances, and your IDs never appear in any infrastructure.

## What a session keeps

Your agent's process, and everything in its memory: a LangGraph in memory checkpointer, a Strands agent's message list, a cache you built, a variable at module level.

LangGraph's `thread_id` is set from the session, so a graph compiled with a checkpointer remembers the conversation per session with no code. See [LangGraph](/frameworks/langgraph).

## When it starts fresh

A session's instance stops, and the next call with the same `sessionId` starts a new one with empty memory:

* after **15 minutes** with no calls;
* after **1 hour**, however busy;
* when a new version goes live, or you roll back.

So a session is right for state that helps within a conversation and can be rebuilt: a loaded document, a warmed cache, the last few turns. It is wrong for anything that must not be lost.

## Memory that lasts

Keep it outside the instance, keyed by your session ID:

* **LangGraph:** compile with a checkpointer backed by your own database.
* **Any agent:** send the history in `messages` on each call, from where your app keeps it, and read it in your agent. See [the invoke API](/call/invoke).
* **Your own store:** read and write it in your agent, with its credentials as [secrets](/build/configuration).

Onecortex does not store conversations for your agent.
