run command executes agents from YAML configuration files or direct prompts.
For a quick one-off prompt you can omit the
run subcommand entirely: praisonai "What is the capital of France?" is equivalent to praisonai run "What is the capital of France?" when the positional argument isn’t an existing file or a .yaml/.yml path. Use praisonai run when you need flags like --output stream-json, --model, --continue, --session, --no-rules, --allow, etc.Single-word direct prompts that look like reserved commands or common typos now fail fast with a hint on
stderr and exit code 2. To send a genuine single word to the model, use praisonai run "<word>" explicitly. See Unknown Command Guard.Usage
Arguments
| Argument | Description |
|---|---|
TARGET | Agent file (YAML) or direct prompt text |
Options
| Option | Short | Description | Default |
|---|---|---|---|
--output | -o | Output mode: text, json, stream-json, silent, verbose | text |
--model | -m | LLM model to use | gpt-4o-mini |
--framework | -f | Framework: praisonai, crewai, autogen | praisonai |
--interactive | -i | Enable interactive mode | false |
--verbose | -v | Verbose output | false |
--stream | Stream output | true | |
--no-stream | Disable streaming | ||
--trace | Enable tracing | false | |
--memory | Enable memory | false | |
--tools | -t | Comma-separated tool names (e.g. web_search,github) or a tools.py file path (resolved via ToolResolver) | |
--toolset | Comma-separated named toolset groups to load | ||
--max-tokens | Maximum output tokens | 16000 | |
--continue | -c | Continue the most recent session for this project | false |
--session | -s | Resume a specific session ID | |
--fork | Fork from the specified session (requires --session) | false | |
--no-save | Don’t auto-save the session after execution | false | |
--no-rules | Disable auto-injection of project instruction files (AGENTS.md, CLAUDE.md, etc.) | false | |
--no-context | Disable AGENTS.md/CLAUDE.md auto-loading into system prompt | false | |
--agent | -a | Use a named custom agent from .praisonai/agents/ | |
--thinking | Reasoning effort for this invocation: off, minimal, low, medium, high | ||
--command | Execute a named custom command; TARGET becomes $ARGUMENTS | ||
--allow | Allow a permission pattern (e.g. 'bash:git *'); repeatable | ||
--deny | Deny a permission pattern; repeatable | ||
--permissions | Path to a YAML permission rules file | ||
--permission-default | Default action for unmatched patterns: allow, deny, or ask | ||
--approval | Approval backend mode: console, plan, accept-edits, bypass | ||
--restore | Restore workspace to a checkpoint (id, last, or latest) and exit | ||
--no-checkpoint | Disable automatic pre-run checkpoint for this invocation | false | |
--attach | Run on the warm runtime under this session id so other terminals can observe via praisonai attach |
Piped Input
praisonai run composes in Unix pipelines. Piped stdin is merged with your prompt argument (prompt first, then piped body).
TARGETis an existing.yaml/.ymlfile (case-insensitive).--agentor--commandis used.--restoreis set (the command exits before ingestion).
Output Modes
--output controls how results and events are written to stdout.
- text (default)
- json
- stream-json
- silent
- verbose
Rich-formatted human-readable output in the terminal.
Standalone vs wrapper
On a standalonepip install praisonai-code install, default run "…" (without --output actions) now requires the praisonai wrapper and surfaces an install hint:
run --output actions "…" runs in-process with no wrapper — the standalone-safe path. See the PraisonAI Code CLI standalone-limits table for the full command matrix.
run --output actions honours --tools and --toolset. These flags were previously dropped in actions mode; they now reach parity with the default, YAML, and Python surfaces. The same ToolResolver path resolves comma-separated names, and tools.py file paths continue to load as before.Examples
Run a built-in preset (no YAML required)
Run with a custom agent
Run with a custom agent and CLI permission override
Run with reasoning effort
--thinking applies across direct-prompt, actions-mode, and custom-agent paths. See Thinking.
Run with a custom command
--continue, --session, --fork, --no-save) work with --agent.
Run from YAML file
Run with a prompt
Run with specific model
Run in interactive mode
Run with memory enabled
Run with verbose output
Run with custom tools
run actions mode, --tools and --toolset are now wired end-to-end (previously silently dropped).
Resume a previous session
Continue where you left off in your current project:After every run with an active session, a compact usage footer prints to stdout:This footer is silenced under
--output json. Token and cost totals accumulate across resumed runs — they are never reset. See Cost Tracking for per-session totals.Run without project instruction files
By default,praisonai run auto-loads AGENTS.md, CLAUDE.md, PRAISON.md, etc. from the project root. Use --no-rules to opt out:
--verbose to see which instruction files were loaded:
Live session attach
Tag a warm-runtime run with a session id so other terminals can stream its events withpraisonai attach.
--attach is supported for direct prompt runs only — not YAML files, --agent, or --command. Requires a compatible warm runtime (praisonai daemon start). Major-version mismatch falls back to in-process execution for run, or exit code 1 for attach.Project context
By default,praisonai run walks up from the current directory to your git root and prepends any AGENTS.md / CLAUDE.md / agents.md / .agents/AGENTS.md it finds to the agent’s system prompt, layered on top of ~/.praisonai/AGENTS.md. Pass --no-context (or set PRAISON_NO_CONTEXT=true) to disable. See Context Files for details.
First-run Credential Check
praisonai run verifies credentials are configured before doing any work.
If no API key is found in environment variables or stored credentials, you’ll see:
Interactive (TTY):
1 in CI mode. Set any supported env var to bypass the check entirely:
Session Continuity
Pick up where you left off —praisonai run remembers per-project conversations and tracks cumulative token usage and cost.
Usage footer
When running with an active session (--session <id> or --continue), a compact footer appears after each answer:
--json / --output json mode, but usage is still persisted into the session record. Totals accumulate across runs and survive resume. See Cost & Token Tracking for the full breakdown.
Continue the last run
Continue the most recent session for your current project:
--continue searches both the project store and the global default store, so it resolves the genuinely most-recent root session — including ones created by chat, gateway, TUI, API, or a bare Agent(session_id=...). If no previous session exists, a warning is shown and a new session starts.Resume a specific session
Resume a specific session by ID (find IDs with Errors out if the session ID does not exist in the current project.
praisonai session list):Try a different approach without losing history
Fork from an existing session to try alternatives:Creates a new session ID copied from the source. Both sessions evolve independently.
What gets restored on --continue / --session
When you use
--continue or --session <id>, every prior user and assistant message in that session is replayed into the agent’s chat history before your new prompt runs. The agent answers with full awareness of what was discussed before — no manual context-passing required.Restored automatically: user and assistant chat_history messages; auto_save continues for the resumed session.Not restored: tool outputs and intermediate scratchpad (conversation messages only); file artefacts from earlier runs remain on disk but are not re-emitted.| Restored | From |
|---|---|
| Chat history (user + assistant messages) | Project store: ~/.praisonai/sessions/projects/<project_id>/<session_id>.json — or global store: ~/.praisonai/sessions/<session_id>.json (used when --continue picks up a session created by chat, gateway, TUI, API, or a bare Agent(session_id=...)) |
| Auto-save bookmark (only new messages appended) | Same file the session lives in |
| Session ID | --session <id> flag, or the last root session across both stores for --continue |
As of the fix for PraisonAI #2655,
--continue searches both the project-scoped store and the global default store, so sessions created by chat, gateway, TUI, API, or a bare Agent(session_id=...) are all resumable. Sub-agent / forked child sessions are skipped in favour of the last root session.History restore and save wiring landed in PR #1963. Earlier builds discovered the session but silently dropped prior history on resume — upgrade
praisonai if --continue returns empty context.Choosing between the flags
- Prompt mode
- YAML mode
Session usage footer
After every prompt run inside an active session, a single-line footer shows cumulative token and cost totals:- Totals are cumulative since session start — not just the last prompt.
- Best-effort: if usage cannot be read or priced, the footer is silently skipped.
- Suppressed in JSON mode (
--output json,--output stream-json). There is no--no-usageflag. - Usage is persisted to
~/.praisonai/sessions/<id>.jsonso resuming with--continueor--session <id>rehydrates the totals and keeps accumulating.
Troubleshooting session continuity
`--continue` runs but the agent has no memory of the previous turn
`--continue` runs but the agent has no memory of the previous turn
Fixed in PR #1963 — sessions were discovered but history was not loaded. Upgrade
praisonai and re-run.`--output actions --session <id>` raised TypeError about resume_session
`--output actions --session <id>` raised TypeError about resume_session
Fixed by PR #1963. Upgrade
praisonai.`--output actions` with `--auto-save` raised TypeError about `auto_save`
`--output actions` with `--auto-save` raised TypeError about `auto_save`
Fixed by commit
7016bfa (issue #2700). The actions-output branch of run re-imported build_cli_memory_config / apply_cli_session_continuity from praisonai_code.cli.utils.project, shadowing the correct praisonai_code.cli.state.project_sessions versions. The stale variant lacked the auto_save keyword, so wiring session continuity in actions mode raised TypeError: apply_cli_session_continuity() got an unexpected keyword argument 'auto_save'. Upgrade praisonai-code and re-run.Session continuity works in prompt mode but not with agents.yaml
Session continuity works in prompt mode but not with agents.yaml
Also fixed by PR #1963 — YAML and file-mode runs use the same project session store as prompt-mode runs.
`--no-save` together with `--session <id>`
`--no-save` together with `--session <id>`
--no-save wins — the run still resumes from the named session (agent has context), but new messages are not persisted. Useful for read-only follow-ups on an existing thread.Sessions are scoped to the current project — detected from the git root, or the current directory if you’re not in a repo. Two projects never see each other’s sessions.
Agent File Format
Create anagents.yaml file:
Session Management
Sessions are scoped to the current project (git root, or current directory if not a git repository). Each run auto-saves to a generatedsession-<uuid8> unless --no-save is set.
Use
praisonai session list to view saved sessions for the current project, or praisonai session list --all to see sessions across all projects.Checkpoint & Rewind
praisonai run auto-checkpoints your workspace before YAML-file runs so a bad turn can be rewound with one command.
- Runs before any YAML-file execution (
*.yaml/*.ymltargets only). - Label:
run:<run_id>(or"auto checkpoint before run"as a fallback). - Workspace: the directory of the target YAML file, not the current directory.
- Plain-prompt runs are skipped to avoid empty-checkpoint noise.
- Best-effort — failures are swallowed and never block the run. Use
--verboseto see"Auto-checkpoint skipped: …"on failure. - Gated by
checkpoints.auto(defaulttrue) in your project config; override per-run with--no-checkpoint. - Reads
checkpoints.storage_dirfrom your project config so the auto-checkpoint/restore path shares the same store aspraisonai code --checkpointssessions. See Checkpoints for the config block.
| Flag | Description | Default |
|---|---|---|
--restore <id|last|latest> | Restore the workspace to a checkpoint and exit — nothing runs. | — |
--no-checkpoint | Disable the automatic pre-run checkpoint for this invocation. | false |
--restore rewinds the workspace and exits before any agent execution — it is a pure undo, not a run.
See Checkpoints and Checkpoint CLI for managing checkpoints directly.See Also
- Session - Session management commands
- Project-Scoped Sessions - How project sessions work
- Checkpoints - Auto-checkpoint and rewind feature
- Checkpoint CLI - Checkpoint subcommands
- Agents - Agent management
- Workflow - Workflow execution
- Interactive TUI - Interactive terminal interface
- Attach - Stream live events from a warm-runtime session

