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

# Agents Overview

> Learn how to create and manage AI agents in PLai Framework

# Agents Overview

Agents are the core AI entities in PLai Framework. Each agent is a specialized AI assistant that can chat with users, use tools, access datasources, and execute complex workflows.

## What are Agents?

Agents in PLai Framework are intelligent AI assistants that can:

<CardGroup cols={2}>
  <Card title="Chat & Interact" icon="comments">
    Engage in natural language conversations with users
  </Card>

  <Card title="Use Tools" icon="wrench">
    Execute actions through connected tools and APIs
  </Card>

  <Card title="Access Data" icon="database">
    Query datasources and knowledge bases
  </Card>

  <Card title="Process Requests" icon="gear">
    Handle batch operations and complex workflows
  </Card>
</CardGroup>

## Agent Features

### Core Capabilities

Every agent in PLai Framework includes:

* **Natural Language Processing**: Powered by advanced LLMs
* **Tool Integration**: Connect to 6+ different tool types
* **Memory & Context**: Maintain conversation history and context
* **Customizable Personality**: Define behavior through system instructions
* **Multi-Modal Support**: Handle text, images, and other media types

### Advanced Features

<Tabs>
  <Tab title="Analytics">
    * Real-time conversation analytics
    * Performance metrics and insights
    * Custom reporting and filtering
    * Progress tracking for batch operations
  </Tab>

  <Tab title="Answer Filters">
    * Answer filtering and validation
    * Content moderation controls
    * Response customization rules
    * Conditional logic implementation
  </Tab>

  <Tab title="Guardrails">
    * Safety and compliance controls
    * Content filtering mechanisms
    * Rate limiting and usage controls
    * Automated monitoring and alerts
  </Tab>
</Tabs>

## Agent Configuration

### Basic Settings

Each agent has fundamental configuration options:

<AccordionGroup>
  <Accordion title="Identity & Behavior">
    * **Name**: Human-readable agent identifier
    * **Description**: Purpose and capabilities summary
    * **System Instructions (Prompt)**: Core personality and behavior guidelines
    * **Avatar**: Visual representation for chat interfaces
  </Accordion>

  <Accordion title="Model Configuration">
    * **LLM Provider**: OpenAI, Anthropic, Google, Groq, Together AI, OpenRouter, etc.
    * **Model Selection**: GPT-4, Claude, Gemini, Llama, and other models
    * **Temperature**: Response creativity and randomness
    * **Max Tokens**: Response length limitations
    * **RouteLLM**: Smart model routing for cost optimization
    * **Streaming**: Enable real-time response streaming for interactive conversations
    * **Language Detection**: Automatically detect and respond in the user's language from the first question
    * **Structured Output**: Define JSON schemas for consistent, structured responses
  </Accordion>

  <Accordion title="Capabilities">
    * **Tools**: Available actions and integrations
    * **Datasources**: Knowledge bases and data access
    * **File Upload**: Document processing capabilities
    * **Voice Input**: Audio conversation support
  </Accordion>
</AccordionGroup>

### Advanced Model Configuration

#### Response Streaming

Enable real-time response streaming to provide progressive, interactive conversations with your users.

<Tabs>
  <Tab title="Overview">
    **What is Streaming?**

    Streaming allows the agent to send responses progressively as they're generated, rather than waiting for the complete response. This creates a more interactive and responsive user experience.

    **Benefits:**

    * Improved user experience with instant feedback
    * Reduced perceived latency
    * Better for long-form responses
    * Real-time interaction feeling
  </Tab>

  <Tab title="Use Cases">
    **Ideal for:**

    * Interactive chatbots
    * Customer support agents
    * Real-time conversational interfaces
    * Applications where user experience is critical

    **Not recommended for:**

    * API integrations requiring complete responses
    * Batch processing operations
    * Scenarios requiring structured data output
  </Tab>

  <Tab title="Compatibility">
    **Model Support:**

    * ✅ Most modern LLMs support streaming (GPT-4, Claude, Gemini, etc.)
    * ❌ Some older or specialized models may not support it

    <Warning>
      **Important**: Streaming and Structured Output are mutually exclusive. Enabling one will automatically disable the other.
    </Warning>
  </Tab>
</Tabs>

#### Language Detection

Automatically detect and adapt to your user's language based on their first question.

<Tabs>
  <Tab title="Overview">
    **How it Works:**

    When enabled, the agent analyzes the user's first message to detect the language being used. The agent then automatically responds in the same language throughout the conversation.

    **Benefits:**

    * Seamless multi-language support
    * No manual language configuration needed
    * Improved global user experience
    * Automatic language consistency
  </Tab>

  <Tab title="Use Cases">
    **Perfect for:**

    * International applications
    * Multi-region customer support
    * Public-facing chatbots
    * Global e-commerce platforms

    **Example Behavior:**

    * User asks "¿Cómo puedo ayudarte?" → Agent responds in Spanish
    * User asks "How can I help you?" → Agent responds in English
    * User asks "Comment puis-je vous aider?" → Agent responds in French
  </Tab>

  <Tab title="Compatibility">
    **Model Support:**

    * ✅ Works with all models
    * ✅ Independent of other features
    * ✅ Can be combined with Streaming or Structured Output

    <Info>
      **Best Practice**: Enable this feature for public-facing agents that may interact with users from different regions.
    </Info>
  </Tab>
</Tabs>

#### Structured Output

Define JSON schemas to enforce consistent, parseable response formats.

<Tabs>
  <Tab title="Overview">
    **What is Structured Output?**

    Structured Output allows you to define a JSON schema that the agent must follow in its responses. This ensures consistent, predictable, and easily parseable outputs.

    **Benefits:**

    * Guaranteed response format
    * Easy integration with external systems
    * Automatic validation
    * Consistent data extraction
  </Tab>

  <Tab title="Requirements">
    **Prerequisites:**

    * Model must support structured outputs (GPT-4, Gemini Pro, etc.)
    * JSON Schema must be defined
    * Cannot be used with RouteLL
    * Cannot be used with Streaming

    <Warning>
      **Limitations**:

      * Not available with RouteLLM routing
      * Streaming must be disabled
      * Requires compatible model
    </Warning>
  </Tab>

  <Tab title="Use Cases">
    **Ideal for:**

    * Data extraction tasks
    * Form filling automation
    * API integrations
    * Structured data processing
    * Database population

    **Example Scenarios:**

    * Extract contact information from text
    * Parse product details from descriptions
    * Generate structured reports
    * Classify and categorize content
  </Tab>

  <Tab title="Examples">
    **Contact Information Extraction:**

    ```json theme={null}
    {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "Full name of the person"
        },
        "email": {
          "type": "string",
          "format": "email"
        },
        "phone": {
          "type": "string"
        }
      },
      "required": ["name", "email"],
      "additionalProperties": false
    }
    ```

    **Product Analysis:**

    ```json theme={null}
    {
      "type": "object",
      "properties": {
        "product_name": { "type": "string" },
        "sentiment": {
          "type": "string",
          "enum": ["positive", "negative", "neutral"]
        },
        "key_features": {
          "type": "array",
          "items": { "type": "string" }
        },
        "price_range": {
          "type": "object",
          "properties": {
            "min": { "type": "number" },
            "max": { "type": "number" },
            "currency": { "type": "string" }
          }
        }
      },
      "required": ["product_name", "sentiment"]
    }
    ```
  </Tab>
</Tabs>

## Agent Types & Use Cases

### Customer Support Agents

```yaml theme={null}
Purpose: Handle customer inquiries and support tickets
Tools: 
  - Knowledge Base Search
  - Ticket System API
  - Email Integration
Features:
  - Escalation to human agents
  - Sentiment analysis
  - Multi-language support
```

### Data Analysis Agents

```yaml theme={null}
Purpose: Process and analyze data from various sources
Tools:
  - Database Connections
  - Code Interpreter
  - Visualization Tools
Features:
  - Automated reporting
  - Data insights generation
  - Chart and graph creation
```

### Content Creation Agents

```yaml theme={null}
Purpose: Generate and edit content across formats
Tools:
  - Web Search (Perplexity AI)
  - Document Processing
  - Image Generation
Features:
  - Multi-format output
  - Fact-checking
  - Style consistency
```

### Research Agents

```yaml theme={null}
Purpose: Gather and synthesize information from multiple sources
Tools:
  - Web Scraping
  - Academic Databases
  - Document Analysis
Features:
  - Source verification
  - Citation management
  - Summary generation
```

## RouteLLM Integration

RouteLLM automatically routes requests to the most appropriate model based on complexity and cost.

### RouteLLM Benefits

* **Cost Optimization**: Use cheaper models for simple tasks
* **Performance**: Route complex queries to advanced models
* **Automatic**: No manual configuration required
* **Transparent**: Full visibility into routing decisions

## Getting Started

Ready to create your first agent?

<Steps>
  <Step title="Navigate to Agents">
    Go to the Agents section in your project dashboard
  </Step>

  <Step title="Click Create Agent">
    Use the "+" button or "Create Agent" button
  </Step>

  <Step title="Configure Basic Settings">
    Set name, description, and system instructions
  </Step>

  <Step title="Select Model">
    Choose your preferred LLM provider and model
  </Step>

  <Step title="Add Tools (Optional)">
    Connect tools to extend agent capabilities
  </Step>

  <Step title="Test & Deploy">
    Test your agent in chat and activate when ready
  </Step>
</Steps>

## Next Steps

<CardGroup cols={2}>
  <Card title="Create Your First Agent" icon="play" href="/agents/creating-agents">
    Step-by-step agent creation guide
  </Card>

  <Card title="Agent Settings" icon="settings" href="/agents/agent-settings">
    Configure advanced agent features
  </Card>

  <Card title="Analytics" icon="chart-line" href="/agents/analytics/overview">
    Monitor and analyze agent performance
  </Card>

  <Card title="First Agent Tutorial" icon="graduation-cap" href="/guides/first-agent">
    Complete walkthrough with examples
  </Card>
</CardGroup>

## Common Questions

<AccordionGroup>
  <Accordion title="How many agents can I create?">
    The number of agents depends on your subscription plan. Free plans typically allow 3 agents, while premium plans offer unlimited agents.
  </Accordion>

  <Accordion title="Can agents communicate with each other?">
    Currently, agents operate independently. Multi-agent workflows are on our roadmap for future releases.
  </Accordion>

  <Accordion title="What happens to conversation history?">
    Conversation history is stored securely and can be accessed through the analytics dashboard. Data retention policies vary by plan.
  </Accordion>

  <Accordion title="Can I export agent configurations?">
    Yes, agent configurations can be exported as JSON files for backup or migration purposes.
  </Accordion>
</AccordionGroup>
