Redop has two post-handler phases:Documentation Index
Fetch the complete documentation index at: https://redop.useagents.site/docs/llms.txt
Use this file to discover all available pages before exploring further.
after, which still runs before the response and may replace the resultafterResponse, which runs after the response is already written and cannot change it
Tool execution order
For tools, the request flow is:What each stage is for
derivebuilds reusable context from the requestonTransformmutates raw params before schema parsing- schema parsing validates and coerces input
onParsecan replace parsed inputonBeforeHandleobserves work before middleware and handlers across tools, resources, and promptstool.beforeis local to one tool- middleware controls execution flow
- the handler does the actual work
tool.aftercan post-process one tool resultonAfterHandleobserves successful results across the whole server before the response is writtentool.afterResponseruns after the response is written for one tool onlyonAfterResponseruns after the response is written across the whole server
Resource and prompt execution order
Resources and prompts do not go through schema parsing. Their successful path is:toolis the tool name for tool callstoolis the resource URI for resourcestoolis the prompt name for prompts
Error handling
If middleware or the handler throws,onError hooks run.
Errors thrown inside after hooks are isolated so the original successful result can still complete.
Errors thrown inside afterResponse hooks are also isolated, but by that point the response is already sent. Those failures can be logged or observed, but they cannot change what the client received.
When to use each hook
- Use
onBeforeHandlefor shared setup or observation before execution. - Use
onAfterHandlewhen you must inspect or replace successful results before the client receives them. - Use
onAfterResponsefor analytics, logging, metrics, and other best-effort work that should happen after the response.