Persistence CLI

CLI commands for database persistence

Persistence CLI

Command-line interface for database persistence management.

Installation

bash
pip install "praisonai[tools]"

Commands

Help

bash
praisonai persistence --help

Doctor

Validate database connectivity.

bash
praisonai persistence doctor [options]

Options:

OptionDescription
--conversation-url URLConversation store URL
--knowledge-url URLKnowledge store URL
--state-url URLState store URL
--allTest all configured stores

Example:

bash
praisonai persistence doctor \
    --conversation-url "postgresql://postgres:pass@localhost/db" \
    --knowledge-url "http://localhost:6333" \
    --state-url "redis://localhost:6379"

# Auto-detects libsql:// → turso, *.supabase.co → supabase, weaviate URL → weaviate
praisonai persistence doctor \
    --conversation-url "libsql://my-db.turso.io?authToken=***" \
    --knowledge-url    "http://my-cluster.weaviate.cloud" \
    --state-url        "redis://localhost:6379"

Backend Auto-Detection

praisonai persistence doctor inspects each --*-url and picks the matching store client automatically — the same rules the live persistence path uses.

Diagram

Backend Auto-Detection

known scheme

unknown scheme

🔗 –*-url

🧠 _detect_backend

✅ Matched backend

⚠️ Lenient fallback

Detection delegates to the canonical resolver PraisonAIDB._detect_backend, so the doctor recognises the same schemes as the live path.

Recognised schemes:

URL exampleDetected backendStore kind
postgresql://…, postgres://…postgresconversation
mysql://…mysqlconversation
libsql://…tursoconversation
sqlite://…, *.dbsqliteconversation
https://…neon.techpostgresconversation
https://…cockroachlabs.cloud / .cockroachlabs.compostgresconversation
https://…xata.shpostgresconversation
postgresql://…supabase.com (direct Postgres)postgresconversation
https://…supabase.co / …supabase.com (REST)supabaseconversation
http(s)://…qdrant… / :6333qdrantknowledge
chroma://… (special-cased)chromaknowledge
http(s)://…weaviate…weaviateknowledge
redis://…redisstate

Fallback defaults apply when the scheme is not recognised — the doctor keeps working using a lenient per-store default:

OptionFallback backend
--conversation-urlsqlite
--knowledge-urlqdrant (with chroma:// special-case preserved)
--state-urlmemory

Run

Run an agent with persistence.

bash
praisonai persistence run [options] "prompt"

Options:

OptionDescription
--session-id IDSession identifier
--user-id IDUser identifier (default: “default”)
--conversation-url URLConversation store URL
--knowledge-url URLKnowledge store URL
--state-url URLState store URL
--agent-name NAMEAgent name (default: “Assistant”)
--agent-instructions TEXTAgent instructions
--dry-runShow config without running

Example:

bash
praisonai persistence run \
    --session-id "my-session" \
    --conversation-url "postgresql://localhost/db" \
    "Hello, my name is Alice"

Resume

Resume an existing session.

bash
praisonai persistence resume --session-id ID [options]

Options:

OptionDescription
--session-id IDSession to resume (required)
--conversation-url URLConversation store URL
--show-historyDisplay conversation history
--continue "prompt"Continue with new prompt

Example:

bash
# Show history
praisonai persistence resume \
    --session-id "my-session" \
    --conversation-url "postgresql://localhost/db" \
    --show-history

# Continue conversation
praisonai persistence resume \
    --session-id "my-session" \
    --conversation-url "postgresql://localhost/db" \
    --continue "What's my name?"

Export

Export a session to a JSONL file.

bash
praisonai persistence export --session-id ID [options]

Options:

OptionDescription
--session-id IDSession to export (required)
--conversation-url URLConversation store URL
--output FILEOutput file path (default: session-{id}.jsonl)

Example:

bash
praisonai persistence export \
    --session-id "my-session" \
    --conversation-url "postgresql://localhost/db" \
    --output session.jsonl

The file holds one JSON line with this shape:

json
{
  "session_id": "my-session",
  "user_id": "default",
  "agent_id": "imported",
  "name": "...",
  "metadata": {},
  "created_at": 1730000000.0,
  "messages": [
    {"id": "...", "role": "user", "content": "Hello", "metadata": {}, "created_at": 1730000000.0}
  ]
}

Import

Import a session from a JSONL file.

bash
praisonai persistence import --file FILE [options]

Options:

OptionDescription
--file FILEJSONL file to import (required)
--conversation-url URLConversation store URL

Example:

bash
praisonai persistence import \
    --file session.jsonl \
    --conversation-url "postgresql://localhost/db"

On an async store, import uses the same fixed dispatch path shipped in PR #5380.

Environment Variables

VariableDescription
PRAISON_CONVERSATION_URLDefault conversation store URL
PRAISON_KNOWLEDGE_URLDefault knowledge store URL
PRAISON_STATE_URLDefault state store URL
OPENAI_API_KEYOpenAI API key for agent
bash
export PRAISON_CONVERSATION_URL="postgresql://localhost/db"
export OPENAI_API_KEY="your-key"

# Now commands are simpler
praisonai persistence doctor --all
praisonai persistence run --session-id "my-session" "Hello!"

Troubleshooting

Connection refused:

  • Check Docker containers are running
  • Verify URL format and credentials

No API key:

  • Set OPENAI_API_KEY environment variable