# Agentic Workflows

Multi-step reasoning where agents use tools to complete tasks.

## Agentic vs Non-Agentic

**Non-agentic** (standard RAG):

* Retrieve documents → generate response
* Single LLM call
* No external actions

**Agentic** (with tools):

* Retrieve documents → decide if tool needed → call tool → synthesize result
* Multiple LLM calls (planning, execution, synthesis)
* Can execute actions (API calls, calculations, code)

**Requires**: Cypress RAG strategy

## Tool Types

**Built-in tools**:

* `search_knowledge_base(query)`: Recursive retrieval
* `calculate(expression)`: Math evaluation (Python eval)

**Custom tools** (Enterprise):

* `api_call(endpoint, method, params)`: HTTP requests to your APIs
* `run_code(script)`: Server-side JavaScript execution (sandboxed)

**Configure**: Agents → \[Agent] → Configuration → Tools tab

## Example Use Case

**Problem**: "When is my next payment date?"

**Non-agentic response**: "Payment dates are on the 1st and 15th of each month."

<figure><img src="/files/sOutKWWixTMTor9Dl54S" alt=""><figcaption></figcaption></figure>

**Agentic response**:

1. Agent retrieves payment schedule from docs
2. Calls `calculate` tool with current date
3. Determines next date: "January 15, 2024"
4. Responds: "Your next payment date is January 15, 2024."

<figure><img src="/files/5I9fWmhlJItL1DAVf6ub" alt=""><figcaption></figcaption></figure>

**Observable behavior**: Response shows "Tools used: calculate" in debug panel

## Enable Agentic Workflows

**Location**: Agents → \[Agent] → Configuration → Advanced Settings

1. Toggle **Agentic Workflow** → On
2. Select tools from list (checkboxes)
3. Configure tool parameters (if needed)
4. Click **Save**

<figure><img src="/files/qGQnPLfK7hCQxYoHnX3R" alt=""><figcaption></figcaption></figure>

**Requirements**:

* RAG strategy must be Cypress
* Enterprise plan (custom tools)
* API endpoints must be accessible from Twig servers

**Latency impact**: +1-3s per tool call (depends on tool execution time)

## Tool Configuration

**Custom API tool example**:

```json
{
  "name": "get_customer_balance",
  "description": "Get customer account balance",
  "endpoint": "https://api.company.com/customers/{customer_id}/balance",
  "method": "GET",
  "auth": {
    "type": "bearer",
    "token": "{{API_TOKEN}}"
  },
  "parameters": {
    "customer_id": {
      "type": "string",
      "description": "Customer ID from conversation context"
    }
  }
}
```

**Observable behavior**: Agent detects need, calls API, incorporates result in response

## When to Use Agentic Workflows

**Use when**:

* Need real-time data (balances, statuses, dates)
* Require calculations or logic
* Must execute actions (create ticket, send email)
* Multi-step reasoning needed

**Don't use when**:

* Simple document retrieval sufficient
* Speed is critical (adds latency)
* No dynamic data needed
* Budget constrained (costs more)

## Constraints

* Cypress strategy only (Redwood/Cedar don't support tools)
* Max 5 tool calls per query
* Tool timeout: 30 seconds
* No database writes (read-only APIs recommended)
* Sandboxed execution (limited Node.js APIs for custom code)

**Rate limits**: Same as standard queries (100 req/min Execute scope)


---

# 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/advanced/agentic-workflows.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.
