Skip to content

Bug: thinking/redacted_thinking blocks exposed to chat on context pruning #49573

@eardori

Description

@eardori

Bug Report

Description

When a long session triggers context pruning (cache-ttl mode), Anthropic API rejects the request with:

LLM request rejected: messages.N.content.1: thinking or redacted_thinking blocks in the latest assistant message cannot be modified. These blocks must remain as they were in the original response.

This error message is then sent directly to the chat channel (Telegram group in this case), exposing internal error details to end users.

Steps to Reproduce

  1. Have a long multi-turn conversation (60+ messages)
  2. Context pruning kicks in (contextPruning.mode: cache-ttl)
  3. A prior assistant message contains thinking blocks
  4. Pruning attempts to modify/truncate that message
  5. Anthropic API rejects → error surfaces in chat

Expected Behavior

  • Error should be caught internally and handled gracefully
  • Either: silently retry without the problematic message, or restart the session context
  • Error should NOT be sent to the end-user chat channel

Actual Behavior

Raw API error string is sent as a chat message to the active channel (Telegram group chat).

Config

{
  "contextPruning": {
    "mode": "cache-ttl",
    "ttl": "1h"
  }
}

Impact

  • Confusing UX for end users in group chats
  • Exposes internal system details publicly

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions