# Claude Agent SDK Session Pattern

> How long an agent's box lives, next to the work it has to do.

**Field:** Artificial Intelligence  
**Category:** Claude Agent SDK  
**Also known as:** Agent SDK Session Pattern, Ephemeral Session, Long-Running Session, Hybrid Session, Agent SDK session patterns

## Think of it like

It is like a sitter. She can come once, stay all day, or come back when called.

## Definition

A session pattern is how long a container lives, next to the agent sessions it serves. In the short-lived pattern, each task gets its own container, which is thrown away when the task is done. In the long-running pattern, containers stay up and serve many sessions. In the hybrid pattern, a container sleeps when no one uses it. When the user comes back, it wakes and loads the old chat from a SessionStore. A fourth pattern runs many agents in one container.

## Example

A tool that turns one PDF into a table uses ephemeral sessions. A Slack bot that never stops uses a long-running one.

## Why it matters

The pattern sets your cost and your start-up wait. It also decides if a user's old chat is still there.

## Common mistake

Using the hybrid pattern with no SessionStore. The chat is lost each time the container sleeps.

## Three principles

- **Ephemeral.** One task, then gone.
- **Long-running.** Always up.
- **Hybrid.** Sleeps, then reloads.

## Related terms

- [Claude Agent SDK Hosting](https://learn.benibix.com/term/ai/agent-sdk-hosting)
- [SessionStore](https://learn.benibix.com/term/ai/session-store)
- [Streaming Input Mode](https://learn.benibix.com/term/ai/streaming-input-mode)
- [ClaudeSDKClient](https://learn.benibix.com/term/ai/claude-sdk-client)
- [resume Option](https://learn.benibix.com/term/ai/resume-option)

![Three rows on a timeline. Ephemeral: a container starts for one task and is removed when it ends. Long-running: one container stays up the whole time and serves many sessions. Hybrid: a container runs, sleeps while the user is away, then wakes and reloads the chat from a SessionStore.](https://learn.benibix.com/diagrams/ai9-sdk-session-patterns.svg)

---

Source: https://learn.benibix.com/term/ai/agent-sdk-session-pattern
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-20
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
