[BUG] PreToolUse hook `additionalContext` is received but not injected into model context

Resolved 💬 3 comments Opened Jan 20, 2026 by coygeek Closed Feb 28, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

When a PreToolUse hook outputs hookSpecificOutput.additionalContext, the value is received by Claude Code (visible in session transcript logs) but is never injected into the model's conversation context.

Session logs show the hook output is captured:

PreToolUse:Read hook succeeded: {"systemMessage": "🔧 🟢 marker: pretool test ok"}
    {"hookSpecificOutput": {"hookEventName": "PreToolUse", "permissionDecision": "allow",
    "additionalContext": "XYZZY_PRETOOL_TEST: If you see this, say 'PRETOOL CONTEXT WORKS' as your first words."}}

The additionalContext value appears in the logs, proving Claude Code received it. But the model never sees this content - Claude never responded with "PRETOOL CONTEXT WORKS".

What Should Happen?

The additionalContext string should be injected into the conversation context before the tool executes, allowing hooks to provide pre-execution context to the model (e.g., file metadata, warnings, guidance).

Note: Other hookSpecificOutput fields work correctly:

  • permissionDecision: "deny" - works (blocks tool execution)
  • permissionDecisionReason - works (shown in error message)
  • additionalContext - broken (received but not injected)

Error Messages/Logs

No error messages. The hook runs successfully and the output is logged, but the context injection silently fails.

From session transcript (`~/.claude/projects/.../[session-id].jsonl`):

PreToolUse:Read hook succeeded: {"systemMessage": "🔧 🟢 marker: pretool test ok"}
    {"hookSpecificOutput": {"hookEventName": "PreToolUse", "permissionDecision": "allow",
    "additionalContext": "XYZZY_PRETOOL_TEST: If you see this, say 'PRETOOL CONTEXT WORKS' as your first words."}}

Steps to Reproduce

  1. Create a PreToolUse hook file (~/.claude/hooks/test-context/hook.py):
#!/usr/bin/env python3
import json
import sys

data = json.load(sys.stdin)
if data.get("tool_name") == "Read":
    print(json.dumps({
        "hookSpecificOutput": {
            "hookEventName": "PreToolUse",
            "permissionDecision": "allow",
            "additionalContext": "TEST_MARKER: If you see this, say 'CONTEXT INJECTION WORKS' immediately."
        }
    }))
else:
    print(json.dumps({}))
  1. Make it executable: chmod +x ~/.claude/hooks/test-context/hook.py
  1. Add to ~/.claude/settings.json:
{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Read",
        "hooks": [{"type": "command", "command": "python3 ~/.claude/hooks/test-context/hook.py"}]
      }
    ]
  }
}
  1. Start a new Claude Code session
  1. Ask Claude to read any file (e.g., "Read /tmp/test.txt")
  1. Expected: Claude responds starting with "CONTEXT INJECTION WORKS"
  1. Actual: Claude responds normally without acknowledging the injected context
  1. Verify hook ran: Check session transcript - you'll see the additionalContext in logs but Claude never received it

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.1.12

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

Claude Code Version: 2.1.12
OS: macOS (Darwin 25.2.0)

Workaround: Use systemMessage field instead:

{"systemMessage": "<system-reminder>Your context here</system-reminder>"}

Suspected cause: The code path that should inject additionalContext into the conversation context is either missing or broken. The value is successfully parsed and logged, but never added to the messages sent to the model.

Related: This may be the same issue as #15664 if that exists, or a new manifestation of context injection bugs in the hook system.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗