[BUG] PreToolUse hook `additionalContext` is received but not injected into model context
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
- 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({}))
- Make it executable:
chmod +x ~/.claude/hooks/test-context/hook.py
- Add to
~/.claude/settings.json:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Read",
"hooks": [{"type": "command", "command": "python3 ~/.claude/hooks/test-context/hook.py"}]
}
]
}
}
- Start a new Claude Code session
- Ask Claude to read any file (e.g., "Read /tmp/test.txt")
- Expected: Claude responds starting with "CONTEXT INJECTION WORKS"
- Actual: Claude responds normally without acknowledging the injected context
- Verify hook ran: Check session transcript - you'll see the
additionalContextin 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.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗