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

# YAML Agent

> YAML data processing tools for AI agents.

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent
from praisonaiagents import read_yaml, write_yaml, validate_yaml

agent = Agent(
    name="YAMLAgent",
    tools=[read_yaml, write_yaml, validate_yaml],
)
agent.start("Validate and merge these two YAML configs")
```

The user describes a YAML change; the agent reads, validates, and updates structured config files.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    U[Input] --> A[Agent]
    A --> T[Tool]
    T --> O[Output]

    classDef agent fill:#8B0000,color:#fff
    classDef tool fill:#189AB4,color:#fff

    class A agent
    class U,O tool
    class T tool
```

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
sequenceDiagram
    participant User
    participant Agent
    participant Feature as YAML Agent

    User->>Agent: Request
    Agent->>Feature: Process request
    Feature-->>Agent: Result
    Agent-->>User: Response
```

<Note>
  **Prerequisites**

  * Python 3.10 or higher
  * PraisonAI Agents package installed
  * PraisonAI Tools package installed
  * `pyyaml` package installed
  * Basic understanding of YAML format
</Note>

## YAML Tools

Use YAML Tools to process and manipulate YAML files with AI agents.

<Steps>
  <Step title="Install Dependencies">
    First, install the required packages:

    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    pip install praisonaiagents praisonai-tools pyyaml
    ```
  </Step>

  <Step title="Import Components">
    Import the necessary components:

    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    from praisonaiagents import Agent, Task, AgentTeam
    from praisonai_tools import read_yaml, write_yaml, validate_yaml, merge_yaml, convert_yaml
    ```
  </Step>

  <Step title="Create Agent">
    Create a YAML processing agent:

    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    yaml_agent = Agent(
        name="YAMLProcessor",
        role="YAML Processing Specialist",
        goal="Process YAML files efficiently and accurately.",
        backstory="Expert in YAML file manipulation and validation.",
        tools=[read_yaml, write_yaml, validate_yaml, merge_yaml, convert_yaml],
        reflection=False
    )
    ```
  </Step>

  <Step title="Define Task">
    Define the YAML processing task:

    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    yaml_task = Task(
        description="Parse and validate configuration files.",
        expected_output="Validated and processed YAML configurations.",
        agent=yaml_agent,
        name="yaml_processing"
    )
    ```
  </Step>

  <Step title="Run Agent">
    Initialize and run the agent:

    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    agents = AgentTeam(
        agents=[yaml_agent],
        tasks=[yaml_task],
        process="sequential"
    )
    agents.start()
    ```
  </Step>
</Steps>

## Understanding YAML Tools

<Card title="What are YAML Tools?" icon="question">
  YAML Tools provide YAML processing capabilities for AI agents:

  * Reading YAML files
  * Writing YAML data
  * Validating YAML structure
  * Merging YAML files
  * Converting between formats
</Card>

## Key Components

<CardGroup cols={2}>
  <Card title="YAML Agent" icon="user-robot">
    Create specialized YAML agents:

    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    Agent(tools=[read_yaml, write_yaml, validate_yaml, merge_yaml, convert_yaml])
    ```
  </Card>

  <Card title="YAML Task" icon="list-check">
    Define YAML tasks:

    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    Task(description="yaml_operation")
    ```
  </Card>

  <Card title="Process Types" icon="arrows-split-up-and-left">
    Sequential or parallel processing:

    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    process="sequential"
    ```
  </Card>

  <Card title="YAML Options" icon="sliders">
    Customize YAML parameters:

    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    safe_load=True, encoding="utf-8"
    ```
  </Card>
</CardGroup>

## Available Functions

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonai_tools import read_yaml
from praisonai_tools import write_yaml
from praisonai_tools import validate_yaml
from praisonai_tools import merge_yaml
from praisonai_tools import convert_yaml
```

## Examples

### Basic YAML Processing Agent

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent, Task, AgentTeam
from praisonai_tools import read_yaml, write_yaml, validate_yaml, merge_yaml, convert_yaml

# Create YAML agent
yaml_agent = Agent(
    name="YAMLExpert",
    role="YAML Processing Specialist",
    goal="Process YAML files efficiently and accurately.",
    backstory="Expert in YAML file handling and validation.",
    tools=[read_yaml, write_yaml, validate_yaml, merge_yaml, convert_yaml],
    reflection=False
)

# Define YAML task
yaml_task = Task(
    description="Parse and validate configuration files.",
    expected_output="Processed and validated YAML data.",
    agent=yaml_agent,
    name="config_processing"
)

# Run agent
agents = AgentTeam(
    agents=[yaml_agent],
    tasks=[yaml_task],
    process="sequential"
)
agents.start()
```

### Advanced YAML Processing with Multiple Agents

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent, Task, AgentTeam
from praisonai_tools import read_yaml, write_yaml, convert_yaml, validate_yaml, merge_yaml

# Create YAML processing agent
processor_agent = Agent(
    name="Processor",
    role="YAML Processor",
    goal="Process YAML files systematically.",
    tools=[read_yaml, write_yaml, convert_yaml],
    reflection=False
)

# Create validation agent
validator_agent = Agent(
    name="Validator",
    role="Data Validator",
    goal="Validate YAML structure and content.",
    backstory="Expert in data validation and verification.",
    tools=[validate_yaml, merge_yaml],
    reflection=False
)

# Define tasks
processing_task = Task(
    description="Process and transform YAML configurations.",
    agent=processor_agent,
    name="yaml_processing"
)

validation_task = Task(
    description="Validate processed YAML data.",
    agent=validator_agent,
    name="data_validation"
)

# Run agents
agents = AgentTeam(
    agents=[processor_agent, validator_agent],
    tasks=[processing_task, validation_task],
    process="sequential"
)
agents.start()
```

## Best Practices

<AccordionGroup>
  <Accordion title="Agent Configuration">
    Configure agents with clear YAML focus:

    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    from praisonai_tools import read_yaml, write_yaml, validate_yaml, merge_yaml, convert_yaml

    Agent(
        name="YAMLProcessor",
        role="YAML Processing Specialist",
        goal="Process YAML files accurately and safely",
        tools=[read_yaml, write_yaml, validate_yaml, merge_yaml, convert_yaml]
    )
    ```
  </Accordion>

  <Accordion title="Task Definition">
    Define specific YAML operations:

    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    Task(
        description="Parse and validate deployment configurations",
        expected_output="Validated configuration set"
    )
    ```
  </Accordion>
</AccordionGroup>

## Common Patterns

### YAML Processing Pipeline

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent, Task, AgentTeam
from praisonai_tools import read_yaml, write_yaml, convert_yaml, validate_yaml, merge_yaml

# Processing agent
processor = Agent(
    name="Processor",
    role="YAML Processor",
    tools=[read_yaml, write_yaml, convert_yaml]
)

# Validation agent
validator = Agent(
    name="Validator",
    role="Data Validator",
    tools=[validate_yaml, merge_yaml]
)

# Define tasks
process_task = Task(
    description="Process YAML files",
    agent=processor
)

validate_task = Task(
    description="Validate processed data",
    agent=validator
)

# Run workflow
agents = AgentTeam(
    agents=[processor, validator],
    tasks=[process_task, validate_task]
)
```

## Related

<CardGroup cols={2}>
  <Card title="Custom Tools" icon="wrench" href="/docs/tools/custom">
    Build your own agent tools
  </Card>

  <Card title="Tools Overview" icon="toolbox" href="/docs/tools/tools">
    Browse PraisonAI tool documentation
  </Card>
</CardGroup>
