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

# Session Resume

> Continue conversations across sessions

Resume conversations automatically by using the same `session_id` in your Agent's memory configuration.

## Quick Start

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent

# First conversation
agent = Agent(
    name="Assistant",
    instructions="You are a helpful assistant",
    memory={"session_id": "my-session-123"}
)
agent.start("My favorite color is blue")

# Later, in a new process - automatically resumes!
agent = Agent(
    name="Assistant",
    instructions="You are a helpful assistant",
    memory={"session_id": "my-session-123"}
)
agent.start("What's my favorite color?")  # Remembers: "blue"
```

By default, passing `session_id` enables `history=True` automatically, which restores prior user and assistant turns from the session store into the new agent before it processes your next prompt.

## With Database Persistence

For production apps, persist to a database:

<CodeGroup>
  ```python PostgreSQL theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  from praisonaiagents import Agent

  agent = Agent(
      name="Assistant",
      memory={
          "session_id": "user-123-main",
          "db": "postgresql://user:pass@localhost/mydb"
      }
  )
  ```

  ```python SQLite theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  from praisonaiagents import Agent

  agent = Agent(
      name="Assistant",
      memory={
          "session_id": "user-123-main",
          "db": "sqlite:///sessions.db"
      }
  )
  ```
</CodeGroup>

## Session ID Strategies

| Pattern            | Use Case            | Example                          |
| ------------------ | ------------------- | -------------------------------- |
| User-based         | Persistent per user | `f"user-{user_id}-main"`         |
| Conversation-based | New chat each time  | `f"conv-{uuid.uuid4().hex[:8]}"` |
| Task-based         | Workflow tracking   | `f"task-{task_id}-{user_id}"`    |

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent

# User-based (recommended for most apps)
agent = Agent(
    name="Assistant",
    memory={"session_id": f"user-{user_id}-main"}
)

# Conversation-based (new session per chat)
import uuid
agent = Agent(
    name="Assistant",
    memory={"session_id": f"conv-{uuid.uuid4().hex[:8]}"}
)
```

## CLI Resume

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# List sessions
praisonai session list

# Resume a session
praisonai session resume my-session

# Show session details
praisonai session show my-session
```

## Best Practices

<CardGroup cols={2}>
  <Card title="Consistent IDs" icon="fingerprint">
    Same `session_id` = same conversation thread
  </Card>

  <Card title="User Isolation" icon="users">
    Include `user_id` in session\_id for multi-user apps
  </Card>

  <Card title="Right Backend" icon="database">
    JSON for dev, PostgreSQL for production
  </Card>

  <Card title="Meaningful Names" icon="tag">
    Use descriptive IDs: `user-123-support-ticket`
  </Card>

  <Card title="CLI equivalent" icon="terminal" href="/docs/cli/run">
    Use `praisonai run --continue` or `praisonai run --session <id>` for the same restore behaviour from the command line
  </Card>
</CardGroup>
