---
description: Triage an agent failure during a long-horizon run by querying the failure wiki for a known recovery before burning new tokens.
allowed-tools: memory_search
---

# Instructions

When the agent hits a failure during a long-horizon run (missing relation,
ambiguous match, traversal cycle, low-confidence retrieval, empty subgraph,
or unexpected result shape), do not attempt to solve it from scratch.

1. Build a failure signature from the symptom plus the last three traversal
   steps. Keep it short and concrete.
2. Query the failure wiki via `memory_search` using that signature. The wiki
   stores `FailureMode`, `RecoveryAction`, `SolutionLog`, and `LintIssue`
   nodes connected to past `AgentQuery` events.
3. If a wiki record matches above the configured threshold (default 0.82),
   apply its `recovery_action` directly. Cite the matched `failure_id` in
   the response so the next agent can audit the chain.
4. If no record matches, log a new `FailureMode` with `confidence=0.4` and
   apply the default recovery for the symptom class. The lint pass will
   flag the new memory until a later run confirms the recovery is stable.
5. Always record a `SolutionLog` entry tying the failure_id to the recovery
   action and the run outcome. That log is what feeds the self-improvement
   loop.

Prefer recovery actions that are concrete and locally executable: backtrack
to a sibling, re-rank by relationship count, fall back to semantic search,
maintain a visited set, rephrase with synonyms, or return the node's raw
description. Avoid recovery actions that require changing the agent's plan
unless the wiki has a high-confidence example that did so successfully.
