Skip to content

Bug: Claude UserPromptSubmit hook may corrupt sessions with empty cached text blocks #44

Description

@Taimylife

Claude Code regression: UserPromptSubmit hook appears to cause empty cached text blocks

Environment:

  • Linux
  • Claude Code 2.1.245
  • IJFW enabled as the Claude plugin
  • Claude sessions using the IJFW UserPromptSubmit hook

After enabling IJFW's full hook set globally, fresh Claude sessions repeatedly failed with:

API Error: 400 messages.N.content.1.text: cache_control cannot be set for empty text blocks

The failure made normal messages and /compact fail. Inspecting the affected JSONL transcripts found multiple assistant records containing only { "type": "text", "text": "" }. Removing those empty records from a backup-restored transcript allowed recovery.

The IJFW pre-prompt.sh log also showed internal router/module failures during this period (identifier redeclaration and a bad module path). Disabling only IJFW's UserPromptSubmit hook stopped further global injection; the remaining session-start/compaction/session-end hooks and MCP server were not the target.

Could maintainers confirm:

  1. Whether pre-prompt.sh can ever emit an empty hookSpecificOutput.additionalContext or otherwise lead Claude Code to serialize an empty text block;
  2. Whether this hook is safe on Claude Code 2.1.245; and
  3. The recommended fix/workaround that preserves IJFW memory without corrupting Claude sessions?

I have local backups and can provide redacted hook output if useful.

Activity

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions