Bug: UserPromptSubmit additionalContext accumulates in history instead of being ephemeral

Status Closed — not planned
Maintainer reply None cached
Activity 5 comments · opened Mar 28, 2026 · closed May 5, 2026

Bug

UserPromptSubmit hook output with additionalContext accumulates in the conversation history instead of being replaced on each new message. Every user message adds another <system-reminder> block, and previous ones remain visible to the model.

Steps to reproduce

  1. Add a UserPromptSubmit hook to settings.json:
"UserPromptSubmit": [{
  "hooks": [{
    "type": "command",
    "command": "printf '{\"hookSpecificOutput\": {\"hookEventName\": \"UserPromptSubmit\", \"additionalContext\": \"Current time: %s\"}}' \"$(date '+%Y-%m-%d %H:%M %Z %A')\""
  }]
}]
  1. Send several messages in a conversation.
  2. Ask Claude if it can see multiple timestamps from previous messages.

Expected behavior

Based on the documentation, additionalContext should be ephemeral/request-scoped — only the latest output should be visible to the model, replacing the previous one.

Actual behavior

All previous additionalContext outputs remain in the conversation history as separate <system-reminder> blocks. The model can see every timestamp from every previous message.

Why this matters

I use a global hook script (~/.claude/hooks/context.sh) to inject dynamic project state on every message:

  • Current time
  • git status with branch name
  • LOCKS.md (multi-agent coordination file)

I would also like to inject larger context like TODO files (50-500 lines) and agent-specific source files for my multi-agent setup, but this is impossible with accumulating behavior — 20 messages × 500 lines = 10,000 lines of wasted context.

The intended use case is a dynamic context layer that always reflects the current project state, similar to how CLAUDE.md is re-read from disk, but generated from script output. If additionalContext were truly ephemeral (replacing the previous output), this would work perfectly.

View original on GitHub ↗

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