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

# Plans and subagents

> How Agent mode organizes work: the plan as a reviewed contract, background subagents queued in PostgreSQL, structured briefs, dependencies, the shared notebook, result hand-back, and the built-in and custom agent definitions

In Agent mode the main agent behaves like a lead: it agrees a plan with the user, keeps the plan's status current, and hands self-contained pieces of work to **subagents** that run in the background in parallel. This page explains both mechanisms. The console view of the same thing is the [side panel](https://docs.oasm.io/ai-studio/side-panel.md).

```mermaid theme={null}
flowchart TD
    U([User]) -->|approves| Plan["Plan<br/>goal + steps"]
    Main["Main agent"] -->|formulate_plan| Plan
    Main -->|"transition_step"| Plan
    Main -->|"dispatch_subagent<br/>brief, targets, after"| Q[("agent_subagents<br/>queue in PostgreSQL")]
    Q -->|"claim, SKIP LOCKED"| R1["Subagent run"]
    Q -->|"claim when 'after' done"| R2["Dependent subagent"]
    R1 -->|"add_workflow_note"| NB[("Shared notebook")]
    R1 -->|"submit_result"| Q
    NB --> R2
    R1 -.->|"result at next step"| Main
    R2 -.->|"result at next step"| Main
```

## Plans

A plan is a **goal** and an ordered list of **steps**, stored with the conversation. The model manages it with four tools:

| Tool | Effect |
| - | - |
| `formulate_plan` | Proposes a new plan. In Agent mode the user reviews it, with the option to send feedback, before anything runs. The goal is generated from the request and pinned above the steps; the model passes one only to correct it. |
| `transition_step` | Marks a step `in_progress` before working on it, and `completed` after. |
| `append_step` | Adds a step to the **running, approved** plan when the work uncovers a genuinely new requirement. It cannot create a plan. |
| `scrap_plan` | Drops the plan and its goal. Any new direction becomes a new plan, which the user reviews again. |

The plan is what the [plan gate](https://docs.oasm.io/architecture/ai-agent/safety.md#the-plan-gate) checks: in Agent mode a gated tool is refused unless an approved plan has a step in progress. Approving the plan also sets how it runs — asking before each call, or automatically.

The plan also drives the run itself. While steps remain, a run that reaches its step limit **continues** in a new iteration instead of stopping mid-task, and the plan with its statuses is part of every iteration's system context. See [Run lifecycle](https://docs.oasm.io/architecture/ai-agent/run-lifecycle.md#the-step-loop).

## Subagents

A subagent is a separate run of an **agent definition** — with its own prompt, tools, skills and step budget — on one task, in the background. The main agent keeps working, or waits, while subagents run.

### The queue

Subagents are rows in an `agent_subagents` table, which is the queue: there is no separate broker.

* **Dispatch** inserts a `pending` row and returns its id at once. A conversation may have at most ten subagents pending or running.
* **Runners** inside each core API process claim pending rows with `FOR UPDATE SKIP LOCKED`, up to four at a time per process, so several API replicas share the work without double-running a subagent.
* **Heartbeats** every 30 seconds mark a run as alive. A row without a heartbeat for two minutes was interrupted — for example by an API restart — and is requeued, at most twice, then marked failed. A run has a hard limit of 20 minutes.
* **Cancellation** is seen at the next heartbeat. Stopping the conversation cancels all its pending and running subagents.

### Briefs

The main agent does not hand over a free-form prompt. `dispatch_subagent` takes a **structured brief** — objective, expected output, context, what the subagent must do and must not do — plus optional `targets`, a step budget (at most 200) and the plan step the work serves. Targets go through the [scope gate](https://docs.oasm.io/architecture/ai-agent/safety.md#the-scope-gate) at dispatch. The brief is rendered into the subagent's task, wrapped as data; see [Resisting prompt injection](https://docs.oasm.io/architecture/ai-agent/safety.md#resisting-prompt-injection).

### Dependencies

A dispatch can name up to ten earlier subagents of the same conversation it must wait for (`after`). A pending row is claimed only when none of its dependencies is still pending or running; a failed or cancelled dependency still releases it, with that status, so a chain never deadlocks. Because dependencies can only point at rows that already exist in the same conversation, checked under a conversation lock, a cycle cannot form.

When a dependent subagent starts, its task is preceded by the results of the subagents it waited for.

### The shared notebook

Every agent in the conversation — the main agent and each subagent — can append to a shared, append-only **notebook** with `add_workflow_note`: facts, decisions and issues, each signed with its author. The newest entries are given to every subagent when it starts, within a size cap. The notebook lets parallel subagents share what they learn without routing everything through the main agent's context. Subagents also share the conversation's [short-term memory](https://docs.oasm.io/architecture/ai-agent/context-and-memory.md#short-term-memory).

### Results

A subagent ends by calling `submit_result` with its answer, facts and open questions; facts and questions are also written to the notebook. Results are capped at 20,000 characters.

The main agent never polls. A result that finishes while the main run is going is handed to the model **before its next step**; one that finishes after the run ended is delivered with the user's next message. When there is nothing left to do but wait, `wait_for_subagents` blocks until at least one finishes, for at most two minutes per call; one user turn waits at most eight minutes and resumes with results at most five times. `continue_subagent` sends a follow-up to a finished subagent, which runs again with its earlier task and answer in context.

Each subagent run keeps a transcript of its steps, capped in size, which the console shows in the side panel, and the conversation's **workflow snapshot** API returns the plan, subagents, their dependencies and the notebook as one graph.

### What a subagent may do

* It runs **unattended**: a call the guard escalates to a prompt is refused rather than waiting. See [Unattended runs](https://docs.oasm.io/architecture/ai-agent/safety.md#unattended-runs).
* A **built-in** definition runs the tools it declares, automatically. A **custom** definition does too in an Auto conversation, and gets read-only tools only in a Manual one.
* It never gets subagent tools — subagents cannot dispatch subagents — or long-term memory.
* It can load only the skills its definition declares.

## Agent definitions

An **agent definition** is a Markdown prompt with frontmatter: name, description, mode (`primary`, `subagent` or both), the tools it may use, the skills it may load, and optionally a step budget and model. The main agent sees the list of subagent definitions and their descriptions, and picks one per task.

### Built-in agents

| Agent | Role | Step budget |
| - | - | - |
| `recon` | Maps one target's attack surface end to end: subdomains, DNS, hosts, ports, services, technologies, TLS, endpoints | 80 |
| `webapp-tester` | Tests one web application or API: authentication, access control, injection, SSRF, business logic | 90 |
| `network-tester` | Assesses exposed non-web services: TLS, SSH, mail, databases, caches, file shares, remote access | 60 |
| `exploit-verifier` | Confirms or rules out **one** candidate finding with the minimum safe proof | 40 |
| `retester` | Re-checks one registered finding against its original evidence | 40 |
| `researcher` | Researches vulnerabilities and issues: CVE details, affected assets, exploit availability | 50 |
| `asset-analyst` | Reports an exposure analysis of a scope from workspace data | default |
| `reporter` | Writes a penetration-test report from existing findings and evidence | default |
| `pentest` | An end-to-end penetration test of one objective with its own plan; runs as main agent or subagent | 150 |
| `planner`, `goals`, `worker` | Building blocks for long-running autonomous testing: break an objective into subgoals, plan, execute one intent | 30 / default / 60 |
| `auto`, `mainagent` | Main-agent definitions: a platform assistant, and a human-facing lead that turns the user's intent into work for others | default |

Built-in definitions declare only the tools and skills their role needs; a test checks that every tool and skill they name exists.

### Custom agents

Members can add their own definitions, private or shared with the workspace. Built-in names are reserved, and a personal agent may not shadow a workspace agent or the other way round, so `@name` always resolves to exactly one agent. A subagent's model is resolved in order: the definition's own model, the member's subagent model setting, the conversation's model, then the member's default. See [Agents](https://docs.oasm.io/ai-studio/settings/agents.md).

## Related

> [card] [Guard and approvals](https://docs.oasm.io/architecture/ai-agent/safety.md)
>
> The plan gate and unattended runs

> [card] [Side panel](https://docs.oasm.io/ai-studio/side-panel.md)
>
> The plan, subagents and workflow from the user's side

> [card] [Agents](https://docs.oasm.io/ai-studio/settings/agents.md)
>
> Built-in and custom agent definitions


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.