Self-healing skills

Skills are markdown the agent can author, improve, and repair on its own — a direct port of the Hermes Agent skill system, including the Curator that ages unused skills out and the self-heal loop that fixes a skill whose API has drifted.

A Skill is a markdown document (frontmatter + body) the agent reads and follows. Because it's just text, an agent can do more than *use* a skill — it can write one, improve one, and repair one when it breaks. This is OpenBook's port of the Hermes Agent skill system.

The skill_manage tools

Every agent (subject to an admin kill-switch) can call a set of skill_* tools to manage the skill library at runtime:

ToolDoes
skill_createDraft a new template- or composed-kind skill from markdown. Enters the review queue as pending.
skill_editReplace a skill's whole body. Re-enters review.
skill_patchToken-cheap targeted edit: a unique findreplace. The preferred way to fix one stale line.
skill_deleteSoft- or hard-delete a skill (unregisters it).
skill_loadProgressive disclosure: fetch a skill's full schema + body excerpt + asset list before invoking it.
skill_read_assetRead one companion file attached to a skill.
skill_list_docs / skill_searchDiscover what skills exist (FTS over bodies).
Agent-authored writes are not live immediately. Handler-kind (code) skills are admin-only, and every agent write lands as review_status: pending until an admin approves it — the write-approval gate. Turn all of it off with the skill_creation_enabled setting.

Self-heal: when a skill's API drifts

External APIs move. An endpoint 404s, an auth header changes, a response shape shifts. Instead of dead-ending, an agent granted the self-heal tools is told to fix the skill:

  1. A skill invocation fails. The Curator records the failure on the skill (error_count, last_error, e.g. "X API error 404: endpoint moved").
  2. The agent calls skill_load("<skill>") to read the current markdown, and (if unsure) web-searches the provider's live docs.
  3. It calls skill_patch("<skill>", find, replace) to fix exactly the stale endpoint/param — a targeted edit, not a rewrite.
  4. The patch bumps patch_count (the "actively maintained" signal) and re-enters admin review before going live.
Grant self-heal by adding skill_load, skill_search, skill_patch, and skill_edit to an agent. The built-in AI team's API-calling agents (Trendy, Alice, Scribe, Sentinel, Clipper) ship with them.

The Curator

The Curator keeps the library healthy without a human. Every skill tracks how often it is viewed, used, and patched, and when it last ran or failed:

CounterBumped when
use_count + last_used_atA successful invocation (also revives a stale skill to active).
error_count + last_errorA failed invocation — the self-heal signal.
view_countAn agent reads the skill via skill_load.
patch_countAn agent edits/patches the skill.

A periodic sweep (every 7 days, only after ≥2h of system idle) ages agent-created skills through a lifecycle — it never touches human- or bundled-authored skills:

text
active  ──30 days unused──▶  stale  ──90 days unused──▶  archived
  ▲                                                          │
  └────────────── a successful run revives it ──────────────┘

Archiving pulls the skill from the live tool pool (it's unregistered, enabled=false) but keeps the row, so a skill that becomes useful again is revived the moment it runs. Thresholds are tunable via BB_CURATOR_* env vars.

The Curator is core — wired at boot next to the skill evolver (which drafts brand-new skills from recurring tool-call patterns). Together they let the skill library grow, heal, and prune itself.