Hooks + Plugins (Implementation): priority, parallelism, fault isolation
Hooks + Plugins (Implementation): priority, parallelism, fault isolation
This page complements Hooks + plugins governance with an implementation-oriented view.
Code entry points (optional)
src/plugins/loader.tssrc/plugins/registry.tssrc/plugins/hook-runner-global.tssrc/plugins/hooks.tssrc/agents/pi-tools.before-tool-call.tssrc/agents/pi-embedded-runner/run/attempt.tssrc/agents/pi-embedded-subscribe.handlers.tools.ts
Registration-time state machine
Conflicts must be rejected with diagnostics (methods/routes/commands); don’t “last writer wins”.
Runtime state machine (HookRunner)
You need two execution models:
- void hooks: run in parallel; default catchErrors=true.
- modifying hooks: run serially by priority; merge rules must be stable.
Injection points (placement matters)
- before agent start (prepend context)
- before tool call (patch/block)
- after tool call (audit, success + failure)
- agent end (summary snapshot + duration)
Failure modes and troubleshooting
- A single plugin breaks the main flow: confirm catchErrors and fire-and-forget audits.
- Unpredictable multi-plugin behavior: verify priority ordering and deterministic merge rules.
Acceptance checks
- higher-priority hooks run first.
- void hooks don’t block main replies.
- conflicts produce diagnostics, not silent overrides.