> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Recipe Cycle Testing

> Create, Run, Judge, Evaluate, and Fix recipes iteratively

The Recipe Cycle Testing workflow helps you iteratively improve your AI agent recipes.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
flowchart LR
    A[Create Recipe] --> B[Run Recipe]
    B --> C[Judge Output]
    C --> D{Score OK?}
    D -->|No| E[Apply Fixes]
    E --> B
    D -->|Yes| F[Done]
    
    style A fill:#8B0000,color:#fff
    style B fill:#8B0000,color:#fff
    style C fill:#189AB4,color:#fff
    style E fill:#189AB4,color:#fff
    style F fill:#189AB4,color:#fff
```

## Quick Start

**1. Create a Recipe**

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai recipe create "Research AI agent frameworks"
```

**2. Run with Trace**

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai recipe run my-recipe --save --name run1
```

**3. Judge the Output**

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai recipe judge run1 --yaml my-recipe/agents.yaml
```

**4. Apply Fixes**

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai recipe apply judge_plan.yaml --confirm
```

**5. Repeat**

Run cycles 2-5 until score reaches target threshold.

## Common Errors & Fixes

> [accordion] Tool Result Truncation
>
> **Error**: `Tool 'tavily_search' result was truncated`
>
> **Cause**: Large search results exceed context window
>
> **Fix**:
>
> * Use `--chunked` flag when judging
> * Reduce `max_results` in tool calls
> * Add instructions to summarize results

> [accordion] Low Task Achievement Score
>
> **Error**: `Task Achievement: 5.0/10`
>
> **Cause**: Agent output doesn't match expected format
>
> **Fix**:
>
> * Add clearer `expected_output` in steps
> * Include specific format requirements in action
> * Add verification instructions to backstory

> [accordion] Hallucination Detected
>
> **Error**: `Hallucination: 3.0/10`
>
> **Cause**: Agent generates unverified information
>
> **Fix**:
>
> * Add instruction to cite sources
> * Use `include_answer: true` in tavily\_search
> * Add verification step in backstory

> [accordion] Missing Goal
>
> **Error**: `Recipe Goal: Not specified`
>
> **Cause**: No `goal` field in agents.yaml
>
> **Fix**: Add a clear, measurable goal:
>
> ```yaml theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
> goal: Research and compare top 5 AI frameworks
> ```

## Tool-Specific Fixes

> [tab] tavily\_search
>
> **Issue**: Results truncated or incomplete
>
> ```yaml theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
> # Fix: Add specific instructions
> agents:
>   researcher:
>     backstory: |
>       Expert researcher. Always verify completeness
>       of search results before finalizing output.
>       Cite sources for all claims.
> ```

> [tab] search\_web
>
> **Issue**: Fallback to DuckDuckGo with limited results
>
> ```yaml theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
> # Fix: Set TAVILY_API_KEY for better results
> metadata:
>   requires:
>     env:
>       - TAVILY_API_KEY
> ```

> [tab] write\_file
>
> **Issue**: Approval required but not configured
>
> ```yaml theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
> # Fix: Add approve field
> approve:
>   - write_file
> ```

## Cycle Results Example

| Cycle | Score | Fixes Applied | Key Issue |
| - | - | - | - |
| 1 | 7.5/10 | 2 | Tool truncation warnings |
| 2 | 6.67/10 | 6 | Hallucination detection |
| 3 | 4.5/10 | 5 | Output format issues |
| 4 | 4.5/10 | 5 | Verification needed |
| 5 | 4.5/10 | - | Stable, needs manual tuning |

> [!NOTE]
>
> Cycle 1 achieved **7.5/10** with improved truncation detection. Subsequent cycles may vary based on LLM responses and tool result sizes.

> [!WARNING]
>
> If scores plateau, manual intervention is needed. Review the backstory and action prompts directly.

## Best Practices

> [card] Start Simple
>
> Use 1 agent for simple tasks. Add agents only when needed.

> [card] Be Specific
>
> Use concrete values in actions, not variables.

> [card] Set Goals
>
> Always include a measurable `goal` field.

> [card] Verify Output
>
> Add verification instructions to agent backstory.

## CLI Reference

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Create recipe
praisonai recipe create "goal" [--no-optimize]

# Run with trace
praisonai recipe run <name> --save --name <trace-id>

# Judge trace
praisonai recipe judge <trace-id> --yaml <file> [--chunked]

# Apply fixes
praisonai recipe apply <plan.yaml> --confirm

# Optimize (automated cycles)
praisonai recipe optimize <path> --iterations 5 --threshold 8.0
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.