Skip to content

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

@spachava753

Description

@spachava753

Affected Area

Model interaction (OpenAI, Anthropic, Gemini, etc.)

Model Provider

anthropic

Model ID

claude-4-5-opus-20250224

Bug Description

When resuming a conversation or continuing a session, the CPE agent filters out "thinking" blocks from the conversation history before sending it back to the model. This is implemented via a BlockWhitelistFilter in internal/agent/generator.go which only allows gai.Content and gai.ToolCall blocks.

While this behavior is generally desirable for many models that don't support interleaved thinking or context preservation of reasoning traces, Claude 4.5 Opus specifically has the capability to preserve and refer to previous thinking blocks. Filtering these out deprives Opus of valuable context about its previous reasoning steps.

The logic currently looks like this:

// internal/agent/generator.go
filterToolGen := NewBlockWhitelistFilter(toolGen, []string{gai.Content, gai.ToolCall})

It unconditionally excludes gai.Thinking.

Expected Behavior

If the model is Claude 4.5 Opus (e.g., ID claude-4-5-opus-20250224), the BlockWhitelistFilter should include gai.Thinking in the allowed types list, so that previous thinking traces are preserved in the conversation history sent to the API.

For other models, the current behavior (filtering thinking blocks) should likely persist unless they are also known to support this.

Steps to Reproduce

  1. Configure CPE to use claude-4-5-opus-20250224 with a thinking-budget enabled.
  2. Run a command that triggers reasoning/thinking.
  3. Continue the conversation (or inspect the logs/debug output if available).
  4. Observe that the previous "Thinking" block is not present in the context sent for the second turn.

Relevant Configuration

models:
  - name: opus
    id: claude-4-5-opus-20250224
    type: anthropic
    generationDefaults:
      thinkingBudget: "1024"

Environment

  • CPE version: (Current dev)
  • Go version: 1.25.1
  • OS: Linux

Additional Context

Reference code in internal/agent/generator.go:

// Wrap the tool generator with BlockWhitelistFilter to filter thinking blocks
// only from the initial dialog, but preserve them during tool execution
filterToolGen := NewBlockWhitelistFilter(toolGen, []string{gai.Content, gai.ToolCall})

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions