Execution Hooks

AVAILABLE

Naagmani offers discrete hook interception points along the complete request/response lifecycle.

Rendering diagram...

Supported Hook Points #

Hook NameWhen It ExecutesCan Mutate Payload?Common Use Cases
pre_authBefore token validation and project context resolution.Headers onlyCustom JWT decryption, IP whitelisting.
pre_routeAfter project auth, before selecting the upstream provider/model.Yes (Full)Semantic routing, RAG context enrichment, PII masking.
pre_model_callImmediately before dispatching payload to the selected provider adapter.Yes (Provider payload)Model-specific prompt formatting, token clipping.
post_model_callImmediately after provider response or first stream chunk.YesOutput moderation, toxic content filtering.
post_responseFinal stage before sending bytes to client.YesWatermarking, telemetry calculation.
on_errorTriggered when upstream provider returns 4xx/5xx or timeouts.Error payloadCustom error formatting, alert webhooks.

Hook Priority & Ordering #

Multiple plugins can attach to the same hook point. They execute strictly ordered by their priority integer in descending order:

  1. Plugin A (priority: 100)
  2. Plugin B (priority: 50)
  3. Plugin C (priority: 10)

Each plugin receives the output resulting from the preceding plugin in the pipeline.


Next Steps #