agent-runtime-hooks

Registers lifecycle hooks to observe and intercept agent execution steps.

Updated Jan 27, 2026
One-click install
npx skills add https://github.com/SmallAi-API/smaihub --skill agent-runtime-hooks-smallai-api
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: agent-runtime-hooks
Source: https://github.com/SmallAi-API/smaihub/tree/main/.agents/skills/agent-runtime-hooks
Command: npx skills add https://github.com/SmallAi-API/smaihub --skill agent-runtime-hooks-smallai-api

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Developers need visibility and control over agent execution—observing steps, mocking tool calls, handling human approvals, compressing context, and tracking sub-agent runs—without modifying core runtime code. ## Core Features & Use Cases - 16 Hook Types Across 5 Categories: Step-level, tool-call, human intervention, context compression, and sub-agent hooks registered per operation via execAgent({ hooks }). - Tool Call Mocking: beforeToolCall supports event.mock() to return fake tool results, enabling deterministic testing of agent behavior. - Human Intervention Tracking: Hooks fire before/after approval flows and when users reject and halt an agent. - Use Case: An evaluation harness (like devtools/agent-evals) uses afterStep, onComplete, afterToolCall, and beforeToolCall mocks to run reproducible agent evaluations. ## Quick Start Register an afterStep hook via execAgent to log each agent step's content, tool calls, and total cost.

Frequently Asked Questions about agent-runtime-hooks

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I mock a tool call in an agent runtime?

Register a beforeToolCall hook and call event.mock() with the fake result, such as event.mock({ content: '{"error":"rate limited"}' }). The dispatcher returns the mock instead of executing the real tool, but this only works in local in-memory mode.

How do I observe agent execution steps in TypeScript?

Pass hooks to execAgent({ hooks }) with types like beforeStep, afterStep, and onComplete. Each handler receives an AgentHookEvent containing content, toolsCalling, totalCost, and completion reason.

Does beforeToolCall mocking work with webhook hooks?

No, tool call mocking only works in local mode where hooks are held in memory. Webhook mode does not support mocking because dispatchBeforeToolCall requires a synchronous return value.

Why are my sub-agent hooks not firing?

CallAgent hooks require parentOperationId in ExecSubAgentTaskParams and are dispatched on the parent operation, not the sub-agent. Verify the parent operation ID is passed when calling execSubAgentTask.

What happens if a hook handler throws an error?

Hook handlers are fire-and-forget and errors are non-fatal, so a failing handler does not interrupt agent execution. The exception is beforeToolCall, which returns a mock result via dispatchBeforeToolCall.