Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add agents/the-teacher/active_harness/agent_hooksgit clone --depth 1 https://github.com/the-teacher/active_harnessWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/agents/the-teacher/active_harness/agent_hooks)<a href="https://agentmods.dev/agents/the-teacher/active_harness/agent_hooks"><img src="https://agentmods.dev/badge/agents/the-teacher/active_harness/agent_hooks.svg" alt="Measured on agentmods" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00000 | $0.00833 |
| Opus 5 | $0.00000 | $0.00417 |
| Sonnet 5 | $0.00000 | $0.00167 |
| Haiku 4.5 | $0.00000 | $0.00083 |
Grade A, and why
agent_hooks scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 65 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Agent Hooks
All hooks are registered with on, before, after, or callback at the class or instance level.
class MyAgent < ActiveHarness::Agent
on :setup do ... end
before :call do ... end
after :call do |result| ... end
callback :retry do |entry, error| ... end
end
Hooks are only registered at the class level. There is no instance-level hook API — agent.on(...) does not exist on an Agent instance and raises NoMethodError. Multiple class-level registrations for the same event accumulate (they don't override each other); all fire in the order they were registered, including hooks contributed by included modules.
Events
| Event | Alias | Block arguments | When it fires |
|---|---|---|---|
:setup |
callback :setup |
— | Before anything else. Runs once per call. Use to normalize @input. |
:before_call |
before :call |
— | After setup, before the first HTTP request is made. Use to modify @input or @context. |
:after_call |
after :call |
result |
After a successful response. result is a Result object. |
:retry |
callback :retry |
entry, error |
After each failed model attempt before trying the next fallback. entry is the model hash {provider:, model:, ...}, error is the exception. |
:failure |
callback :failure |
attempts |
After all models in the chain have failed. attempts is an array of flat hashes {provider:, model:, error:, error_code:, execution_time:} (one per attempt). |
:before_system_prompt |
before :system_prompt |
— | Before the prompt class call is invoked. Use to mutate @context before the prompt reads it. |
:after_system_prompt |
after :system_prompt |
prompt |
After the prompt string is built. Return value is ignored — use before_system_prompt to mutate context, or a prompt class for full control. |
:before_parse |
before :parse |
raw |
Before the raw LLM string is parsed (e.g. JSON). Transform hook — the block's return value replaces raw. |
:after_parse |
after :parse |
parsed |
After successful parsing. Transform hook — the block's return value replaces parsed. |
:parse_error |
callback :parse_error |
raw, error |
When parsing fails. The block's return value is used as the fallback parsed value. |
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 3d ago First seen · 65 lines · 0 tokens per session scan A ee4a0f8fa74e
agent_hooks is an agent published in the GitHub repository the-teacher/active_harness (89 stars, last pushed 24d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 833 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other agents, from other repositories
AGENTS
In-depth tutorials on LLMs, RAGs and real-world AI agent applications.
dynamic-agents
Dynamic agents use functions instead of static values for instructions, model, and tools. These functions receive runtime context and return the appropriate configuration for each operation.
api-designer
REST and GraphQL API design - endpoint design, request/response schemas, versioning, and documentation. Use for designing new APIs or evolving existing ones.
accessibility-specialist
Accessibility expert: WCAG 2.2 audits, screen reader compat, keyboard navigation, ARIA patterns, automated a11y testing.
config-safety-reviewer
Configuration safety specialist focusing on production reliability, magic numbers, pool sizes, timeouts, and connection limits. Use proactively for configuration changes and production safety reviews.
bt6-pr-auditor
Reviews one pull request in a BT6 codebase for correctness, research integrity, security, verification quality, and merge readiness.