Skip to content

feat(agent): preserve Anthropic thinking blocks and enable interleaved thinking#120

Merged
spachava753 merged 1 commit intomainfrom
feat/anthropic-thinking-preservation
Dec 22, 2025
Merged

feat(agent): preserve Anthropic thinking blocks and enable interleaved thinking#120
spachava753 merged 1 commit intomainfrom
feat/anthropic-thinking-preservation

Conversation

@spachava753
Copy link
Copy Markdown
Owner

Summary

When resuming conversations across different providers, thinking blocks from one provider (e.g., Gemini) are incompatible with another (e.g., Anthropic). Previously, CPE filtered out all thinking blocks, but this prevented Claude from benefiting from its own preserved reasoning when resuming conversations.

Changes

New AnthropicThinkingBlockFilter: Identifies Anthropic thinking blocks by checking for the anthropic_thinking_signature key in ExtraFields, keeping those while filtering out thinking blocks from other providers. Non-Anthropic generators continue to use the existing BlockWhitelistFilter.

Beta headers for Anthropic: API requests now include:

  • interleaved-thinking-2025-05-14 - enables Claude to reason between tool calls
  • context-management-2025-06-27 - enables server-side thinking block retention management

Testing

Added comprehensive tests for the new filter covering Anthropic/Gemini/OpenRouter thinking blocks, edge cases, and mixed provider conversations.

Closes #115

…d thinking

When resuming conversations across different providers, thinking blocks from one provider (e.g., Gemini) are incompatible with another (e.g., Anthropic). Previously, CPE filtered out all thinking blocks, but this prevented Claude from benefiting from its own preserved reasoning when resuming conversations.

The new AnthropicThinkingBlockFilter identifies Anthropic thinking blocks by checking for the `anthropic_thinking_signature` key in ExtraFields, keeping those while filtering out thinking blocks from other providers. Non-Anthropic generators continue to use the existing BlockWhitelistFilter that removes all thinking blocks.

Additionally, Anthropic API requests now include beta headers for interleaved thinking (`interleaved-thinking-2025-05-14`) and server-side context management (`context-management-2025-06-27`), enabling Claude to reason between tool calls and allowing the API to manage thinking block retention automatically.

Closes #115
@spachava753 spachava753 merged commit 7a4455f into main Dec 22, 2025
@spachava753 spachava753 deleted the feat/anthropic-thinking-preservation branch April 10, 2026 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Thinking blocks filtered for Claude 4.5 Opus during conversation resume

1 participant