# Recovery

[Documentation index](../README.md)

Most problems can be resolved from the Pi session that owns the affected work.
The status widget and error message help you decide whether to wait, answer a
question, repair configuration or recover an existing assignment.

## Find the right recovery path

| What you see                                | Where to start                                                                                                                   |
| ------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| Pi works but cannot delegate                | [Configuration and profile errors](#configuration-and-profile-errors)                                                            |
| Agent asks a question                       | [Blocked](#agent-is-blocked)                                                                                                     |
| Agent finished but remains visible          | [Settling](#agent-is-settling)                                                                                                   |
| Agent seems stuck                           | [Health attention](#health-attention)                                                                                            |
| Agent cannot be identified or disappeared   | [Unknown](#agent-is-unknown) or [lost](#agent-is-lost)                                                                           |
| Provider or model error                     | [Model execution failed](#model-execution-failed)                                                                                |
| Agent fails to start                        | [Startup failure](#startup-failure)                                                                                              |
| Lead stopped or Manager disappeared         | [Resume assigned work](project-orchestration.md#pause-and-resume) or [recover a Manager](chief-supervision.md#recover-a-manager) |
| Running Coordinator missing after an update | [Refresh Coordinator discovery](#coordinator-is-missing)                                                                         |
| Clicking a staff entry fails                | [Refresh Coordinator discovery](#coordinator-is-missing)                                                                         |
| Staff target rejected after a fork          | Ask your Manager or Chief to rediscover staff in the new session.                                                                |

## Configuration and profile errors

Open `/herdsman-definitions` and inspect the affected definition and its
source layers. Repair the reported configuration problem, then reapply the
appropriate profile:

| Profile                    | Command             |
| -------------------------- | ------------------- |
| Flexible Lead              | `/lead-flexible`    |
| Orchestration-focused Lead | `/lead-orchestrate` |
| Active Manager             | `/manager-refresh`  |
| Active Chief               | `/chief-refresh`    |

An ordinary Flexible Lead may still work directly in Pi when delegation is
unavailable. If its optional profile could not load, only the saved native
Pi tool selection is available; intended profile exclusions may not apply.
A failed explicit refresh retains the previous valid policy. Assigned and
supervisory sessions have stricter recovery boundaries.

See [Coordinator definitions](../reference/agent-definition-schema.md#coordinator-definitions)
for exact resolution behavior.

## Coordinator is missing

An eligible Lead or Manager can appear in its supervisor's overview before
its first prompt. If an expected Coordinator is missing:

1. Check that the session is still running and has initialized successfully.
2. After a Herdsman update, finish or safely pause affected work, then reload
   or restart sessions that still use an older build.
3. Reopen the Manager or Chief overview to check the current staff.

If clicking a staff entry fails, the session may have changed since the
widget was rendered. Reopen the overview and select the current entry. See
[Status widget navigation](../reference/status-widget.md#navigation).

You do not need to enable peer communication for Manager or Chief supervision.
A missing live Lead does not mean its project assignment is gone. Check the
existing assignment before starting replacement work.

## Health attention

Herdsman notifies the owning session when work needs attention. You can ask
your Lead to explain the notification and check the evidence.

| Situation                            | What you can ask for                                                            |
| ------------------------------------ | ------------------------------------------------------------------------------- |
| Long-running work is making progress | Let it finish.                                                                  |
| The direction needs to change        | Ask the Lead to steer the Agent.                                                |
| The current operation needs to stop  | Ask the Lead to interrupt it and continue the assignment with new instructions. |
| You want to abandon the assignment   | Ask the Lead to stop the Agent.                                                 |

A stale notification is not proof of a hang. Repeated notifications may
reflect the same unresolved condition, not a new failure. Steering may
remain queued until the running operation reaches a safe boundary.

For example, "Check why the validator is taking so long. If it is still
running the expected build, leave it alone."

See [Health attention](../reference/agent.md#health-attention) for timing,
diagnostic evidence and available controls.

## Agent is `blocked`

An Agent may be waiting for an answer, its own Agents, or an external
condition. If you see a question in the owning conversation, answer it
there. The same assignment can then continue.

If there is no question, ask the owner to explain what the Agent is waiting
for. Starting another assignment is not a way to unblock it.

## Agent is `settling`

The Agent's result or cleanup is still being processed. Normally you can
continue other work while Herdsman finishes automatically.

If an error persists:

- A result artifact may no longer be accessible. Restoring access to the
  same artifact allows delivery to retry.
- A `result_error` means the result could not be durably saved. Follow the
  reported recovery action before starting replacement work.

See [Settling](../reference/agent-states.md#settling) for the exact state
and persistence behavior.

## Model execution failed

A provider or model error is not successful completion, even if some
response text is visible. Cancellation is a separate outcome.

1. Open the affected conversation or its owner's failure report.
2. Check whether edits, commands or external actions already took effect.
3. Repair the underlying problem, such as authentication or model access.
4. Ask the owner to continue existing work where recovery is available.

For assigned Leads, use the Manager to continue live work or resume the
paused assignment. Herdsman does not automatically replay tools or restart
failed work. See [Assignment reports](../reference/staff.md#assignment-reports)
and [Agent results](../reference/agent.md#result-delivery-and-errors).

## Agent is `unknown`

Herdsman cannot establish the Agent's exact identity or current control state.
This can happen after an interrupted launch, process changes or incomplete
session evidence.

The Agent is protected from control operations until its identity can be
verified. A quiet terminal or missing pane is not enough to establish that
execution has ended.

Ask the owning session to refresh its observations and explain the reported
error. Avoid manually removing panes or deleting state to bypass the check.

### Continuing assigned work with an unresolved Agent

You can still ask your Lead to continue unrelated work if it can establish
that the unresolved Agent cannot conflict with it. For example, an unknown
implementation Agent should not be replaced by another writer in the same
scope, but independent documentation work may still be safe.

See [Unknown state](../reference/agent-states.md#unknown) for the exact
ownership and control boundaries.

## Agent is `lost`

Herdsman has verified that the expected execution is gone, but the
assignment is still unresolved.

Ask the direct owner to close the lost generation safely. Once the stop is
verified, the owner may continue the saved Pi session if eligible or start
new work as appropriate. A lost Agent is not a completed assignment, and
Herdsman never automatically restarts it.

See [Lost and unknown states](../reference/agent-states.md#unknown) and
[Session continuation](../reference/agent.md#resume_agent).

## Inactivity advisory

A working Agent may be marked stale after ten minutes without a qualifying
progress event. Long tool operations can legitimately take longer.
See [Health attention](#health-attention) for the recovery options.

## Startup failure

Check the error message and any reported launch stage or terminal evidence.
If it mentions extension loading, inspect the effective Pi package and
extension configuration. If it mentions Herdr readiness, check shell startup.

A timeout does not establish that Pi has exited. Herdsman only removes
startup resources it can identify safely.

## `pane_not_ready`

Herdr panes need to reach a shell prompt without interactive setup questions.
For example, an automatic shell-update prompt can prevent an Agent from
starting.

With Oh My Zsh, add this before sourcing Oh My Zsh:

```zsh
[[ ${HERDR_ENV:-} == 1 ]] && zstyle ':omz:update' mode disabled
```

This disables automatic update checks inside Herdr only. You can still run
`omz update` manually.

If startup still fails, inspect the reported `pane_readiness` stage and
terminal diagnostic. Fix the underlying startup problem rather than adding
delays or automatically answering prompts.

## Cleanup or rollback failure

The error may report both the original failure and a cleanup problem.
Keep both when reporting the issue. The `nextAction` field may identify
what needs to be resolved before another attempt.

See [Rollback](../reference/errors.md#rollback) for details.

## Agent stop failure

Ask the owning session to explain the failed stop. Herdsman may preserve
an Agent or its parent when it cannot safely close all affected execution.

For emergency human cleanup in a Lead session, use `/herdsman-stop`.

> [!WARNING]
> This can discard active work or pending results. A successful stop does
> not guarantee that the saved conversation can be continued.

See [Stop Agent](../reference/agent.md#stop_agent) and
[Session continuation](../reference/agent.md#resume_agent).

## Historical session failure

Ask the original owner to continue a saved Agent session. When a completed
result offers a reusable continuation reference, you can refer to that
result in your request.

The saved session must still be eligible: its definition, ownership and
current assignment authority are checked. A conflicting active generation
must finish or be safely stopped first. Recovery preserves the saved
conversation, but does not replay unfinished work.

See [resume_agent](../reference/agent.md#resume_agent) for supported
selectors and eligibility.

## Native Pi restoration of a managed Agent

Opening a managed Agent's saved conversation using Pi alone does not
restore Herdsman's managed execution environment. In a Herdr-hosted Lead
session, Herdsman quarantines such a restored transcript.

Return to the original Lead to recover the work. History and working-tree
changes remain available. If you want to disable Herdr's automatic Agent
restoration globally, set `resume_agents_on_restore = false` in Herdr.

See [Native Pi restoration](../reference/agent.md#native-pi-restoration)
for scope and limitations.

## Before retrying

When asking your Lead for help or reporting a reproducible problem, include
the error category, operation, affected Agent or session, startup stage,
primary and cleanup causes, and any reported `nextAction`. Remove
credentials and other private details before sharing logs.

## See also

- [Status widget](../reference/status-widget.md)
- [Agent states](../reference/agent-states.md)
- [Errors](../reference/errors.md)
