# Agents

> The specialized agents behind a flow and the safeguards that keep them on track.

A [flow](https://pentagi.com/docs/glossary/#flow) is carried out by a team of [agents](https://pentagi.com/docs/glossary/#agent). Each [agent type](https://pentagi.com/docs/glossary/#agent-type) has its own prompt, model settings and [tools](https://pentagi.com/docs/glossary/#tool), so you can assign stronger or cheaper models per role.

## [Agent types](https://pentagi.com/docs/concepts/agents/#agent-types)

| Agent                   | Role                                                                                                                              |
| ----------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| `primary_agent`         | Main reasoning agent that drives a flow                                                                                           |
| `assistant`             | Interactive [assistant](https://pentagi.com/docs/glossary/#assistant) mode                                                                           |
| `generator`             | Splits each [task](https://pentagi.com/docs/glossary/#task) into [subtasks](https://pentagi.com/docs/glossary/#subtask)                                                 |
| `refiner`               | Refines the plan as results come in                                                                                               |
| `adviser`               | Expert advice; mentor in execution monitoring and planner in task planning                                                        |
| `reflector`             | Corrects agents that stop producing [tool calls](https://pentagi.com/docs/glossary/#tool-call)                                                       |
| `searcher`              | Information gathering and web search                                                                                              |
| `enricher`              | Gathers extra context from [memory](https://pentagi.com/docs/glossary/#memory) and the [sandbox](https://pentagi.com/docs/glossary/#sandbox) before the adviser answers |
| `coder`                 | Writes and analyzes code                                                                                                          |
| `installer`             | Installs and sets up tools in the sandbox                                                                                         |
| `pentester`             | Penetration testing and security assessment                                                                                       |
| `simple`, `simple_json` | Plain and JSON-structured completions                                                                                             |

Two more agents work behind the scenes: the `memorist` answers other agents' questions about past work from long-term memory, and the `reporter` writes up the result of each task.

## [How work is delegated](https://pentagi.com/docs/concepts/agents/#how-work-is-delegated)

```mermaid
sequenceDiagram
  accTitle: How a task is split into subtasks and the primary agent delegates each step to specialist agents through shared memory
  participant G as Generator
  participant O as Primary agent
  participant M as Memorist
  participant S as Specialists
  participant V as Vector store
  G->>O: Subtasks of the task
  O->>M: Past work, when the context lacks it
  M->>V: Search memory
  O->>S: Delegate a step to the searcher, pentester, coder or installer
  S->>V: Store tool results
  S-->>O: Result
```

## [Safeguards](https://pentagi.com/docs/concepts/agents/#safeguards)

* **Tool call limits** (always on) — `MAX_GENERAL_AGENT_TOOL_CALLS` (default 100) caps the model turns in the chains of `primary_agent`, `assistant`, `pentester`, `coder` and `installer`, and `MAX_LIMITED_AGENT_TOOL_CALLS` (default 20) caps them for the other agents. One turn can call several tools. Values from 1 to 5 are raised to 6, and 0 or less means the default.
* **Repeat detection** (always on) — from the third call in a row to the same tool with the same arguments, the tool is not run again: the agent gets the previous answer back with a request to change course. The seventh such call ends the chain.
* **Reflector** (always on) — steps in the first time a model answers without a tool call and guides the agent back to one; after three unsuccessful rounds the chain stops.
* **Execution monitoring** (beta, `EXECUTION_MONITOR_ENABLED`) — for `primary_agent`, `pentester`, `coder`, `installer`, and `assistant` when it works with agents, the adviser acts as a mentor when the agent calls the same tool `EXECUTION_MONITOR_SAME_TOOL_LIMIT` times in a row (default 5) or makes `EXECUTION_MONITOR_TOTAL_TOOL_LIMIT` tool calls since the last advice (default 10). The trigger counts calls rather than detecting a stall; the adviser then reviews the agent's progress and recommends whether to continue, change approach or stop.
* **Intelligent task planning** (beta, `AGENT_PLANNING_STEP_ENABLED`) — the adviser drafts 3–7 concrete steps before specialists start a subtask.

> [!NOTE]
> Execution monitoring and task planning roughly double result quality for models under 32B parameters, at the cost of 2–3× more tokens and time. They are off by default.

In Enterprise, the planner always runs and execution monitoring is on by default with limits of 20 and 40 — see [Agent profiles](https://pentagi.com/docs/enterprise/agent-profiles/#planner-and-execution-monitor).