Aident AI

Claude Code Tool Result Missing? Remove PreToolUse Defer
If Claude Code returns [Tool result missing due to internal error] only for tools matched by a PreToolUse hook, inspect the hook's JSON output. For an interactive Claude Code or Claude Desktop session, remove permissionDecision: "defer" from an advisory or no-op path. Exit successfully with no output when the hook has no decision, or return additionalContext without a permission decision when the model needs a warning. Do not replace defer with allow, because that can bypass the normal permission decision.
Current reports show this failure on Bash, Write, and AskUserQuestion. The matched tool never runs, the expected question or permission control may not appear, and Claude receives the generic missing-result message. This is different from an ordinary command failure because there is no real tool result to diagnose.
Confirm That a PreToolUse Hook Owns the Failure
The same generic message can describe unrelated failures, so first isolate the boundary.
What you observe | Likely boundary | Next step |
|---|---|---|
Only tools matched by one | Hook decision output | Inspect that hook for |
| A hook that defers | Remove |
The hook log records exit 127 or command not found | Hook process never launched | Use the hook exit 127 guide |
Every tool fails even after hooks are disabled in a controlled test | Host, transport, or session issue | Preserve the transcript and compare a fresh terminal session |
A permission prompt repeats even though the tool result is present | Permission configuration rather than missing output | Use the auto mode permission guide |
Run /hooks in Claude Code and note the exact configuration source for the matching hook. Hooks can come from user settings, project settings, local project settings, managed policy, a plugin, or skill and agent frontmatter. Edit only the source that owns the faulty matcher.
Before changing a project file, capture its diff:
For a user-level file such as ~/.claude/settings.json, make a local backup without printing its contents. Settings can contain private paths, commands, and environment references.
Why Defer Breaks the Interactive Flow
Anthropic's current hooks reference gives defer a narrow contract. It is for an integration that runs claude -p as a subprocess, reads the JSON result, receives stop_reason: "tool_deferred", presents the pending tool in its own interface, and later resumes the same session. The tool is not supposed to execute before that resume loop completes.
An ordinary interactive terminal or Claude Desktop session is not that integration loop. Three independent reports show the consequence:
Issue 64389 reports that a
Bashhook returningdeferproduces the missing-result error and never starts the shell command.Issue 80839 reproduces the failure for
WriteandBashwhendeferis combined withadditionalContext. Removing the decision while keeping the context was the reporter's working mitigation.Issue 84589 reports that Claude Desktop parked all eight observed
AskUserQuestioncalls while thousands of other tool calls completed.
These reports establish a reliable configuration boundary and mitigation. They do not establish one official root cause for every host or prove that a particular Claude Code release has fixed the behavior.
Repair a No-Opinion or Advisory Hook
A common guardrail needs three outcomes:
deny an unsafe operation;
add context without deciding; or
have no opinion and let the normal permission flow continue.
The faulty no-op branch often emits this:
For a true no-op, exit with code 0 and write nothing to stdout. For an advisory warning, keep only the context:
Keep a real denial explicit:
Do not use allow as a substitute for no opinion. allow resolves the permission decision in favor of execution, while empty output leaves the normal permissions system in control. Do not disable every hook or change the global permission mode to work around one malformed result.
If your hook script builds a result object, make the no-op path return before serialization. This avoids accidentally printing {}, null, a debug line, or a stale decision. Keep logs on stderr or in a protected local log, and never include secrets or full tool inputs in diagnostic output.
Test the Hook as a Four-Case Matrix
Reload the edited settings or start a fresh session, then test the smallest safe cases.
Case | Hook output | Expected behavior |
|---|---|---|
No opinion | Exit 0 with empty stdout | The tool follows normal permission rules and returns a real result |
Advisory |
| Claude receives the warning and the tool follows normal permission rules |
Policy denial |
| The tool does not run and Claude receives the specific denial reason |
Intentional headless hold |
| The subprocess exits with |
Start with a harmless read-only command such as pwd or a read of a disposable fixture. Confirm that:
the tool returns real output instead of the generic missing-result message;
an advisory message appears without auto-approving the tool;
a denied fixture does not execute; and
an operation outside the allow list still uses the expected permission flow.
For AskUserQuestion, use one short test question. The decision control must appear and return a corresponding tool result. Do not test with a production deployment choice, destructive command, secret, or irreversible action.
Keep Defer Only for a Real Resume Integration
If you intentionally operate a headless host, keep defer only after verifying the complete contract:
the host launches Claude Code with
-pand a structured output format;the hook returns
deferfor a single tool call;the process result contains
stop_reason: "tool_deferred", a session ID, and the pending tool call;the host presents or resolves that pending call outside Claude Code;
the host resumes the same session with
claude -p --resume; andthe resumed hook returns
allowwith validated updated input or returnsdeny.
Anthropic documents that defer is ignored when the model emits multiple tool calls together because only one pending tool can be resumed safely. Treat a missing deferred_tool_use, a normal completion, or any execution before explicit resolution as a failed integration test.
Do not copy the headless pattern into an interactive settings file. Separate host-specific hook configuration so a desktop or terminal session cannot enter a state that only an external resume controller understands.
If the Error Persists
Re-run /hooks and check for another matcher from a different scope. User, project, managed, plugin, and skill hooks can all match the same event, and all matching hooks run before Claude Code combines their results. One repaired hook does not cancel a second hook that still returns defer.
Then narrow the test:
disable only the suspected hook in a local reversible configuration;
start a fresh session and repeat one harmless tool call;
restore the hook with empty or context-only output;
repeat the same call; and
compare the transcript and debug log without uploading raw private data.
If the result is still missing with no matching hook, stop applying this fix. Record the Claude Code version, host surface, tool name, configuration scopes, and one sanitized reproduction. A transport failure, a parallel tool-result bug, or a host-specific question UI failure needs a different upstream report.
Track the Upstream Reports Without Editing Them
You can use Aident Loadout to check whether the reports have been closed, linked to a release, or given an official workaround without pasting a GitHub token into the agent. Give Claude Code the canonical setup instruction:
Follow https://aident.ai/SETUP.md
Then use this bounded prompt:
Check my Aident Loadout account and Vault status. Find a connected read-only GitHub issue search Action, inspect its current schema, and preflight it. Return up to five open
anthropics/claude-codeissues that contain bothPreToolUseanddefer, prioritizingTool result missing due to internal error. Include issue number, title, status, comments, reactions when returned, and updated time. Do not create or edit issues, post comments, change files, or ask for a provider key.
Success is measurable: you receive at most five current issue records, the Action performs zero GitHub writes, and no credential appears in the prompt or result. Ready to monitor the fix safely? Set up Aident Loadout and run the read-only issue check.
Sources
Claude Code issue 64389: PreToolUse defer causes a missing tool result
Claude Code issue 80839: defer plus additionalContext breaks Write and Bash
Claude Code issue 84589: Claude Desktop parks AskUserQuestion
Refresh this guide when Anthropic changes the documented defer contract, the cited issues change state, a Claude Code release verifies the interactive behavior, or the linked Aident setup and hook diagnostics change.



The one tool
for every tool
your agent needs.
Give any AI agent real capabilities in seconds. Connect 1,000+ tools once, skip the setup headache, and let your agents execute.
