pub enum HookResponse {
Allow {
reason: Option<String>,
},
Deny {
reason: Option<String>,
},
Modify {
input: Value,
reason: Option<String>,
},
Replace {
output: Value,
is_error: Option<bool>,
reason: Option<String>,
},
}Expand description
What a hook answered.
The wire spelling of HookOutcome, which is what an
in-process Interceptor returns directly. Two shapes
for one vocabulary, because JSON has no enums and a shell script has no
serde_json::Value — everything past the parse is shared.
Variants§
Allow
No objection. reason is ignored, and exists so a hook can say why for
a human reading its own logs.
Deny
Block the call. reason reaches the model as the tool’s error, so it
should read as an explanation, not a status code.
Modify
Run the tool with this input instead of the one the model produced.
input is required: a modify without one is a hook that meant to
intervene and did not say how, and quietly running the original would
be the one outcome nobody asked for.
Only at pre_tool_use. After the call there is no input left to
change, and a hook that asks for one is answered as a hook that could
not answer.
Replace
Show the model this result instead of the one the tool returned.
output is required, for the reason modify’s input is. A string is
a text result and anything else is a structured one, which is the same
distinction the runtime already draws — so a hook that rewrites a line
of text writes a JSON string and gets text back, with no quoting to
undo.
is_error is optional and means “leave it as it was” when omitted: a
hook that redacts a secret out of a failing result has not thereby
declared the call a success. Say it explicitly to change it.
Only at post_tool_use.