agent-runtime-hooks

Intercept agent lifecycle events and mock tool calls via hooks.

1|Updated May 9, 2026
One-click install
npx skills add https://github.com/duwenji/generative-ai-oss-tutorials --skill agent-runtime-hooks-duwenji
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: agent-runtime-hooks
Source: https://github.com/duwenji/generative-ai-oss-tutorials/tree/main/sandbox/lobe-chat/.agents/skills/agent-runtime-hooks
Command: npx skills add https://github.com/duwenji/generative-ai-oss-tutorials --skill agent-runtime-hooks-duwenji

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

You need visibility and control over an agent’s execution flow so you can debug behavior, log costs/events, mock tool calls, and integrate tracing/evals without rewriting the agent core.

Core Features & Use Cases

  • Lifecycle hook coverage: Intercept events across step execution, tool calls, human intervention, context compression, sub-agent calls, completion, and errors.
  • Tool call mocking: Use beforeToolCall hook events to return deterministic mock results for local testing and evaluation.
  • Scoped, per-operation dispatch: Register hooks via execAgent({ hooks }) and automatically clean them up when the operation completes.

Quick Start

Register an afterStep and beforeToolCall hook in your agent execution so you can log each step outcome and mock a specific tool response during testing.

Frequently Asked Questions about agent-runtime-hooks

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

FAQPage Schema
How do I trace and log every step of an agent execution flow?

Agent runtime hooks intercept lifecycle events across step execution, tool calls, and errors to provide tracing. You register hooks via execAgent to log each step outcome and monitor behavior without rewriting the agent core.

Can I mock tool calls for deterministic local testing and evaluation?

Yes, tool call mocking uses the beforeToolCall hook event to return deterministic mock results. This enables local testing and evaluation harnesses by intercepting tool boundaries and injecting controlled responses via event.mock().

How do I add human-in-the-loop pauses to an autonomous agent workflow?

Runtime hooks intercept human intervention lifecycle events to enable human-in-the-loop pauses. You register hook handlers to pause execution at specific boundaries, allowing manual review before the agent proceeds to the next operation.

What is the best way to monitor context compression in sub-agent orchestration?

Runtime hooks intercept context compression and sub-agent call events to monitor orchestration. You register scoped, per-operation hooks that dispatch automatically during execution and clean up when the operation completes.

Do runtime hook handlers block agent execution when an error occurs?

No, hook handlers are fire-and-forget with non-fatal error behavior. If a hook handler encounters an error, it does not block or crash the agent execution flow, ensuring the main operation continues running smoothly.

Are agent runtime hooks scoped to a single operation or globally registered?

Runtime hooks are scoped per-operation. You register them via execAgent with automatic cleanup when the operation completes, preventing hook leakage across different agent runs and ensuring isolated execution contexts.