Unified 12-Hook Extension Pipeline behaviour (09 - Data Flows and Extension Injection Points.md).
Every callback is optional; modules that use SuperPi.Extension inherit pass-through default
implementations and can override only the hooks they need.
The 12 Canonical Extension Hooks
on_input/2— Intercepts raw user text before turn creation (:continue,{:transform, text, media},:handled).before_agent_start/2— Mutates initial system prompt sections and active tool definitions before the run starts.before_compact/2— Overrides or customizes context compaction (:default,{:compacted, summary, data},:cancel).before_request/2— Inspects/filters derived context messages in-memory right before provider serialization.before_provider_request/2— Inspects/mutates the raw provider HTTP/JSON payload or aborts the call.after_response/2— Inspects the completed assistant response and token usage before tool dispatch.before_tool/3— Permission gate and input validator before a tool executes (:allow,{:block, reason},{:mutate_input, map}).wrap_tool/4— Higher-order middleware around tool execution (next.(args)).after_tool/4— Post-processes 3-channel tool output (output,structured_output,details) before recordingpi.event.after_tools/3— Runs after a parallel tool batch settles (:continue,{:steer, msg},{:handoff, agent}).on_yield/3— Intercepts child task or external yield waits.after_run/2— Verification and continuation gate when the assistant stops calling tools (:acceptor{:continue, follow_up_prompt}).
Summary
Types
@type context() :: map()