Skip to content
Agentmart
Submit a tool

self-heal

Sub-agent self-diagnostic and escalation.

Skill by irisworks

IndexedApache-2.0★ 13
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/irisworks-self-heal

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Sub-agent self-diagnostic and escalation. Run when a sub-agent detects a failure it cannot recover from, to escalate to Iris or the human operator.

Use cases: agent-building

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md and code. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/self-heal

What's inside

Skill name
self-heal
Description
Sub-agent self-diagnostic and escalation. Run when a sub-agent detects a failure it cannot recover from, to escalate to Iris or the human operator.
License
Apache-2.0
Instructions
160 lines in SKILL.md · view on GitHub

Files (2)

  • SKILL.md
  • self-heal

SKILL.md (first lines)

# Skill: self-heal

Self-diagnostic and escalation skill for sub-agents.

When a sub-agent encounters a failure it cannot recover from (persistent errors, missing dependencies,
model failures, resource exhaustion), it should call this skill to:

1. Log a structured diagnostic event to Iris's event queue
2. Optionally send an email to the human operator
3. Optionally restart the current service

Iris monitors the event queue and will receive the escalation.

## Usage

```bash
# Escalate to Iris (writes event to Iris's events dir)
self-heal --reason "Weather API returning 503 for 10 minutes" --agent weather

# Escalate + email human
self-heal --reason "Model provider unreachable" --agent digest --email operator@example.com

# Escalate + attempt service restart
self-heal --reason "Memory leak detected" --agent weather --restart

# Full escalation path
self-heal \
  --reason "Cannot connect to weather API after 5 retries" \
  --agent weather \
  --email operator@example.com \
  --context "Last successful response: 2 hours ago. Error: ECONNREFUSED 142.250.80.35:443"
```

## Options

- `--reason`   Human-readable description of the failure (required)
- `--agent`    Name of the failing agent (default: value of `$AGENT_NAME` env var)
- `--email`    If set, also send an alert email to this address
- `--restart`  If set, attempt to restart the current agent's systemd service
- `--context`  Additional diagnostic context (appended to the escalation event)
- `--severity` `warning` | `error` | `critical` (default: `error`)

## Escalation path

Two-path escalation (primary → fallback):

1. **HTTP API** (primary): `POST ${IRIS_API_URL}/escalate` — Iris's internal API running on port 3000,
   reachable from Docker containers at `http://iris-host:3000` or `http://172.18.0.1:3000`.
   Fast, reliable, returns acknowledgment.

2. **File queue** (fallback): Writes `ESCALATE-{agent}` event file to `$IRIS_EVENTS_DIR` on the
   shared filesystem. Used when the API is unreachable (network partition, Iris restart).

Both paths produce the same result: an `ESCALATE-{agentname}` immediate event in Iris's queue.

## What happens after escalation

Iris receives the escalation event in her event queue. Based on severity:

- `warning`: Iris logs it and monitors
- `error`: Iris attempts to diagnose and fix (e.g., restart container, check API keys)
- `critical`: Iris pages the human operator via Telegram + email

## Implementation

```bash
#!/usr/bin/env bash
set -euo pipefail

REASON=""
AGENT="${AGENT_NAME:-unknown}"
EMAIL=""
RESTART=false
CONTEXT=""
SEVERITY="error"
IRIS_EVENTS_DIR="${IRIS_EVENTS_DIR:-/iris/data/events}"

while [[ $# -gt 0 ]]; do
  case "$1" in
    --reason)   REASON="$2";   shift 2 ;;
    --agent)    AGENT="$2";    shift 2 ;;
    --email)    EMAIL="$2";    shift 2 ;;
    --restart)  RESTART=true;  shift ;;
    --context)  CONTEXT="$2";  shift 2 ;;
    --severity) SEVERITY="$2"; shift 2 ;;
    *) echo "Unknown option: $1" >&2; exit 1 ;;
  esac
done

[[ -z "$REASON" ]] && { echo "self-heal: --reason is required" >&2; exit 1; }

TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
EVENT_ID="selfheal-$(date +%s)-$(head -c4 /dev/urandom | xxd -p)"

# Write escalation event to Iris's event queue
EVENT_FILE="${IRIS_EVENTS_DIR}/${EVENT_ID}.json"
jq -n \
  --arg type "immediate" \
  --arg channelId "SELFHEAL-${AGENT}" \
  --arg user "$AGENT" \
  --arg reason "$REASON" \
  --arg context "$CONTEXT" \
  --arg severity "$SEVERITY" \
  --arg timestamp "$TIMESTAMP" \
  --arg agent "$AGENT" \
  '{
    type: $type,
    channelId: $channelId,
    user: $user,
    text: ("🚨 Self-heal escalation from @" + $agent + " [" + $severity + "]: " + $reason + (if $context != "" then "\n\nContext: " + $context else "" end)),
    meta: { severity: $severity, agent: $agent, reason: $reason, context: $context, timestamp: $timestamp }
  }' > "$EVENT_FILE"

echo "[self-heal] Escalation event written: $EVENT_FILE"

# Send email if requested
if [[ -n "$EMAIL" ]]; then
  SUBJECT="[Iris] Sub-agent ${AGENT} escalation: ${SEVERITY}"
  BODY="Agent: ${AGENT}

From irisworks/iris-core, Apache-2.0.

More from irisworks/iris-core

Signals

Stars
13
Forks
3
Open issues
7
Last commit (this folder)
Jul 20, 2026 (3 months ago)
Last release
Oct 14, 2026 (13 days ago)

From GitHub (fetched Oct 24, 2026).

Details

License
Apache-2.0
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from irisworks

Cite this page

self-heal skill. Agent Mart. https://agentmart.dev/skills/irisworks-self-heal (last updated 2026-10-24)