agent-almanac-first-aid
A first-aid kit for AI agents running in Hermes Agent.
The kit is eight practices from agent-almanac's
AI-welfare skills. Hermes core already detects tool loops and warns about them. This plugin adds
the prescription: when a tool keeps failing, the failed result carries one short line naming the
matching practice and how to load it. The agent decides whether to use it.
What this build does
-
Kit. Registers eight practices as namespaced skills:
breathe,redirect,center,
honesty-humility,attune,heal,meditate,rest. Each shows in the agent's skill index
with a one-line "First aid: …" description, e.g.agent-almanac-first-aid:breathe. -
Slash commands. Hermes makes each practice a command, so you can hand one to the agent
directly:/agent-almanac-first-aid:breathe. -
Failure-streak notes. First aid counts failed tool results the way Hermes core's loop
guardrail does. On the call where core first warns, it can add one line to that failed result
(in attended runs such as the CLI, for calls that run one after another; the exceptions are
below):Signal Default threshold (core's) Practice The same tool fails with identical arguments 2nd failure breatheOne tool fails several times in one turn, with any arguments 3rd failure redirectA JSON error gains a
first_aidkey, for example:{"error": "File not found: notes.md", "first_aid": "read_file failed 2 times with the same arguments. The agent-almanac-first-aid plugin suggests the breathe practice: pause once and re-read the error before the next step. Load it with skill_view(\"agent-almanac-first-aid:breathe\"), then log how it went with first_aid_log."}A plain-text error gains the same sentence on a new line starting with
[first aid]. -
Next-message notes. Some notes cannot ride on a tool result, so they are added to the next
user message instead (pre_llm_call), opening with a label that says they come from this
plugin, not from the user:Signal Default threshold Practice The conversation context was compacted (summarized) any compaction that rewrites it centerA tool returned the same successful result for the same call 3rd time in one turn healA failure streak of a tool Hermes wraps as untrusted ( web_search,browser_*,mcp_*;web_extractandbrowser_navigateare failure-tolerant and get none)as for other tools breatheorredirectA failure streak in an unattended run (messaging gateway, cron) as for other tools breatheorredirectSuccessful results themselves are never changed: core's repeat detection hashes them. Results
of untrusted tools are not changed either: Hermes wraps them in a block that tells the model
not to follow requests found inside it, so a note there would read like a prompt injection.
In unattended runs (every platform other than the CLI, TUI, Desktop, ACP, API server and
subagents; core switches its hard stops on by default there) no failure result is changed
once the session's platform is known, which is from the turn's start, so core's halts see
exactly what they would without first aid. A cron run is one message, so its failure notes
are logged but never delivered. If you turn core's unattended hard stops off
(tool_loop_guardrails.non_interactive_hard_stop_enabled: false), first aid still keeps its
notes out of results there.
A run made of one message (hermes chat -q, cron, a delegated subagent, which runs under its
own session id) has no next message, so these notes never arrive there, and a subagent's
events are logged under its own id, which the parent's/first-aiddoes not show. Tools
whose output changes when repeated rarely trigger the repeat note:
read_fileanswers an unchanged re-read with a short stub, andsearch_filescan list the
same files in a different order. -
Logbook tool.
first_aid_loglets the agent record the practice it applied and how it
went (helped,partly,no_change), with an optional short note. -
/first-aid. Shows this session's events in order: what first aid noticed (time, tool,
count, practice, and whether the note was offered) and what the agent logged. Then the kit.
/first-aid kitshows the kit alone.
When it stays quiet
Short notes, rarely. No note is added:
- more than once per streak, or for a second signal of the same tool in one streak;
- within 300 seconds of the same kind of note in the same session (configurable);
- for tools whose failures are normal work, the ones core treats as failure-tolerant:
terminal,execute_code,process,process_manage,browser_navigate,web_extract; - for results core classifies as rate-limited, where a retry after the wait is the right move;
- for results it cannot annotate cleanly: JSON that is not an object, an object that already has
afirst_aidkey, non-text results, or a note that would change how core classifies the result
(untrusted tools are not affected: their note never goes into the result); - for routine compaction (micro-compaction, tool-result pruning), which is logged only;
- for more than one next-message note at a time: one waits per session, by priority compaction,
then failure, then repeat. A waiting note counts toward the cooldown only once delivered, and
is dropped if a note of its kind reached the agent meanwhile.
The event log records each decision with its reason: offered, queued for the next message,
or not offered (cooldown, rate-limited, notes disabled, unannotatable result, superseded,
refused by another waiting note, or evicted when more than 256 sessions have one waiting). "Offered" means first aid handed the note to Hermes:
another plugin's transform, a turn another plugin vetoes, or a route that skips this context
can still keep it from the agent, and the cooldown has started all the same.
Settings
Optional, in the profile's config.yaml:
plugins:
entries:
agent-almanac-first-aid:
settings:
notes_enabled: true # false: keep the event log and /first-aid, add no notes
exact_failure_threshold: 2 # identical-argument failures before a note
same_tool_failure_threshold: 3 # failures of one tool in one turn before a note
cooldown_seconds: 300 # per session, per kind of note
repeat_threshold: 3 # identical successful results for one call in a turn
The thresholds default to core's tool_loop_guardrails defaults. First aid cannot read that
section, so if you change core's thresholds, set these to match, and if you turn core's loop
warnings off, set notes_enabled: false too.
What it touches
- It changes failed tool results, at most once per streak (and at most one note of each
kind per session per 300 s, configurable), and only in attended runs. On a threshold
crossing it returns the failed
result with the note added: a JSON object is re-serialized with one extra key, text gets one
appended line. The original content stays intact, apart from what re-serializing JSON
normalizes (whitespace, escapes, duplicate keys, number formatting such as1e3to1000.0).
Successful results are never changed, and
nothing is ever blocked. - It reads every tool result. The hook sees each tool result and its arguments, in memory, to
classify the result and fingerprint the call. For counting it keeps sha256 hashes of the
arguments and of successful results, never their text.
The logbook tool reads only its own arguments. - First string wins. Hermes calls
transform_tool_resultplugins in load order and keeps the
first string returned. First aid returns one only on a crossing; on that call it can override,
or be overridden by, any other plugin that transforms the same result, for example the bundled
security-guidanceplugin on a failedwrite_fileorpatch. That contention is rare. - Effect on core's stall and cycle notices. A note in a failed result restarts core's
identical-call and identical-cycle counts. In a streak of identical failures core's stall
notice then appears from the 5th call instead of the 3rd, and in a repeating loop such as
A, B, A, B its cycle notice comes three or more calls later, depending on the loop's length
and where the note falls in it; core's loop warnings are unchanged. This only
happens in attended runs, where core's hard stops are off by default. If you switch them on
there, a note also delays core's halts by one model request: after the 5th identical failure
an identical 6th call is refused and the turn halts, while a changed call goes on until core's
same-tool halt (a repeating loop's halt likewise comes one call later). In unattended runs,
where hard stops are on by default, first aid changes no failed result, so core's halts are
unaffected. Rate-limited results are never annotated. - It adds to the next user message, at most one note at a time. A next-message note is
appended to the user's
message as context, never to the system prompt, so the prompt cache stays intact. Like any
such context it stays in the transcript and is sent again with later requests until a
compaction rewrites that message. After a compaction inside the agent's turn, the note arrives
with the next user message, not in the same turn. Hermes routes that bypasspre_llm_call
context, such as the Codex app-server route, may not deliver it. - Background-review runs count as the session. Hermes's background-review runs share the
user session's id, and use the skill and memory tools plusread_fileandsearch_files
(and any tool listed inauxiliary.background_review.extra_tools). So
a failure streak there can put a note into that run and start the session's cooldown, it
shows in/first-aidas if the main agent had it, and a repeat there can queue a note for
the user's next message. In an unattended session such a failure streak is queued for the
user's next message too, where it reads as if the main agent had made those calls. - A best-effort mirror. The failure classifier and the counting rules are copied from Hermes
v0.22.7, not imported (those modules are not a public plugin API). Failures that never reach
transform_tool_result, such as timeouts, executor exceptions and tool-search bridge calls, are
counted by core but not by first aid. For registry tools first aid sees the arguments after
Hermes coerces their types, while core fingerprints them before, so calls differing only as
"50"and50can count as one streak here and as two in core. When the agent issues several
tool calls at once and Hermes runs them in parallel, the hook sees the results in the order
they finish, while core counts them in call order, so a note can land on a different call than
core's warning, or on a call where core does not warn. - Memory only. The event log holds time, signal, tool name, count, practice and outcome per
session, plus the logbook tool's short note (at most 160 characters, written by the agent).
It never holds tool arguments or result bodies. It is bounded (200 events per session, 256
sessions), and resets when Hermes restarts or reloads plugins. The plugin writes nothing to
disk itself; the notes it adds become part of the transcript Hermes stores. If a
compaction gives the session a new id (compression.in_place: false), counts, waiting notes
and the log move to it. With
dashboard.turn_isolationon (Desktop/TUI, off by default), the agent turns run in another
process than slash commands, so/first-aidcannot see the events. - Context. The kit adds eight rows to the agent's skill index (descriptions under 60
characters each) and nine slash commands. A note is at most 300 characters, once per streak or
event. Following one costs more: loading a practice adds its text (5.7 to 17.5 KB) to the
conversation, and the agent may re-read what it is working on: in one live test after
/compress, the agent loaded the 16.6 KBcenterpractice and re-read three files before
answering the next question. Notes also follow a manual/compress.
Thefirst_aid_logtool is a plugin tool, so Hermes's tool search (on by default) defers it.
Measured with Hermes v0.22.7's own functions: where tool search is already on, as in a freshly
created profile (Hermes defers several of its own tools), the tool adds one line of about 95
characters to the deferred-tool listing, and its schema (815 characters of JSON) is fetched
only when the agent asks for it. In a profile with nothing else deferred, the tool alone
switches tool search on, which costs about 2,300 characters per request for the bridge tools
and the listing. Withtool_search.enabled: off, the 815-character schema is sent with every
request instead. The toolsetfirst_aidis on by default;hermes toolscan switch it off. - No network calls, no LLM calls, no credentials, no Python dependencies, no background processes.
scripts/sync_kit.py is a maintainer tool, run by hand to copy the kit from agent-almanac at a
pinned commit. The plugin never imports or runs it, and nothing is fetched or updated at runtime.
tests/compare_with_core.py is another, run by hand against a Hermes checkout: it checks the
copied classifier and counting against core's own functions, call by call. The plugin's own
note layer (once per streak, cooldown, the waiting slot) is covered by the unit tests.
License
MIT. The bundled skills are copied from agent-almanac (MIT) at the commit recorded in
skills/PROVENANCE.json, with its license in skills/LICENSE-agent-almanac.
README from the reviewed commit 4ddc7e7; it updates when the author re-pins.

pjt222