agent-runtime-hooks

Registers lifecycle hooks to observe and intercept agent execution steps and tool calls.

74|11|Updated Jul 4, 2024
One-click install
npx skills add https://github.com/OpenSourceAGI/qwksearch-research-agent --skill agent-runtime-hooks-opensourceagi
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: agent-runtime-hooks
Source: https://github.com/OpenSourceAGI/qwksearch-research-agent/tree/main/apps/qwk-in-lobe/.agents/skills/agent-runtime-hooks
Command: npx skills add https://github.com/OpenSourceAGI/qwksearch-research-agent --skill agent-runtime-hooks-opensourceagi

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Developers building on the agent runtime lack visibility into and control over agent execution, making it hard to observe steps, mock tool responses, handle human approvals, or track sub-agent calls without modifying core runtime code. ## Core Features & Use Cases - 16 Lifecycle Hook Types: Register hooks across 5 categories including step, tool call, human intervention, context compression, and sub-agent events via execAgent({ hooks }). - Tool Call Mocking: Use beforeToolCall with event.mock() to intercept tool execution and return simulated responses for testing. - Human Intervention Tracking: Observe approve/reject flows with beforeHumanIntervention, afterHumanIntervention, and onStopByHumanIntervention events. - Use Case: Build an evaluation harness like agent-evals that uses afterStep, onComplete, and beforeToolCall mocks to run deterministic agent tests without hitting real external tools. ## Quick Start Register an afterStep and beforeToolCall hook via execAgent to log each agent step and mock a specific tool response during a test run.

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 desired result payload. The HookDispatcher returns the mock via dispatchBeforeToolCall, so the real tool never executes. Mocking only works in local mode, not webhook mode.

How to observe agent execution steps and tool calls?

Pass a hooks array to execAgent with handlers like beforeStep, afterStep, afterToolCall, and onComplete. Hooks are registered per operation by HookDispatcher and automatically unregistered when the operation finishes.

What hook types does the agent runtime support?

The runtime supports 16 hook types across 5 categories: step level, tool call level, human intervention, context compression, and sub-agent CallAgent events. All handlers are fire-and-forget async functions except beforeToolCall, which supports mocking.

Do agent hooks work for sandbox and MCP tools?

Yes, sandbox and MCP tools go through executeTool, so beforeToolCall and afterToolCall hooks cover them automatically. Use event.identifier in your handler to filter for specific tools.

Why is my beforeToolCall mock not working in webhook mode?

Tool call mocking only works in local mode where hooks are held in memory. Webhook mode dispatches hooks remotely and cannot return a mock result, so the real tool will always execute.