Fast CLI Startup

Sub-commands load only when you run them — every CLI invocation starts fast

Sub-commands load on demand — only the module you actually use is imported, so every praisonai invocation starts in milliseconds regardless of how many commands exist.

python
from praisonaiagents import Agent

agent = Agent(name="assistant", instructions="You are a helpful CLI assistant.")
agent.start("Hello from a fast-starting CLI session.")

The user runs praisonai chat; only the chat module loads, so startup stays fast even with many subcommands installed.

Diagram

Yes

No

📝 You run
praisonai chat

🔍 Sub-command?

🧠 Load only
chat module

⚡ Skip to
prompt/YAML path

✅ Run

How It Works

Diagram
FastCliStartupAgentUserFastCliStartupAgentUserRequestProcessResultResponse

Quick Start

  1. Run a prompt directly

    No sub-command is needed — and no sub-command modules load:

    python
    from praisonaiagents import Agent
    
    Agent(
        name="Assistant",
        instructions="You are a helpful assistant",
    ).start("Summarise the latest sales report")

    The CLI equivalent is identical in startup cost:

    bash
    praisonai "Summarise the latest sales report"
  2. Run a sub-command

    Only the matching module loads — the other ~77 commands stay unloaded:

    bash
    praisonai chat
  3. List all available commands
    bash
    praisonai --help

How It Works

Diagram
Fast CLI StartupAgentUserFast CLI StartupAgentUserRequestProcess requestResultResponse

PraisonAI keeps a static map of command names (_COMMAND_GROUPS in praisonai/cli/app.py). When you run praisonai chat, the CLI checks that map and imports only the chat module. All other ~77 modules are never touched.

The praisonai.run / agents_generator module is fully lazy after PR #4821 — framework adapters load only when a framework is selected. See Lazy Imports & Fast Startup.

Diagram

CLI Startup

Yes

No

praisonai chat

Check _COMMAND_GROUPS

Match found?

Import chat module only

Treat as prompt or YAML

Run chat

Run prompt/YAML


Best Practices

You don't have to opt in

Lazy command dispatch is always on — no flag, no environment variable. Every praisonai invocation benefits automatically.

Adding a new sub-command

Add an entry to _COMMAND_GROUPS in praisonai/cli/app.py:

python
_COMMAND_GROUPS = {
    # existing entries ...
    "mycommand": ".commands.mycommand",
}

Without this entry, praisonai --help won’t list your command and dispatch won’t reach it.

When things go wrong

Run the built-in diagnostic to check your CLI setup:

bash
praisonai doctor

Related