UserPromptSubmit hook additionalContext not injected into model context in VSCode extension
Resolved 💬 3 comments Opened Apr 16, 2026 by qinyan1603-source Closed Jun 19, 2026
Environment
- Claude Code VSCode Extension (tested on v2.1.109+)
- Windows 11, Python 3.x
- Hook registered in
~/.claude/settings.jsonunderhooks.UserPromptSubmit
Summary
A UserPromptSubmit hook that outputs valid {"additionalContext": "..."} JSON to stdout executes successfully but the content never reaches the model context. The same hook mechanism works as expected in CLI.
Reproduction
- Register a UserPromptSubmit hook in
settings.json:
``json``
"UserPromptSubmit": [{
"hooks": [{
"type": "command",
"command": "python path/to/hook.py",
"timeout": 10
}]
}]
- The hook script reads stdin JSON, builds context, outputs:
``json``
{"additionalContext": "Current time: 2026-04-16 16:28 ..."}
- Open VSCode, start a new Claude Code conversation
- Ask the model: "What startup context did you receive from hooks?"
- Model reports: none received
Evidence that the hook DID execute
- Hook writes a state file on successful execution → file exists with correct
session_idand timestamp - Running the hook manually with
echo '{"session_id":"test"}' | python hook.pyproduces valid JSON output - A second hook (
session_reset.py) registered on the same event also executes and writes its own state file
Evidence that additionalContext is NOT injected
- Model explicitly reports no startup context received
- No
<user-prompt-submit-hook>tag visible in conversation - No time/memory/backlog content visible anywhere in model context
What works
- Hook triggering: ✅
- Hook script execution: ✅
- Hook stdout output (valid JSON with
additionalContext): ✅ - Stop hook blocking feedback (non-zero exit): ✅ (reaches model)
- CLAUDE.md loading: ✅
- MCP tool calls: ✅
What doesn't work
UserPromptSubmithookadditionalContext→ model context: ❌
Expected behavior
Per Claude Code hooks documentation, additionalContext returned from a hook's stdout should be appended to the model's context for that turn. This works in CLI but not in the VSCode extension.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗