-
-
Notifications
You must be signed in to change notification settings - Fork 3
Pipeline Hooks
CortexPrism edited this page Jun 17, 2026
·
1 revision
The pipeline hooks system provides a 10-stage middleware architecture for the agent loop.
INPUT → pre-assess → ASSESS → post-assess → pre-reason → REASON → post-reason
→ pre-tool → TOOL EXECUTE → post-tool → pre-reflect → REFLECT → post-reflect
→ pre-output → OUTPUT → post-output
| Hook | Stage | Priority | Purpose |
|---|---|---|---|
@cortex/injection-guard |
pre-reason | 5 | Prompt injection detection |
@cortex/model-quartermaster |
pre-llm, post-llm | 5 | MQM model selection |
@cortex/quartermaster |
pre-tool, post-tool | 6 | Tool orchestration learning |
@cortex/summarization |
pre-reason | 8 | Context compaction (80K tokens) |
@cortex/content-safety |
pre-output | 10 | Content filtering |
@cortex/loop-detection |
pre-tool | 12 | Per-file edit tracking |
@cortex/tool-output-sandbox |
post-tool | 15 | Large output capture |
@cortex/pre-completion-checklist |
post-reason | 20 | Build-Verify-Fix |
@cortex/audit-log |
post-output | 150 | Session/turn logging (non-disableable) |
@cortex/cost-tracker |
post-tool, post-output | 200 | Token/cost metrics |
Any hook can return { abort } to stop the pipeline immediately. The abort message is delivered to the user and logged to Lens.
Hooks support five action types:
-
abort— Stop the pipeline -
modifyInput— Mutate the input before processing -
modifyLLMResponse— Modify the LLM's response -
modifyOutput— Modify the final output -
injectMessages— Add messages to the conversation -
sideEffects— Log, emit metrics, store data, send notifications
Plugins can contribute their own hooks to the pipeline. Per-session state is cleaned up on turn end to prevent memory leaks.
cortex hooks list # List all hooks
cortex hooks disable @cortex/cost-tracker # Disable a hook- Architecture — System design including hooks
- Request Flow — Hooks in the request lifecycle
CortexPrism — Open-source agentic AI harness · MIT License · Built with Deno 2.x + TypeScript