[BUG] cache_control cannot be set for empty text blocks

Resolved 💬 3 comments Opened Apr 28, 2026 by kalato77-sudo Closed Jun 22, 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?

Bug: cache_control cannot be set for empty text blocks

Version: Claude Code v2.1.121

OS: macOS

Steps to reproduce:

  1. Create a project with multiple agents in .claude/agents/
  2. Run any slash command that activates those agents
  3. Error appears immediately

Error message:
API Error: 400 {"type":"invalid_request_error","message":"messages.0.content.X.text: cache_control cannot be set for empty text blocks"}

Root cause (observed):
Claude Code appends a ## MEMORY.md block to each agent file at runtime. When MEMORY.md is empty, this creates an empty text block with cache_control set, which the API rejects.

Expected behavior:
Command executes normally. If MEMORY.md is empty, the block should be omitted or cache_control should not be applied.

What Should Happen?

Slash commands should execute normally when agent MEMORY.md files are empty. The empty MEMORY.md block should either be omitted from the request or cache_control should not be applied to it.

Error Messages/Logs

**Error message:**
API Error: 400 {"type":"invalid_request_error","message":"messages.0.content.X.text: cache_control cannot be set for empty text blocks"}

Steps to Reproduce

  1. Create a project with multiple agent files in .claude/agents/
  2. Start Claude Code: claude
  3. Run any slash command that activates those agents: /Tras_El_Cristal
  4. Error appears immediately — command never executes

Note: All agent MEMORY.md files are empty (fresh project).
The bug occurs because Claude Code appends an empty ## MEMORY.md
block to each agent at runtime and sets cache_control on it.

Claude Model

Sonnet (default)

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.1.121

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

_No response_

View original on GitHub ↗

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