agent-runtime-hooks

Provides hooks for Dart VM service and Android, with SwiftUI iOS previews.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/kingheu0818-sketch/lobehub_yu --skill agent-runtime-hooks-kingheu0818-sketch
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: agent-runtime-hooks
Source: https://github.com/kingheu0818-sketch/lobehub_yu/tree/main/.agents/skills/agent-runtime-hooks
Command: npx skills add https://github.com/kingheu0818-sketch/lobehub_yu --skill agent-runtime-hooks-kingheu0818-sketch

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill solves the need to reliably monitor and control an agent’s execution flow—so you can trace steps, inspect tool calls, mock tool results, and integrate human approvals without changing core agent logic.

Core Features & Use Cases

  • Lifecycle tracing: Hook into before/after step events and capture completion or error outcomes for auditing and debugging.
  • Tool-call interception and mocking: Run custom logic before and after tool executions, including deterministic mocking on the beforeToolCall hook in local mode.
  • Human intervention & context management hooks: Observe pauses for approval/rejection and track context compression phases (beforeCompact/afterCompact/onCompactError).
  • Sub-agent call visibility: Trace parent operation behavior when calling sub-agents, including success and error cases.

Quick Start

Register hooks via execAgent({ hooks }) to capture beforeToolCall and afterStep events, and use beforeToolCall to mock a tool response when you need deterministic 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 agent execution steps and capture tool calls during runtime?

You can trace agent execution by registering lifecycle hooks dispatched via HookDispatcher to capture beforeToolCall, afterToolCall, and afterStep events for auditing and debugging without altering core agent logic.

Can I mock tool responses for deterministic agent testing?

Yes, you can intercept tool execution and inject deterministic mocks using the beforeToolCall hook in local mode, ensuring reliable and repeatable agent testing outcomes.

What is the best way to add human approval workflows into an agent's execution flow?

Human approval workflows are integrated by registering hooks that observe pauses for approval or rejection, allowing you to intercept execution and inject manual intervention logic seamlessly.

How do I track context compression events during agent operations?

Context compression tracking is handled by registering hooks for beforeCompact, afterCompact, and onCompactError events, which lets you monitor and manage context window reduction phases during execution.

Does this approach support tracing sub-agent calls and their errors?

Yes, sub-agent call visibility is supported, allowing you to trace parent operation behavior when calling sub-agents, including capturing both successful executions and error cases.

What are the limitations of using async hooks for agent runtime monitoring?

Handlers must be non-fatal async Promise<void> functions, meaning they observe and intercept events without blocking the core execution pipeline, and errors in handlers do not halt the agent runtime.