Skip to main content
The 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.
praisonai run exits 1 whenever the agent fails to produce a result. Under --output json / --output stream-json the failure surfaces as {"status": "failed", "code": "run_failed"} with an actionable remediation. See Exit Codes for the full table.
praisonai run "..." with no cloud key and no --model picks a reachable local model automatically. If Ollama (or any OpenAI-compatible local server) is running, you’ll see a one-line stderr notice and the run continues:
An explicit --model still takes over. See Keyless Local-First Run.

Usage

Arguments

Bare Prompts

You can drop the run keyword entirely for one-shot prompts:
Bare prompts inherit everything run gives you — --output modes, session continuity, credential gate, and permissions.
Any invocation with a -/-- flag, or a positional ending in .yaml/.yml, keeps the legacy dispatcher — fully backward-compatible. Multi-token unquoted prompts are joined into a single run positional so praisonai build a weather agent reaches the model as one prompt.

Options

For workflow guidance, see Isolated Runs or the flag-focused guide at Run —worktree.

Delegating to Named Agents

Let a running agent delegate sub-tasks to your own named agents in .praisonai/agents/*.md. Pass --subagents to opt agents in for a single run, or mark agents with mode: subagent to expose them on every run.
See Named Agent Delegation for the full guide.

Isolated Runs (Git Worktree)

Add --worktree and each run gets its own git branch and checkout — concurrent runs never clobber each other’s edits.
What happens on exit depends on what the run produced:
The run commits everything (git add -A + git commit --no-verify) to the isolated branch, then removes the worktree checkout while keeping the branch. You’ll see:
If the commit can’t be made (e.g. no git identity configured), the worktree is kept in place with a warning so output is never lost.
The worktree checkout and its branch are torn down entirely — nothing is left behind.
The worktree checkout stays in place for in-place review, regardless of whether changes were made.
--worktree is a no-op outside a git repository — it prints Not a git repository; running without worktree isolation. and runs in place, so it’s safe to add unconditionally. Change detection uses git status --porcelain, so brand-new untracked output counts as a change.
Isolation applies to direct prompt and YAML file runs only. These combinations are rejected up front (exit code 1):
  • --worktree + --attach — the warm runtime is a separate process whose working directory can’t be redirected.
  • --worktree + --agent / --command / --profile / --profile-deep — only prompt and YAML runs are supported.
  • --keep without --worktree--keep requires --worktree.
When --worktree is used with a warm-runtime-eligible prompt, the run falls back to in-process execution so it never attaches to a cached warm agent.
Human-facing worktree messages are suppressed under --output json / --output stream-json, so structured runs stay machine-parseable.
This CLI flag wraps the same core primitive documented for the Python API. Pick the layer that fits:

Python API — GitWorktreeAdapter

Provision worktrees directly from Python for concurrent agents.

Per-Kanban-Task Worktrees

Give each kanban task its own worktree with workspace_kind="worktree".

Piped Input

praisonai run composes in Unix pipelines. Piped stdin is merged with your prompt argument (prompt first, then piped body).
Piped input is skipped when:
  • TARGET is an existing .yaml / .yml file (case-insensitive).
  • --agent or --command is used.
  • --restore is set (the command exits before ingestion).
See Piped Input for the full behaviour.

Output Modes

--output controls how results and events are written to stdout.
Rich-formatted human-readable output in the terminal.

Exit Codes

praisonai run returns a non-zero exit code whenever the agent fails to produce a result, so CI pipelines and scripts can branch on the exit code instead of scraping stderr.

Failure payload (--output json / --output stream-json)

When the agent produces no result, the CLI emits a machine-readable failure object and exits 1:
The paired error event carries the same status and an error code:
The human-facing stderr line includes an actionable remediation:
The failure contract applies to every run path — direct prompt, YAML file, --agent, --attach, --profile, and --profile-deep. Profiled runs still print the profiling report before exiting non-zero, so you keep the profile even on failure.

CI usage

Test the run in-process first — the CLI’s exit-code contract mirrors this success test.
The CLI does the same success test for you and returns exit 1 on failure:
See Agent Run Outcomes → CLI Mapping for how the SDK-level statuses collapse into this single exit signal.

Standalone vs wrapper

On a standalone pip install praisonai-code install, default run "…" and the human-readable text modes (--output plain/verbose/silent) now route through the in-process Agent (PR #2853) — the same path used by the structured modes (--output actions|json|stream|stream-json). Only chat and code still require the praisonai wrapper and surface an install hint.
Every text mode — default run "…" and --output plain|verbose|silent|actions|json|stream|stream-json — runs in-process with no wrapper. 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.
run --agent honours --tools, --toolset, and auto-discovers .praisonai/tools/*.py. These were previously silently dropped when --agent was used. The --agent path now composes its toolset by unioning the agent’s frontmatter tools: list with --tools/--toolset and (when PRAISONAI_ALLOW_LOCAL_TOOLS=true or --allow-local-tools is set) auto-discovered project-local tools, dedup’d by callable identity. Fixes #3047.

Examples

Run a built-in preset (no YAML required)

Run with a custom agent

Run with delegatable subagents

Let the running agent hand named sub-tasks to your other .praisonai/agents/*.md agents, each under its own model/tools/permissions.
Wiring is a no-op when no delegatable agents exist — default runs are unchanged. See Named Agent Delegation.

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

Session flags (--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

In run actions mode, --tools and --toolset are now wired end-to-end (previously silently dropped). The same is now true for run --agent <name>--tools/--toolset merge into the agent’s frontmatter tools: list instead of being dropped (#3047).

Run with project-local tools

Local .praisonai/tools/*.py files require an opt-in because loading them executes Python:
If tool files exist but neither is set, run prints a one-line hint naming the location(s) and enable step — no more silent skip. See Project-Local Tools.

Resume a previous session

Continue where you left off in your current project:
Resume a specific session by ID:
Fork from a session to try a different approach:
Run without saving the session:
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:
Use --verbose to see which instruction files were loaded:

Isolated worktree runs

Pass --worktree to run the agent on a fresh git branch and worktree so its output never touches your working tree. Add --keep to retain the worktree and branch for review.
See Run in an Isolated Worktree for the full teardown behaviour matrix and rejected-combination rules.

Live session attach

Tag a warm-runtime run with a session id so other terminals can stream its events with praisonai 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.

Isolated Runs (--worktree)

Add --worktree to run the agent on a fresh git branch and worktree so its edits never touch your working tree.
--worktree provisions a fresh git worktree on a new branch, chdirs into it, runs the agent, then prints the branch name and a git status --short summary. Every other flag (--tools, --model, --session, --thinking, --memory) applies unchanged.

How teardown protects your output

Changes are detected with git status --porcelain, so brand-new untracked files count. When the agent produced output, the CLI auto-commits everything to the branch (praisonai run: <target>, --no-verify) and retains the branch — only the worktree checkout is pruned. A run with no changes is torn down completely. If the auto-commit fails (for example no user.email/user.name is configured, or a hook rejects it), the worktree checkout is kept in place with a Could not commit isolated changes; worktree kept at <path> (branch '<branch>') for manual review. warning — your output is never lost.

What happens on teardown

The run detects changes with git status --porcelain, so brand-new (untracked) files are never lost.
--worktree never destroys the agent’s output. On any change the branch is committed and retained even without --keep — only the worktree checkout is pruned.

When to use it

Recipes

A short uuid4 token is appended to each run’s branch name (e.g. praisonai/agents.yaml-a1b2c3d4), so concurrent runs of the same target never collide.

Compatibility

The CLI rejects incompatible combinations at parse time.
A short random 8-char token is appended to every branch/worktree name, so two runs of the same target never collide — run praisonai run "..." --worktree twice in parallel and each gets its own branch and directory.

Best practices

On completion, any tracked or untracked change is committed to the branch and the branch is retained. Even if the auto-commit fails (missing user.email/user.name, hook rejection), the worktree checkout is kept in place — you never have to fight the CLI for your agent’s output.
Auto-commit already preserves your work on a branch. --keep is for cases where you want to review files in place before merging — compare screenshots, or run a local dev server against the checkout.
The flag is a transparent no-op outside git. Wire it into every project script without conditionals: praisonai run --worktree "..." runs in the current cwd if there’s no repo, printing Not a git repository; running without worktree isolation.
--keep never auto-removes. When you’re done: git worktree remove <path> && git branch -D praisonai/…. To see leftovers from all runs: git worktree list.
Three ways to get worktree isolation, one shared primitive:
  • CLI (this page)praisonai run --worktree for one-off human-driven runs.
  • Kanban — set workspace_kind="worktree" on a task so dispatched workers each get one (Per-Task Worktree Isolation).
  • Library — instantiate GitWorktreeAdapter yourself for programmatic isolation (Workspace Isolation).

See Workspace Isolation for the underlying GitWorktreeAdapter and the Python API.

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. With no cloud key, it first checks for a reachable local endpoint and adopts it automatically — the prompt below only appears when nothing is reachable. If no cloud key and no local endpoint is found, you’ll see: Interactive (TTY):
Local model reachable (no cloud key needed):
CI / non-interactive (no key and no local endpoint):
When no cloud key is set, PraisonAI probes for a local OpenAI-compatible endpoint (Ollama or any /v1-speaking server) and adopts it automatically before falling back — see Keyless local-first fallback. Non-TTY/CI still exits 1 when nothing is detected, so pipelines fail safe. Exit code is 1 in CI mode. Set any supported env var to bypass the check entirely:

Local model fallback

When no cloud key is configured, praisonai run "..." probes for a reachable local endpoint (Ollama or any OpenAI-compatible server) and adopts its model + base URL for the run — no --model needed. A cloud key always wins; the local probe only runs as a fallback.
See Auth, First-run Onboarding, and Keyless Local-First Run for the full behaviour matrix and CI examples.

Session Continuity

Pick up where you left off — praisonai run remembers per-project conversations and tracks cumulative token usage and cost. When running with an active session (--session <id> or --continue), a compact footer appears after each answer:
The footer is suppressed in --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.
1

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.
2

Resume a specific session

Resume a specific session by ID (find IDs with praisonai session list):
Errors out if the session ID does not exist in the current project.
3

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.
4

What gets restored on --continue / --session

When you use --continue or --session <id>, every prior user, assistant, assistant-tool-call, and tool-result 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 and what tools it called — no manual context-passing required. Tool-call persistence in the default JSON store landed in PraisonAI PR #3099.Restored automatically: user, assistant, assistant-tool-call, and tool-result chat_history messages; auto_save continues for the resumed session.Not restored: intermediate scratchpad beyond the persisted tool turns; file artefacts from earlier runs remain on disk but are not re-emitted.
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

--continue / --session / --fork / --no-save work for YAML/team runs identically to prompt runs. Prior team conversation — per-agent chat history and shared team state — is replayed. The flags are honored regardless of whether agents.yaml sets memory: true; session continuity opts the team into shared memory automatically. See YAML / Team Session Continuity.
After every prompt run inside an active session, a single-line footer shows cumulative token and cost totals:
The format is:
  • 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-usage flag.
  • Usage is persisted to ~/.praisonai/sessions/<id>.json so resuming with --continue or --session <id> rehydrates the totals and keeps accumulating.
JSON mode — the footer is suppressed but usage is included in the payload:

Troubleshooting session continuity

Fixed in PR #1963 — sessions were discovered but history was not loaded. Upgrade praisonai and re-run.
Fixed by PR #1963. Upgrade praisonai.
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.
Also fixed by PR #1963 — YAML and file-mode runs use the same project session store as prompt-mode runs.
--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 an agents.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 generated session-<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.
Auto-checkpoint behaviour:
  • Runs before any YAML-file execution (*.yaml / *.yml targets 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 --verbose to see "Auto-checkpoint skipped: …" on failure.
  • Gated by checkpoints.auto (default true) in your project config; override per-run with --no-checkpoint.
  • Reads checkpoints.storage_dir from your project config so the auto-checkpoint/restore path shares the same store as praisonai code --checkpoints sessions. See Checkpoints for the config block.
New checkpoint flags:
--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