session command manages conversation sessions, allowing you to save, resume, and organize multi-turn interactions.
Quick Start

Commands
Start a Session
List Sessions
- in the Tokens and Cost columns.
Updated columns (praisonaiagents 1.6.85+): The table now shows
ID | Name | Status | Events | Tokens | Cost | Updated. Tokens are formatted with thousands separators (e.g. 12,345); Cost is formatted as $0.0140. Sessions with no recorded usage show - for both.--json to get machine-readable output with usage data per session:
session list (no --project, no --all) merges the current project’s session store with the global default store — every session --continue/resume could see, in one list, deduped by session id (freshest updated_at wins when the same id lives in both stores). Use --all to include every project’s sessions, or --project <id> to restrict to one project’s store only. Cross-store merge landed with the fix for PraisonAI #2655.What shows up
Without--all or --project, the default listing surfaces:
- Sessions created by
praisonai run(project store) ✅ - Sessions created by
chat, gateway, TUI, API, or a bareAgent(session_id=...)(global default store) ✅ new - Sub-agent / forked child sessions still appear here, but
--continueskips them in favour of the last root session.
--project <id> stays project-scoped only; --all widens to every project.
Token / Cost columns
TheTokens and Cost columns show cumulative totals across all runs for each session. Totals are persisted in session-store metadata under usage and updated automatically by praisonai run / direct prompts whenever --session is set or a default project session is active. A - is rendered when no usage has been recorded yet.
JSON output (--json):
| Flag | Description |
|---|---|
| (default — no flag) | Merges the current project’s store with the global default store, deduped by session id |
--all | Show sessions from all projects |
--project <id> | Show sessions for a specific project ID — that project’s store only |
--json | Output as JSON (includes usage, total_tokens, and cost per session) |
Resume a Session
session resume restores chat history, model, and agent name from a previous session.
History is preserved by default via compact retention — older turns are summarised and archived rather than dropped. See Session Persistence — Retention Policies.
Usage: line shows cumulative tokens and cost accumulated across all previous prompts in this session. If no usage has been recorded yet, the line is omitted.
Resume and continue with a prompt
praisonai run --session <id> path. The resume panel is suppressed when a prompt is provided — the run pipeline emits the only top-level output.
Show transcript only (legacy view)
--transcript to inspect a session without restoring state. The panel title shows “Session Transcript”.
Cross-store lookup
session resume finds a session whether it was created via praisonai run --continue (project store) or via the gateway/TUI (global store). See Storage Backends.
When you pass a continuation prompt, the resume panel is suppressed — the run pipeline emits the only top-level output. To inspect a session without continuing, use
--transcript or omit the prompt.Cost & Token Tracking
PraisonAI accumulates input/output/cached tokens and dollar cost on every session run, so you can see exactly what a conversation has spent.Quick Start
What gets persisted
Each session stores ausage object in its metadata:
| Field | Type | Default | Description |
|---|---|---|---|
input_tokens | int | 0 | Cumulative prompt tokens across the session. |
output_tokens | int | 0 | Cumulative completion tokens across the session. |
cached_tokens | int | 0 | Cumulative cached tokens (provider-reported). |
total_tokens | int | 0 | input + output total. |
cost | float | 0.0 | Cumulative dollar cost rounded to 6 decimal places. |
requests | int | 0 | Cumulative number of LLM interactions. |
Footer format
After each prompt run with an active session, the CLI prints:"{input:,} in / {output:,} out · ${cost:.4f}" — locale-formatted integers, 4-decimal cost. The footer is suppressed in --json mode but usage is still persisted.
Resume behaviour
Totals are rehydrated on--continue / --session <id> and keep accumulating — they do not reset. The resume panel shows a usage summary line:
How it works
Reading usage programmatically
Notes
Best-effort — never breaks a run
Best-effort — never breaks a run
Any failure (pricing lookup, persistence error, missing collector) leaves the session untouched. Usage accounting never breaks a run.
Multi-model aware
Multi-model aware
When a run uses more than one model, each model’s tokens are priced individually with
get_pricing(model_name).Cached tokens tracked separately
Cached tokens tracked separately
Provider-reported cached reads are accumulated in
cached_tokens but excluded from cost — the provider already discounts them.Show Session Details
Delete a Session
Help
Token and Cost Tracking
Every session accumulates cumulative token usage and cost across all prompts, visible insession list and the resume panel.
After each run, a single-line footer is printed:
·). The footer reflects cumulative totals since session start, not just the last prompt. It is silently suppressed in JSON mode (--json / --output json) — there is no --no-usage flag.
When you resume a session, the cumulative totals are rehydrated so subsequent prompts keep accumulating:
Working with praisonai run
The same project-scoped store powers --continue and --session on praisonai run. As of PR #1963, every surface restores history from and saves to this store:
praisonai run surface | Restores history? | Saves new messages? |
|---|---|---|
Prompt mode (praisonai run "...") | Yes | Yes (unless --no-save) |
YAML / file mode (praisonai run agents.yaml) | Yes | Yes (unless --no-save) |
Actions mode (--output actions) | Yes | Yes (unless --no-save) |
--auto-save, --session, --continue, and --fork. If you hit a TypeError about auto_save on an older praisonai-code build, upgrade and retry — see the run.mdx troubleshooting section.
As of PR #2277, --session <id> and --continue now persist model and agent_name into session metadata so a later session resume reproduces the same configuration deterministically. For advanced programmatic use, the rehydrate_session helper in praisonai.cli.session returns a RehydratedSession with session_id, chat_history, model, agent_name, metadata, and found fields — see the SDK reference for details.
Using Sessions with Prompts
Continue a Conversation
Session with Other Features
Use Cases
Project-Based Conversations
Learning Sessions
Code Review Sessions
Auto-Save Sessions
Automatically save sessions after each agent run using the--auto-save flag:
Python API
History in Context
Load conversation history from previous sessions into the current context:Python API
Workflow Checkpoints
Save and resume workflow execution at any step:Checkpoint Storage
Project-Scoped Sessions
Sessions are automatically scoped to your current project. PraisonAI detects your project by finding the git repository root, or uses the current working directory as a fallback. Project identification:- Project ID: First 8 characters of SHA256 hash of project root path
- Git detection: Uses
git rev-parse --show-toplevelwith 5-second timeout - Fallback: Current working directory if not in a git repository
Session Storage
Sessions are stored in a project-scoped layout when using the default behavior:--all flag:
Storage Backend Options
Store sessions in different backends for production deployments:| Backend | Best For |
|---|---|
file | Development, debugging |
sqlite | Production, concurrent access |
redis://url | Distributed systems, shared sessions |
Concurrent Sessions
Multiplepraisonai processes can safely share the same session — the CLI store reloads, merges, and writes under an exclusive lock so no messages are lost when the TUI, --interactive mode, and praisonai "…" --session all touch the same file.
Merge Strategy
When two writers race, the session store merges their changes:| Field | Merge strategy |
|---|---|
messages | Union, deduped by (role, content, timestamp); on-disk order preserved, new messages appended |
metadata | Dict merge, incoming wins on key conflict |
total_input_tokens / total_output_tokens / total_cost / request_count | max(on_disk, incoming) |
current_model | Incoming if set, else on-disk |
updated_at | max(on_disk, incoming) |
Lost-Update Prevention
praisonai session show and praisonai session resume always reflect the latest on-disk state — the in-process cache is invalidated automatically when another process writes (mtime-based check).
This concurrent-save safety was added in PR #1854. For the equivalent feature in the SDK-level store, see Multi-Process Safety.
This applies to the default file-backed session store. The
sqlite / redis:// backends in the Storage Backend Options table above handle concurrency via the database itself; the CLI does not add its own merge layer there.Cross-Platform Support
Thepraisonai session commands work on Windows, macOS, and Linux — file locking is automatic and platform-appropriate.
| Platform | File locking | Notes |
|---|---|---|
| Linux / macOS | fcntl.flock() | Exclusive on write, shared on read |
| Windows | Whole-file lock (max(file_size, 1) bytes) — matches Unix fcntl.flock semantics | Blocking exclusive on write, shared (LK_RLCK) on read |
| Other (Pyodide, minimal embedded CPython) | None — logs a one-time warning | Single-process is safe; concurrent writers may corrupt session files |
%USERPROFILE%\.praison\sessions\{session_id}.json following the OS convention via Path.home(). Cross-platform locking was added in PR #1837. Concurrent multi-process writes (e.g. TUI + praisonai --interactive sharing the same session directory) are preserved without message loss as of PR #1885 and PR #1892. For the SDK-level session store with the same cross-platform guarantees, see Session Persistence.
Example usage across platforms:
Best Practices
Naming
Use descriptive names like
project-auth-featureOrganization
Create separate sessions for different projects
Cleanup
Delete old sessions to free up storage
Context
Start new sessions when changing topics significantly
Related
Run Command
Session flags and usage footer for
praisonai runSession Persistence
SDK-level session management
Cost Tracking
Per-session persistence and
/cost slash commandProject Sessions
Persisted usage shape and project scoping

