Hook Runner • AI Agent SDK

HookRunner: Executes hooks from a registry.

HookRunner

Defined in the runner module.

AI Agent

Executes hooks from a registry.

Supports:

  • Python function hooks (sync and async)
  • Shell command hooks
  • Sequential and parallel execution
  • Timeout handling
  • Result aggregation
Diagram

Allow

Deny

Event Trigger

Hook: HookRunner

Decision

Process

Block

Constructor

ParamField Optional[HookRegistry]

No description available.

ParamField float

No description available.

ParamField Optional[str]

No description available.

Methods

Usage

python
registry = HookRegistry()
    runner = HookRunner(registry)

    # Execute hooks for an event
    results = await runner.execute(
        event=HookEvent.BEFORE_TOOL,
        input_data=BeforeToolInput(
            tool_name="write_file",
            tool_input={"path": "/tmp/test.txt"}
        )
    )

    # Check if any hook blocked
    if runner.is_blocked(results):
        print("Tool execution blocked by hook")

Source

View on GitHub

praisonaiagents/hooks/runner.py at line 31


Related Documentation