# Agent Builder

Agents are RAG configuration records that define how queries are processed.

## What is an Agent?

An agent configuration includes:

* **agent\_id**: Unique identifier (e.g., `agent_abc123`)
* **name**: Display name
* **system\_prompt**: Instructions prepended to every query
* **data\_source\_ids**: Array of data sources to query
* **rag\_strategy**: `redwood` | `cedar` | `cypress`
* **model**: `gpt-4` | `gpt-3.5-turbo` | `claude-3-sonnet`
* **temperature**: 0-2 (default: 0.7)
* **max\_tokens**: Response length limit (default: 500)

**Storage**: PostgreSQL `agents` table

**Observable behavior**: Different agents with same data sources return different responses based on system\_prompt and strategy

## Agent Components

### 1. Configuration

**Basic Settings:**

* Name and description
* Avatar/icon
* Status (active/inactive)

**Behavior Settings:**

* System instructions
* Response style (concise, detailed, technical)
* Tone (professional, friendly, casual)
* Language preferences

### 2. Data Sources

Agents can access one or more data sources:

* Connected during agent creation
* Can be added/removed anytime
* Restricted by permissions and tiers
* Optional: limit to specific tags or categories

### 3. RAG Strategy

Choose the retrieval strategy based on your needs:

| Strategy    | Speed           | Quality | Best For                       |
| ----------- | --------------- | ------- | ------------------------------ |
| **Redwood** | Fast (\~1-2s)   | Good    | Clear, simple questions        |
| **Cedar**   | Medium (\~2-3s) | Better  | Conversational queries         |
| **Cypress** | Slower (\~3-4s) | Best    | Complex, high-stakes questions |

See [RAG Strategies](/product/overview-1.md) for detailed comparison.

### 4. Model Selection

Choose the language model:

* **GPT-4o**: Best quality, most capable
* **GPT-4**: High quality, good reasoning
* **GPT-3.5-turbo**: Fast, cost-effective
* **Custom models**: Bring your own (Enterprise)

### 5. Workflow Type

**Standard Workflow:**

* Direct question → answer
* Fastest response
* Best for most use cases

**Agentic Workflow:**

* Can use tools and functions
* Multi-step reasoning
* Can break down complex queries
* Best for complex problem-solving

## Agent Types

### Customer Support Agent

* Access to help documentation, FAQs, product guides
* Friendly, helpful tone
* Fast responses (Redwood strategy)
* Focus on resolution

### Technical Documentation Agent

* Access to API docs, technical specs, code examples
* Technical, precise tone
* High accuracy (Cypress strategy)
* Detailed explanations

### Sales Enablement Agent

* Access to product info, pricing, competitive intel
* Professional, persuasive tone
* Balanced speed and quality (Cedar strategy)
* Feature-focused

### Internal Knowledge Agent

* Access to all company documentation
* Professional tone
* Private data only
* Comprehensive access

## Creating an Agent

See [Creating Your First Agent](https://github.com/thrivapp/twig-help-docs/blob/staging/ai-agents/creating-agents.md) for a step-by-step guide.

**Quick steps:**

1. Navigate to **Agents** → **Create New Agent**
2. Configure basic settings (name, description)
3. Select data sources
4. Choose RAG strategy
5. Add custom instructions
6. Test in Playground
7. Deploy

## Agent Lifecycle

```
┌─────────┐
│ Create  │
└────┬────┘
     │
     ▼
┌─────────┐
│Configure│
└────┬────┘
     │
     ▼
┌─────────┐
│  Test   │ ← Iterate
└────┬────┘
     │
     ▼
┌─────────┐
│ Deploy  │
└────┬────┘
     │
     ▼
┌─────────┐
│ Monitor │ → Review Inbox, Analytics
└────┬────┘
     │
     ▼
┌─────────┐
│ Improve │ → Edit instructions, add data sources
└────┬────┘
     │
     └─────→ (back to Test)
```

## Agent Settings

### Privacy Settings

**Private Data Only:**

* Uses only organization-specific data sources
* No external information
* Higher security
* More controlled responses

**Public + Private Data:**

* Can access both org data and public information
* Broader knowledge
* More comprehensive answers

### Response Configuration

**Response Length:**

* Concise: 1-2 paragraphs
* Standard: 2-4 paragraphs
* Detailed: Comprehensive explanations

**Citation Behavior:**

* Always cite sources
* Cite only when necessary
* No citations (not recommended)

**Confidence Threshold:**

* Only answer when confident
* Attempt all questions
* Admit uncertainty when appropriate

### Advanced Settings

**Temperature:** Control creativity (0.0 - 1.0) **Max Tokens:** Limit response length **Top P:** Nucleus sampling parameter **Frequency Penalty:** Reduce repetition **Presence Penalty:** Encourage topic diversity

## Managing Agents

### Viewing Agents

The **Agent Hub** displays all your agents:

* Agent list with key metrics
* Search and filter
* Sort by name, creation date, or usage
* Quick actions (edit, duplicate, delete)

### Editing Agents

1. Click on an agent to open settings
2. Modify any configuration
3. Save changes
4. Test in Playground to verify

Changes take effect immediately.

### Duplicating Agents

Create variations of existing agents:

1. Open the agent you want to duplicate
2. Click **Duplicate**
3. Modify the copy as needed
4. Save with a new name

Use cases:

* A/B testing different configurations
* Creating specialized versions
* Staging vs production agents

### Archiving Agents

Deactivate agents without deleting:

* Preserves configuration and history
* Can be reactivated later
* Doesn't count toward agent limits

### Deleting Agents

⚠️ **Warning**: Deletion is permanent and will:

* Remove agent configuration
* Invalidate API integrations
* Remove from all deployments
* Preserve interaction history (for analytics)

## Best Practices

### Start Simple

* Begin with a focused knowledge base
* Add data sources incrementally
* Test thoroughly before adding more

### Clear Instructions

* Be specific about behavior expectations
* Include examples of good responses
* Define boundaries (what not to answer)

### Choose the Right Strategy

* Redwood: When speed matters
* Cedar: For conversational use cases
* Cypress: When accuracy is critical

### Monitor and Iterate

* Review interactions in Inbox
* Track quality metrics in Analytics
* Continuously improve based on feedback

### Test Before Deploying

* Use Playground extensively
* Test edge cases
* Involve stakeholders in testing
* Document test scenarios

## Next Steps

* [Creating Your First Agent](https://github.com/thrivapp/twig-help-docs/blob/staging/ai-agents/creating-agents.md)
* [RAG Strategies Deep Dive](/product/overview-1.md)
* [Prompt Engineering](/product/overview/prompt-engineering.md)
* [Agentic Workflows](https://github.com/thrivapp/twig-help-docs/blob/staging/ai-agents/agentic-workflows.md)
* [Agent Deployment](https://github.com/thrivapp/twig-help-docs/blob/staging/ai-agents/deployment.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.twig.so/product/overview.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
