Claude Code Tool Result Missing? Remove PreToolUse Defer

Claude Code Tool Result Missing? Remove PreToolUse Defer

Aident AI

A cyan command passes through a violet decision gate while an amber pause bracket lifts away toward a stable white result.

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 PreToolUse hook lose their result

Hook decision output

Inspect that hook for permissionDecision: "defer"

AskUserQuestion never renders in Claude Desktop, but other tools work

A hook that defers AskUserQuestion

Remove defer from the no-op path and retest one question

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:

git status --short
git diff -- .claude/settings.json

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 Bash hook returning defer produces the missing-result error and never starts the shell command.

  • Issue 80839 reproduces the failure for Write and Bash when defer is combined with additionalContext. Removing the decision while keeping the context was the reporter's working mitigation.

  • Issue 84589 reports that Claude Desktop parked all eight observed AskUserQuestion calls 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:

  1. deny an unsafe operation;

  2. add context without deciding; or

  3. have no opinion and let the normal permission flow continue.

The faulty no-op branch often emits this:

{
  "hookSpecificOutput": {
    "hookEventName": "PreToolUse",
    "permissionDecision": "defer"
  }
}

For a true no-op, exit with code 0 and write nothing to stdout. For an advisory warning, keep only the context:

{
  "hookSpecificOutput": {
    "hookEventName": "PreToolUse",
    "additionalContext": "This command targets a generated file. Verify the source of truth before editing."
  }
}

Keep a real denial explicit:

{
  "hookSpecificOutput": {
    "hookEventName": "PreToolUse",
    "permissionDecision": "deny",
    "permissionDecisionReason": "This operation violates the repository write policy."
  }
}

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

additionalContext without a decision

Claude receives the warning and the tool follows normal permission rules

Policy denial

permissionDecision: "deny" with a reason

The tool does not run and Claude receives the specific denial reason

Intentional headless hold

permissionDecision: "defer" under claude -p

The subprocess exits with tool_deferred; the host records the pending call and resumes it later

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:

  1. the host launches Claude Code with -p and a structured output format;

  2. the hook returns defer for a single tool call;

  3. the process result contains stop_reason: "tool_deferred", a session ID, and the pending tool call;

  4. the host presents or resolves that pending call outside Claude Code;

  5. the host resumes the same session with claude -p --resume; and

  6. the resumed hook returns allow with validated updated input or returns deny.

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:

  1. disable only the suspected hook in a local reversible configuration;

  2. start a fresh session and repeat one harmless tool call;

  3. restore the hook with empty or context-only output;

  4. repeat the same call; and

  5. 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-code issues that contain both PreToolUse and defer, prioritizing Tool 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

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.

Home

Home

Home

Integrations

Integrations

Integrations

Vault

Vault

Vault

Audit

Audit

Audit

Arana Grande

Arana Grande

Arana Grande

Free

Free

Free

30-day audit summary

30-day audit summary

30-day audit summary

Daily action-call volume and the latest receipts from the Loadout audit trail.

Daily action-call volume and the latest receipts from the Loadout audit trail.

Daily action-call volume and the latest receipts from the Loadout audit trail.

View Audit

View Audit

View Audit

Loadout usage

Loadout usage

Loadout usage

617 action calls in the last 30 days

617 action calls in the last 30 days

617 action calls in the last 30 days

May 19 - Jun 17

May 19 - Jun 17

May 19 - Jun 17

10 active days

10 active days

10 active days

Less

Less

Less

More

More

More

Recent activity

Recent activity

Recent activity

Latest action-call receipts from connected agents

Latest action-call receipts from connected agents

Latest action-call receipts from connected agents

Apr 23, 09:23 AM

Apr 23, 09:23 AM

Apr 23, 09:23 AM

Shopify

Shopify

Shopify

Creates Or Updates An Asset For A Theme

Creates Or Updates An Asset For A Theme

Creates Or Updates An Asset For A Theme

Success

Success

Success

Apr 23, 09:21 AM

Apr 23, 09:21 AM

Apr 23, 09:21 AM

Shopify

Shopify

Shopify

Update Products Param Product Id

Update Products Param Product Id

Update Products Param Product Id

Success

Success

Success

Apr 23, 08:53 AM

Apr 23, 08:53 AM

Apr 23, 08:53 AM

Shopify

Shopify

Shopify

Update Products Param Product Id

Update Products Param Product Id

Update Products Param Product Id

Failed

Failed

Failed

Apr 22, 22:13 PM

Apr 22, 22:13 PM

Apr 22, 22:13 PM

Shopify

Shopify

Shopify

Create Product Image

Create Product Image

Create Product Image

Success

Success

Success

Apr 22, 22:12 PM

Apr 22, 22:12 PM

Apr 22, 22:12 PM

Shopify

Shopify

Shopify

Create Product Image

Create Product Image

Create Product Image

Success

Success

Success

Connected integration coverage

Connected integration coverage

Connected integration coverage

162

162

162

of 753 accessible connected

of 753 accessible connected

of 753 accessible connected

Callable actions

Callable actions

Callable actions

1,126

1,126

1,126

Vault credentials

Vault credentials

Vault credentials

8

8

8

Explore what's possible

Explore what's possible

Explore what's possible

See all Integrations

See all Integrations

See all Integrations

Google Ads

Google Ads

Google Ads

All available Goolge Ads tools via...

All available Goolge Ads tools via...

All available Goolge Ads tools via...

X (twitter)

X (twitter)

X (twitter)

All available X tools via...

All available X tools via...

All available X tools via...

Github

Github

Github

All available Github tools via...

All available Github tools via...

All available Github tools via...

Notion

Notion

Notion

All available Notion tools via...

All available Notion tools via...

All available Notion tools via...

Slack

Slack

Slack

All available Slack tools via...

All available Slack tools via...

All available Slack tools via...

Firecrawl

Firecrawl

Firecrawl

All available Firecrawl tools via...

All available Firecrawl tools via...

All available Firecrawl tools via...

753 integrations are available for loadouts.

753 integrations are available for loadouts.

753 integrations are available for loadouts.

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.

Try Aident Loadout

Give your Agent real capabilities in minutes. Connect 1,000+ tools, and let your agents execute.

Try Aident Loadout

Give your Agent real capabilities in minutes. Connect 1,000+ tools, and let your agents execute.

Try Aident Loadout

Give your Agent real capabilities in minutes. Connect 1,000+ tools, and let your agents execute.