[Feature Request] PreToolUse hook result substitution primitive
Feature request: result-substitution primitive for PreToolUse hooks
PreToolUse hooks today can allow, deny, modify input, or inject systemMessage — but cannot replace a tool's output
with synthetic content. I'd like a primitive that says "don't run the native tool; here's the result text to hand
the model as if the tool had returned it."
Concrete use case. I built https://github.com/HeinrichvH/Exactor, a PreToolUse hook that intercepts
WebSearch/WebFetch and routes the query to a cheaper, cited, subagent-driven researcher (Mistral Vibe). The
researcher returns a validated report with sources. The report is legitimate tool-result content — but because the
only way to hand it to the model is via permissionDecision: "deny" + permissionDecisionReason (or exit 2 + stderr),
it renders as "PreToolUse:WebSearch hook blocking error". The model reads it fine, but the framing is adversarial
(error, block) when the intent is cooperative (substitution, redirect).
Proposed shape:
{
"hookSpecificOutput": {
"hookEventName": "PreToolUse",
"permissionDecision": "substitute",
"toolResult": "<content to render as if the tool returned it>"
}
}
Or equivalent: a toolResultOverride field on the existing deny decision.
Why it matters. The "senior delegates crawling to cheap subagents" pattern is a genuinely useful abstraction —
subagents compact log/code/web exploration into cited JSON for pennies, saving main-loop context. PreToolUse hooks
are the natural enforcement point, but the current API forces the pattern to surface as errors. A substitution
primitive would unlock a class of "augmentation hooks" (custom fetchers, cached crawlers, local-first search,
policy-filtered responses) without the error-framing wart.
Current workaround: exit 2 + stderr, or permissionDecision: "deny" + permissionDecisionReason. Both work
functionally; both render as blocking errors. Happy to discuss further — context at github.com/HeinrichvH/Exactor.
Environment Info
- Platform: darwin
- Terminal: Apple_Terminal
- Version: 2.1.117
- Feedback ID: 31415c86-13b8-4ee0-b75c-3ba2b5f3e233
Errors
[]This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗