Skip to content

PostToolUse: updatedToolOutput under hookSpecificOutput is ignored #447

Closed

Description

@przadka-agents

A PostToolUse hook that returns updatedToolOutput under hookSpecificOutput has no effect: the model still gets the original tool output. The same field at the top level works, and tests/hooks-more.test.ts covers that form ("replaces the tool output the model sees via a schema-valid updatedToolOutput").

The nested form is the one in the example of Claude Code's hooks reference, under PostToolUse decision control:

{
  "hookSpecificOutput": {
    "hookEventName": "PostToolUse",
    "updatedToolOutput": { "stdout": "[redacted]", "stderr": "", "interrupted": false, "isImage": false }
  }
}

To reproduce (pi-code 1.7.0 from npm, hooks extension loaded with -e extensions/hooks/index.ts, Pi 1.5.2, Linux):

  1. In the user settings.json (I pointed CLAUDE_CONFIG_DIR at an empty directory holding only this file), add a PostToolUse hook on Bash whose command prints the JSON above.
  2. Run pi -p "Run exactly one bash call: echo hello".
  3. Read the tool result in the session file.
Hook output Tool result the model gets
updatedToolOutput under hookSpecificOutput hello
updatedToolOutput at the top level [redacted]

Cause, as far as I can tell: updatedToolOutput() in extensions/hooks/index.ts reads parsed?.updatedToolOutput and parsed?.updatedMCPToolOutput only, and the type tryParseJson() returns in decisions.ts declares both at the top level, not under hookSpecificOutput.

Where it bites: a redaction hook written for Claude Code that masks credential-shaped output runs, its reason is appended to the tool result, and the secret still reaches the model and the session file.

Reading hookSpecificOutput.updatedToolOutput first and falling back to the top-level field would accept both forms.

Activity

  1. added a commit that references this issue on Nov 15, 2026
    a5ff5f1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions