Auto Mode
Automatically generate and execute agents with intelligent tool discovery
The --auto flag automatically generates an agents.yaml configuration from a natural language task description, using intelligent tool discovery to assign the most appropriate tools based on task analysis.
Quick Start
praisonai --auto "Create a research team to analyze market trends"Auto Mode vs Recipe Create
flowchart LR
subgraph Auto["praisonai --auto"]
A1[Generate YAML]
A2[Execute Immediately]
end
subgraph Recipe["praisonai recipe create"]
R1[Generate Folder]
R2[Optimize Loop]
R3[Ready to Run]
end
A1 --> A2
R1 --> R2
R2 --> R3
style A1 fill:#8B0000,color:#fff
style A2 fill:#189AB4,color:#fff
style R1 fill:#8B0000,color:#fff
style R2 fill:#189AB4,color:#fff
style R3 fill:#8B0000,color:#fff- Generates and executes immediately
- Creates
agents.yamlin current directory - Best for one-off tasks
- No optimization loop
- Creates a reusable recipe folder
- Includes
agents.yaml+tools.py - Optimization loop for quality
- Best for reusable workflows
Usage
praisonai --auto "<task description>" [options]Options
| Option | Description |
|---|---|
--auto | Enable auto mode with task description |
--merge | Merge with existing agents.yaml instead of overwriting. Refuses to clobber an un-parseable target — see Merge safety below. |
--framework | Framework adapter to use. Discovered dynamically from the adapter registry — built-in (ag2, autogen, autogen_v4, crewai, praisonai) and any installed third-party adapter (entry-point group praisonai.framework_adapters). |
Merge safety
--merge reads the existing agents.yaml (or workflow YAML) before writing the merged result. If that file cannot be parsed, the merge refuses to overwrite it — your data is preserved instead of being silently replaced with a freshly generated scaffold.
flowchart LR
M["--merge"] --> R["📖 Read target YAML"]
R --> P{"Parses?"}
P -->|Yes| MG["🔀 Merge + atomic write"]
P -->|"yaml.YAMLError"| BK["💾 Write <file>.<stamp>.bak"]
BK --> E["🛑 Raise MergeConflictError<br/>(no write)"]
classDef flag fill:#8B0000,stroke:#7C90A0,color:#fff
classDef proc fill:#189AB4,stroke:#7C90A0,color:#fff
classDef ok fill:#10B981,stroke:#7C90A0,color:#fff
classDef warn fill:#F59E0B,stroke:#7C90A0,color:#fff
class M flag
class R,BK proc
class P warn
class MG ok
class E warnWhen the target is un-parseable, --merge now:
- Writes a collision-safe backup at `<file>.
.bak` next to the original.
- Raises
praisonai.auto.MergeConflictError— which propagates out ofconvert_and_saveto the CLI, so no write happens and your original file stays intact.
MergeConflictError: Refusing to overwrite un-parseable agents.yaml: mapping values are not allowed here … Original preserved at agents.yaml.20260906143221.bak. Fix the file or re-run without --merge.If the backup copy itself fails, the original is left untouched and the message says so instead (Backup failed; original left untouched at <path>.).
Resolution: fix the reported parse error in your YAML, or re-run without --merge to regenerate the file from scratch.
The same protection applies to the workflow YAML path (WorkflowAutoGenerator.merge_with_existing_workflow).
Nested agent-reference rewriting
When --merge renames an incoming agent to avoid clobbering an existing one (e.g. writer → writer_auto_1), every reference to the old name is rewritten — including refs nested inside if / then / else branches, loop payloads, nested steps, parallel lists, route targets, and bare step: "writer" entries. The merged YAML runs without a manual rename pass.
Intelligent Tool Discovery
Auto mode sources tool suggestions from the canonical ToolResolver.list_available(), so only tools you actually have installed are surfaced.
Keyword hints still prioritise suggestions by task, but the recommended set is intersected with the installed registry before it reaches the prompt.
graph LR
T[🎯 Topic] --> K[🔑 Keyword hints]
K --> I{🔍 Intersect with<br/>installed registry}
I --> P[📝 Prompt: AVAILABLE TOOLS installed]
classDef topic fill:#8B0000,stroke:#7C90A0,color:#fff
classDef proc fill:#189AB4,stroke:#7C90A0,color:#fff
classDef out fill:#10B981,stroke:#7C90A0,color:#fff
class T topic
class K,I proc
class P outWhen the resolver is available, the generation prompt header reads “AVAILABLE TOOLS (installed)” and lists only installed tools. If the resolver cannot be constructed, auto mode falls back to keyword hints and the header reads “AVAILABLE TOOLS BY CATEGORY”.
The legacy AVAILABLE_TOOLS and TOOL_CATEGORIES remain importable from praisonai.auto for backward compatibility.
The enhanced auto mode analyzes your task description and automatically assigns appropriate tools from 9 categories:
| Category | Tools | Triggered By |
|---|---|---|
| Web Search | internet_search, tavily_search, exa_search | “search”, “find”, “look up” |
| Web Scraping | scrape_page, crawl, extract_text | “scrape”, “crawl”, “extract” |
| File Operations | read_file, write_file, list_files | “read file”, “save”, “load” |
| Code Execution | execute_command, execute_code | “execute”, “run code”, “script” |
| Data Processing | read_csv, write_csv, read_json | “csv”, “excel”, “json”, “data” |
| Research | search_arxiv, wiki_search | “research”, “paper”, “wikipedia” |
| Finance | get_stock_price, get_historical_data | “stock”, “price”, “financial” |
| Math | evaluate, solve_equation | “calculate”, “math”, “equation” |
| Database | query, find_documents | “database”, “sql”, “mongodb” |
Strict structured-output providers
Auto mode sends a closed response schema (additionalProperties: false) so providers with strict structured output, such as OpenAI’s strict response_format, accept it instead of returning HTTP 400 "Invalid schema".
from praisonai.auto import WorkflowAutoGenerator
generator = WorkflowAutoGenerator(topic="Draft, review, and polish a launch email")
path = generator.generate(pattern="evaluator-optimizer")
print(path) # workflow.yaml, generated against a strict schemagraph LR
T[🎯 Topic] --> S[🔒 Closed schema<br/>id-based lists]
S --> L[🧠 LLM]
L --> R[🔁 Rebuild keyed maps]
R --> Y[✅ agents.yaml / workflow.yaml]
classDef topic fill:#8B0000,stroke:#7C90A0,color:#fff
classDef cfg fill:#6366F1,stroke:#7C90A0,color:#fff
classDef proc fill:#189AB4,stroke:#7C90A0,color:#fff
classDef out fill:#10B981,stroke:#7C90A0,color:#fff
class T topic
class S cfg
class L,R proc
class Y outThe LLM returns agents, roles, tasks, and routes as lists with id fields; auto mode converts them back to the keyed YAML you already use, so the YAML format is unchanged.
Generated workflow step shapes
praisonai workflow auto can emit these step shapes:
| Shape | Example |
|---|---|
| Agent step | {agent: writer, action: "Draft"} |
| Routing | {route: {default: [writer]}} |
| Parallel | {parallel: [{agent: a, action: "..."}, ...]} (plain agent steps only) |
| Loop | {loop: {over: items, var_name: item, step: writer}} — also from_csv, from_file, parallel, max_workers, context, steps |
| Repeat | {agent: writer, repeat: {until: approved, max_iterations: 3}} |
| Branching | {if: {condition: "...", then: [...], else: [...]}} |
| Include | {include: recipe-name} or {include: {recipe: x, input: "..."}} |
| Nested steps | {steps: [...]} |
Step keys outside the workflow DSL are rejected during generation instead of being silently dropped when the workflow runs.
Generated evaluator-optimizer workflow
--pattern evaluator-optimizer generates three sequential agents: a drafter, an evaluator that gives feedback, and a reviser that applies it.
steps:
- agent: drafter
action: "Draft the initial content for: {{input}}"
output_variable: draft
- agent: evaluator
action: "Give specific, actionable feedback on the draft."
- agent: reviser
action: |
Revise the draft using this feedback: {{previous_output}}
Original draft:
{{draft}}Auto mode always sets output_variable: draft on the first step and appends the {{draft}} block to the reviser if the model left it out. For a true generate ↔ evaluate loop that exits on approval, write it by hand with Evaluator Optimiser.
Validation errors
| You see | Cause | Fix |
|---|---|---|
ValueError: Duplicate generated ID: 'writer' | The LLM emitted two agents, roles, or tasks with the same ID (previously the second silently replaced the first). | Re-run, or make the topic more specific. |
pydantic.ValidationError ... Extra inputs are not permitted | The LLM emitted a step option the workflow DSL does not support. | Re-run; see YAML Workflows for supported options. |
ValueError: Evaluator workflows require three steps with distinct agents. | An evaluator-optimizer generation did not return exactly three steps with three different agents. | Re-run, or use a stronger model. |
Examples
Financial Research
praisonai --auto "Research stock prices and create a financial report"Generated tools: get_stock_price, get_stock_info, get_historical_data, write_file
Web Scraping
praisonai --auto "Scrape websites for product data and save to CSV"Generated tools: scrape_page, crawl, extract_text, write_csv, read_csv
Data Analysis
praisonai --auto "Analyze CSV data and generate statistics"Generated tools: read_csv, analyze_csv, calculate_statistics, write_file
With Framework
praisonai --auto "Create a data analysis team" --framework praisonaiMerge Existing
praisonai --auto "Add a quality reviewer" --mergeHow It Works
flowchart TD
A["🎯 Task Description"] --> B["📊 Complexity Analysis"]
B --> C{"Simple?"}
C -->|Yes| D["1 Agent"]
C -->|No| E{"Moderate?"}
E -->|Yes| F["2 Agents"]
E -->|No| G["3-4 Agents"]
D --> H["🔧 Tool Assignment"]
F --> H
G --> H
H --> I["📝 Generate YAML"]
I --> J["▶️ Execute"]
style A fill:#8B0000,color:#fff
style B fill:#189AB4,color:#fff
style H fill:#189AB4,color:#fff
style I fill:#8B0000,color:#fff
style J fill:#189AB4,color:#fff- Task Complexity Analysis
Determines if task is simple (1 agent), moderate (2 agents), or complex (3-4 agents)
- Keyword Matching
Identifies relevant tool categories from task description
- Tool Assignment
Assigns appropriate tools from matched categories
- Agent Generation
Creates specialized agents with focused roles
- YAML Output
Generates
agents.yamlconfiguration file - Execution
Runs the generated agents to complete the task
LiteLLM unlocks 100+ providers for auto mode, with automatic OpenAI fallback. Learn how provider selection works. Generated job-workflow YAML no longer pins gpt-4o-mini — steps inherit your configured model. LiteLLM transient errors (429/5xx/timeouts) are retried up to 2× before OpenAI fallback engages.
Generated Output
The auto mode creates an agents.yaml file with:
- Intelligent agent count based on task complexity
- Specialized roles with clear responsibilities
- Appropriate tools from 50+ available tools
- Focused tasks with expected outputs
- Process configuration (sequential, parallel, etc.)
Generated YAML files are written atomically — a crash or interruption during save will not corrupt the existing file.
When to Use Each
Use Auto Mode When…
- You need a quick one-off task
- You want immediate execution
- You don’t need to save the workflow
- You’re prototyping ideas
Use Recipe Create When…
- You want a reusable workflow
- You need optimization for quality
- You want to share the recipe
- You need custom tools in
tools.py - You want to version control the recipe