HookRegistry¶
This docs was updated at: 2026-03-21
com.paragon.harness.HookRegistry ยท Class
Ordered registry of AgentHook instances executed around agent lifecycle events.
Hooks are invoked in registration order for before events and in reverse order
for after events (stack semantics).
Hook failures are caught and logged but do not interrupt agent execution, ensuring that harness infrastructure never breaks agent functionality.
Example:
HookRegistry hooks = HookRegistry.create()
.add(new LoggingHook())
.add(new CostTrackingHook())
.add(new RateLimitingHook(100));
// Wire into agent via Harness builder or directly:
Agent agent = Agent.builder()
.hookRegistry(hooks)
.build();
See Also
AgentHook
Since: 1.0
Methods¶
create¶
Creates an empty registry.
of¶
Creates a registry pre-populated with the given hooks.
add¶
Adds a hook to the registry.
Parameters
| Name | Description |
|---|---|
hook |
the hook to add |
Returns
this registry (for chaining)
size¶
Returns the number of registered hooks.
isEmpty¶
Returns true if no hooks are registered.
fireBeforeRun¶
Dispatches AgentHook.beforeRun to all hooks in order.
fireAfterRun¶
Dispatches AgentHook.afterRun to all hooks in reverse order.
fireBeforeToolCall¶
Dispatches AgentHook.beforeToolCall to all hooks in order.
fireAfterToolCall¶
public void fireAfterToolCall(
@NonNull FunctionToolCall call,
@NonNull ToolExecution execution,
@NonNull AgenticContext context)
Dispatches AgentHook.afterToolCall to all hooks in reverse order.