# Agent definitions

[Documentation index](../README.md) · [Working with Agents](working-with-agents.md)

An Agent definition is a Markdown file that describes a specialist's
responsibility and capabilities, not a mandatory workflow.

**On this page:** [Create](#create-a-standalone-definition) · [Choose an Agent](#bundled-roster) · [Sources](#sources) · [Inspect](#inspect-effective-definitions) · [Compose](#compose-specialist-agents) · [Advanced settings](#permission-aware-extensions)

## Create a standalone definition

Save this as `~/.pi/agent/agents/docs-reviewer.md` when using Pi's default
agent directory:

```markdown
---
name: docs-reviewer
description: Review documentation changes for accuracy, navigation and examples; report findings without editing.
noSkills: true
noExtensions: true
tools: [read, ls, find, grep]
---

Review the documentation changes for correctness and readability.
Report concrete findings without editing files.
```

Ask your Lead:

```text
Use docs-reviewer to review my documentation changes.
```

The frontmatter `name`, not the filename, is the Agent's definition identity.
The selected tools are a model-facing allowlist, not a process or extension
sandbox. Omit shell and mutation-capable tools for an inspection-only Agent.

## Bundled roster

Choose an Agent for the work that remains. The defaults are capabilities,
not required stages.

| Agent         | Use for                                                               |
| ------------- | --------------------------------------------------------------------- |
| `scout`       | Fast read-only codebase reconnaissance.                               |
| `researcher`  | Current or external research and local inspection.                    |
| `implementer` | Approved source changes and focused verification.                     |
| `reviewer`    | Independent internal review of correctness and validation evidence.   |
| `validator`   | Outstanding tests, checks and smoke scenarios, without writing fixes. |
| `ship`        | Authorized Git and GitHub delivery operations.                        |
| `generalist`  | Tightly coupled investigation, implementation and verification.       |

Forward useful completed evidence instead of repeating work unless it is
insufficient, outdated or independent verification is necessary.

### Researcher web access

The bundled researcher includes `web_enable` and the default
`pi-web-access` tools (`web_search`, `fetch_content`, `get_search_content`,
`source_check`). Pi and the extension determine tool availability.

The bundled researcher explicitly requests Pi's native Code Mode
(`builtin:codemode`) and `npm:pi-web-access`. Its `noExtensions: true` disables
ordinary extension discovery. Pi may resolve and install the explicitly requested
npm extension when it is not cached and online startup is permitted. In an
operator-enforced offline environment, web tools may be unavailable. Without
them, the researcher retains local inspection capabilities and reports
unavailable external evidence.

Higher-precedence overlays can replace the bundled `extensions` list. Use the
[existing array modifiers](../reference/agent-definition-schema.md#file-format)
to extend the inherited list deliberately. If `pi-web-access` is configured
with different public tool names, replace the researcher's `tools` array
through a matching project or
global overlay. Search providers may receive external requests, and extension
code runs in the Pi process with that process's permissions; the callable-tool
allowlist is not an operating-system sandbox.

### Ship and validation boundaries

Ship requires an authenticated GitHub CLI (`gh`) for hosting operations.
Commit, push, PR creation, merge, release publication and updates to specified
release fields each require separate explicit authorization. Its instructions
are not a shell sandbox or a grant of credentials. Repository shipping policy
remains local.

Validator runs outstanding verification rather than designing or fixing
changes. Validator, Implementer and Generalist can use Pi's `bash` and
Windows-only `powershell`; shell tools are not read-only sandboxes.
Reviewer findings inform the delegator, not user or supervisor approval.

## Sources

Choose the scope that matches the change:

| Scope                                     | Agent files                            |
| ----------------------------------------- | -------------------------------------- |
| Global defaults                           | `<agentDir>/agents/`                   |
| Trusted project                           | `.pi/agents/`                          |
| Trusted clone, shared by linked worktrees | `<git-common-dir>/pi-herdsman/agents/` |

Matching definitions overlay bundled defaults by precedence
`bundled < global < trusted project < private repository`.
Use a partial overlay for a bundled Agent; don't edit bundled files.
[Sources and precedence](../reference/agent-definition-schema.md#sources-and-precedence)
owns the exact directory, trust and layering rules, including how to find the
Git common directory. For Coordinator profiles, see
[Customizing Coordinators](customizing-coordinators.md).

## Inspect effective definitions

Open `/herdsman-definitions` and select **Agent definitions**. The UI shows
configuration and contributing sources, including disabled definitions. The
model-facing `list_agents` instead exposes the current eligible capability
roster and live Agents, not complete configuration or source paths.

For changes, inspect contributing layers, choose the intended source, make the
smallest edit and validate through normal discovery or `list_agents` when
available. Ask Pi for help or use `/skill:agent-definitions`. The skill uses
the same files and validation, not another management API.

For exact UI behavior see [Commands](../reference/commands.md#herdsman-definitions).
For one-off changes to a fresh assignment's model or thinking when enabled,
see [task-scoped overrides](../reference/agent.md#task-scoped-model-and-thinking).
A resumed Agent uses its saved model and thinking when the definition omits
those fields; see [Execution settings](../reference/agent-definition-schema.md#execution-settings).

## Enable or disable a definition

Set `enabled: false` on a matching overlay or use the Definitions UI:

```markdown
---
name: reviewer
enabled: false
---
```

Disabled definitions remain visible to the editor but are unavailable for fresh
delegation and resumption. A definition requiring unavailable children also
fails eligibility; active assignments are not mutated.
See [Fields](../reference/agent-definition-schema.md#fields).

## Write useful descriptions

Write `description` for the delegator: state what the Agent can do, when to use
it, and a meaningful boundary where another capability fits better. Prefer
concrete tasks over generic role labels. Descriptions guide selection; they do
not grant tools or dictate workflows. Keep them accurate when overrides change
capabilities, and qualify optional integrations.

## Recognize recurring generalist work

If the generalist is repeatedly selected for the same recognizable class of
tasks, review whether the available Agent definitions cover that responsibility.
First check whether an existing specialist is being overlooked because of an
unclear description, selection boundary, or missing capability. Add a focused
Agent definition only when the work has a distinct, recurring responsibility
and specialization would meaningfully improve selection or execution.
Generalist selection frequency alone does not establish that another Agent
is needed.

For a read-only historical assessment, invoke
`/skill:agent-specialization-audit` with the optional
[`pi-session-inspector`](https://www.npmjs.com/package/pi-session-inspector)
extension available in Pi. When auditing a Git repository with an inspector
that supports `cwdPrefixes`, the skill includes its registered worktrees and
historical Herdr worktree paths from saved Pi session headers. Former worktree
membership may be inferred from paths rather than verified. The audit compares
recorded assignments with the current effective roster, reports incomplete
coverage, and does not modify Agent definitions.

## Compose specialist Agents

Different Agents can share procedures while retaining distinct responsibilities,
model choices, tools, and Pi extension behavior. When the same instructions are
always needed, preload them through body `@file` references instead of making
the Agent discover and read a skill. For example, assume the shared file
`.pi/skills/release-conventions/SKILL.md` exists in the project.

`.pi/agents/release-drafter.md`:

```markdown
---
name: release-drafter
description: Draft release notes from supplied change evidence; do not publish
tools: [read, ls, find, grep, write]
noSkills: true
noExtensions: true
---

Use these shared release conventions:

@../skills/release-conventions/SKILL.md

Write a draft from the supplied evidence. Flag unsupported claims.
```

`.pi/agents/release-auditor.md`:

```markdown
---
name: release-auditor
description: Check release notes against supplied inline evidence; do not edit
tools: []
noSkills: true
noExtensions: true
extensions: ["/absolute/path/to/release-audit.ts"]
---

Use these shared release conventions:

@../skills/release-conventions/SKILL.md

Check the notes against evidence provided in the assignment text.
Report unsupported claims and omissions without editing files.
```

Herdsman expands each whole-line `@file` reference into the Agent's system
prompt at launch. This reuses the file's text, not Pi's native skill-discovery
mechanism; `noSkills: true` disables automatic discovery. The content is
included up front, including any skill frontmatter, and nested file references
or scripts are not loaded automatically. For larger or optional procedures,
use native `skills` instead to permit on-demand loading.

The auditor has no ordinary callable tools, so its evidence must be available
in the assignment text. Its optional `release-audit.ts` path illustrates a
user-provided Pi extension that can specialize supported session hooks or
model behavior; omit it if unneeded, or replace it with an existing accessible
extension. `noExtensions: true` disables ordinary discovery, not explicitly
listed `extensions`. Loading extension code is independent of model-callable
`tools`; an empty tool allowlist is not an extension or process sandbox.
See the [agent-definition schema](../reference/agent-definition-schema.md) and
[Body file references](../reference/agent-definition-schema.md#body-file-references) for the exact contracts.

## Allow direct agents

```markdown
---
name: coordinator
tools: [read, bash]
agents: [scout, researcher]
---

Coordinate the assigned analysis and integrate direct Agent results.
```

A managed Agent needs a non-empty `agents` allowlist, valid references and an
eligible tool/depth policy to delegate. Mandatory owner communication remains
available. See [Delegation](../concepts/delegation.md) and
[Managed-Agent coordination tools](../reference/agent-definition-schema.md#managed-agent-coordination-tools).

## Add body files

Use a whole-line file reference in a definition body to include its text at
launch. For example, `@./prompts/docs-policy.md` is relative to the declaring
definition. See [Body file references](../reference/agent-definition-schema.md#body-file-references)
for supported forms and exact expansion.

## Permission-aware extensions

Agent definitions may include a `permission:` mapping for compatible
permission-aware Pi extensions.

[`pi-permission-system`](https://github.com/gotgenes/pi-packages/tree/main/packages/pi-permission-system)
can consume the same global or trusted project-local agent definition as Pi
Herdsman:

```yaml
---
name: reviewer
tools: ["read", "ls", "find", "grep"]
permission:
  "*": deny
  read: allow
  ls: allow
  find: allow
  grep: allow
---
```

Pi Herdsman accepts and preserves `permission:` but does not evaluate its
contents or make authorization decisions from it. Managed agents publish the
conventional `<active_agent name="<definition>"/>` identity signal and
subagent lineage metadata used by compatible extensions. Herdsman separately
projects current semantic identity and direct-owner context in its
`pi_herdsman_agent` prompt section; this is not an authorization signal.
Permission policy is effective only when the
compatible permission extension is loaded in that Pi session. The permission
extension is optional; Pi Herdsman does not install or depend on it.

## Configure an extension-backed model

The effective definition controls extension discovery regardless of how the
model is selected. To use a provider extension without enabling ordinary
discovery, add it explicitly in a partial definition overlay:

```markdown
---
name: scout
model: mistral-native/zai-glm-5-3-flash
extensions: ["+npm:pi-mistral-native"]
---
```

This overlay inherits the bundled scout's `noExtensions: true` and adds the
provider extension without replacing scout's existing extension list.

If the provider extension is already configured for ordinary Pi discovery,
you can instead enable that discovery for scout:

```markdown
---
name: scout
model: mistral-native/zai-glm-5-3-flash
noExtensions: false
---
```

Ordinary discovery can load other configured extensions as well.

## Override an existing bundled role

For model, instructions, tools or skills, see
[Customizing bundled Agents](customizing-agents.md).

## See also

- [Agent-definition schema](../reference/agent-definition-schema.md)
- [Configuration](../reference/configuration.md)
