Skip to main content
Resume conversations automatically by using the same session_id in your Agent’s memory configuration.

Quick Start

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:
from praisonaiagents import Agent

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

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

Session ID Strategies

PatternUse CaseExample
User-basedPersistent per userf"user-{user_id}-main"
Conversation-basedNew chat each timef"conv-{uuid.uuid4().hex[:8]}"
Task-basedWorkflow trackingf"task-{task_id}-{user_id}"
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

# List sessions
praisonai session list

# Resume a session
praisonai session resume my-session

# Show session details
praisonai session show my-session

Best Practices

Consistent IDs

Same session_id = same conversation thread

User Isolation

Include user_id in session_id for multi-user apps

Right Backend

JSON for dev, PostgreSQL for production

Meaningful Names

Use descriptive IDs: user-123-support-ticket

CLI equivalent

Use praisonai run --continue or praisonai run --session <id> for the same restore behaviour from the command line