Skip to main content

In plain terms

Three ways to attach your own code: The event bus is also for watching. Prefer hooks when you already have the agent object. Prefer onAny for tracers.

hooks — the four doorbells

These cannot skip a tool. For that, use loopHooks.beforeToolExec.

Guardrails — teachers who can send you back

Input runs before the model sees the question. Fail → the run throws. Output runs after the answer. Fail → the run throws (and a cached answer is dropped).

loopHooks — the steering wheel

Full page: Loop hooks.