Back to Blog

Claude Opus 5.5 API: Fix Thinking Block Errors

Tutorials and Guides8514
Claude Opus 5.5 API: Fix Thinking Block Errors

A Claude API integration can continue returning successful responses after a model upgrade while quietly breaking an important part of the application.

The issue may not appear during ordinary conversations.

A simple request works. The model returns text. Authentication succeeds. The endpoint responds normally.

Then the application enters a multi-step tool workflow.

After the first tool call, the next request fails with a 400 error, loses part of its conversation state, or stops displaying progress between operations.

For developers migrating to Claude Opus 5.5, these symptoms deserve attention.

The model introduces several important changes to thinking behavior, tool selection, and conversation-history handling.

One particularly important change is that thinking blocks are now tied to the model and the conversation. Applications that previously reconstructed assistant messages or extracted only text content may no longer preserve the information required for subsequent tool interactions.

This guide explains how Claude Opus 5.5 handles thinking blocks, why multi-turn requests can fail, and how to design a more reliable tool-calling loop.

1. What Changed in Claude Opus 5.5 API?

Claude Opus 5.5 is designed for long-running agentic coding and knowledge-work tasks.

According to Anthropic's current model documentation, its API identifier is:

text
claude-opus-5-5

The published specifications include:

SpecificationValue
Model IDclaude-opus-5-5
Context window1 million tokens
Maximum output128,000 tokens
Input price$4 per million tokens
Output price$20 per million tokens
Thinking behaviorAdaptive thinking
Default effortMedium

For existing applications, the most important changes are not limited to the model's capabilities.

The request and response structures also need attention.

Four areas deserve particular consideration:

  1. Thinking can no longer be disabled using older settings.
  2. Forced tool selection using any or a named tool is not supported.
  3. Thinking blocks are tied to the model and conversation history.
  4. Some older computer-use tool versions are rejected.

There is also a response-format change that can affect applications displaying progress messages.

Text generated between tool calls can appear in thinking blocks instead of ordinary text blocks.

An application that reads only text blocks may therefore appear to stop responding between tool operations.

2. Why Thinking Blocks Must Be Preserved

In a conventional chat application, developers may assume that an assistant response is simply a string of text.

That assumption is not sufficient for a tool-enabled Claude application.

A response can contain multiple content blocks, including:

These blocks serve different purposes.

A tool-use block describes an operation the application needs to execute.

A thinking block carries model-specific conversational state.

A text block contains ordinary response content.

The application should not treat all three as interchangeable text.

A Common Implementation Mistake

Consider the following simplified approach:

python
assistant_text = "".join(
    block.text
    for block in response.content
    if block.type == "text"
)

This code extracts ordinary text but discards the other blocks.

That may be acceptable if the application only needs to display a final text response.

It is not sufficient for preserving a complete multi-turn tool interaction.

If the next request requires previous thinking blocks, removing them can cause problems.

Anthropic's documentation explicitly instructs developers to select content blocks according to their type and preserve thinking blocks unchanged when returning them in tool-use loops.

The correct design is to retain the complete assistant response separately from the text displayed to the user.

3. Understanding the Thinking Block Prefix Check

One of the most important compatibility details concerns conversation history.

Anthropic documents that thinking blocks are associated with the model that generated them.

The API also checks whether content preceding a thinking block has changed.

This check includes:

If an application modifies this content while reusing an old thinking block, the request may no longer satisfy the expected prefix.

This can lead to a 400 error or the removal of incompatible blocks.

Why Rebuilding Conversation History Can Be Dangerous

Imagine a coding agent with the following history:

text
System Instructions
      |
      v
Tool Definitions
      |
      v
User Request
      |
      v
Assistant Thinking
      |
      v
Assistant Tool Call
      |
      v
Tool Result

Now suppose the application receives a tool result and reconstructs the conversation from scratch.

It may:

Even if the new conversation looks logically equivalent to a human, it may no longer preserve the original model-generated prefix.

A safer approach is to keep the conversation append-only.

When instructions need to change, use the documented mid-conversation system-message mechanism rather than silently rewriting earlier history.

This is particularly important for long-running coding agents that maintain hundreds of interactions.

4. Build a Safer Multi-Turn Tool-Calling Loop

The application should separate three responsibilities:

  1. Sending the request to Claude.
  2. Executing requested tools.
  3. Preserving the model's original conversation content.

The following Python example demonstrates the core structure.

Install the SDK:

bash
pip install -U anthropic

Configure the client:

python
import os
import anthropic

client = anthropic.Anthropic(
    api_key=os.environ["ANTHROPIC_API_KEY"]
)

Define a simple tool:

python
def get_project_status():
    return {
        "status": "running",
        "tests": "passed",
        "branch": "main"
    }

Register the tool:

python
tools = [
    {
        "name": "get_project_status",
        "description": "Retrieve the current project status.",
        "input_schema": {
            "type": "object",
            "properties": {},
            "required": [],
            "additionalProperties": False
        }
    }
]

Now send the first request:

python
messages = [
    {
        "role": "user",
        "content": "Check the project status."
    }
]

response = client.messages.create(
    model="claude-opus-5-5",
    max_tokens=4096,
    output_config={
        "effort": "medium"
    },
    tools=tools,
    messages=messages
)

Notice that the example does not attempt to disable thinking.

Claude Opus 5.5 uses adaptive thinking, and the effort setting controls reasoning depth.

Preserve the Original Assistant Response

After receiving the response, append the complete assistant content to the conversation.

python
assistant_content = [
    block.model_dump(exclude_none=True)
    for block in response.content
]

messages.append({
    "role": "assistant",
    "content": assistant_content
})

The important point is that the application does not rebuild the assistant message from its visible text alone.

It preserves the content-block structure returned by the SDK.

Execute the Tool

Next, process any tool-use blocks:

python
tool_results = []

for block in response.content:

    if block.type == "tool_use":

        if block.name == "get_project_status":
            result = get_project_status()

            tool_results.append({
                "type": "tool_result",
                "tool_use_id": block.id,
                "content": str(result)
            })

Return the tool results:

python
if tool_results:

    messages.append({
        "role": "user",
        "content": tool_results
    })

    next_response = client.messages.create(
        model="claude-opus-5-5",
        max_tokens=4096,
        output_config={
            "effort": "medium"
        },
        tools=tools,
        messages=messages
    )

    print(next_response.content)

This is a minimal demonstration of the message structure.

A production implementation should continue processing tool calls until the model returns a terminal response, support every registered tool, handle tool exceptions, and preserve the complete content-block history.

It should also avoid exposing internal thinking content directly to end users.

The key principle is to preserve protocol state while separately deciding what information belongs in the user interface.

5. Why Does the Application Stop Showing Progress Between Tool Calls?

Another change can produce a confusing user experience.

Claude Opus 5.5 can return text between tool calls in thinking blocks.

At the default display setting, the corresponding thinking field may be empty.

An application that streams only blocks with:

python
block.type == "text"

may therefore display nothing while the agent is preparing its next tool operation.

This does not necessarily mean that the API request has stalled.

The model may still be progressing through its workflow.

Developers should distinguish between:

If the application needs user-facing progress updates, review Anthropic's documented thinking.display behavior and progress-update configuration.

Do not expose private internal reasoning as a progress message. Present concise status information such as:

text
Reading project files...
Running the test suite...
Reviewing the failed test...
Preparing the final report...

This gives users visibility without treating internal model state as ordinary application text.

6. Handle Model Switching Carefully

Multi-model Agent applications introduce another compatibility challenge.

A conversation may begin with Claude Opus 5.5 and later switch to Claude Fable 5.2, or move from one model family to another.

However, not every model can read every earlier thinking block.

Anthropic's documentation provides explicit compatibility rules for model transitions.

For example:

Model TransitionEarlier Thinking State
Claude Opus 5 to Opus 5.5Supported
Claude Opus 5.5 to Fable 5.2Supported on specified Claude API and Google-managed routes
Claude Fable 5.2 to Opus 5.5Not supported
Opus 5.5 to unrelated model familiesNot supported

The exact behavior also depends on the platform carrying the conversation.

If the target model cannot read an earlier thinking block, the API may drop that block before the model receives it.

This means that switching models is not always equivalent to changing a model ID.

A Better Model Switching Strategy

For applications that need multiple providers, consider three approaches.

Approach 1: Start a new conversation

Use this when the next model does not support the existing reasoning history.

Pass a concise task summary and the relevant tool results instead.

Approach 2: Preserve compatible history

Use the original message structure when the target model supports the earlier thinking blocks.

Approach 3: Separate task state from model history

Store application state independently from the model conversation.

For example, a coding agent can maintain:

This allows a new model to continue the business task without pretending that it can inherit incompatible internal reasoning state.

7. Avoid Forced Tool-Calling Errors

Another common migration issue involves tool_choice.

Some older implementations force the model to call a particular tool using:

json
{
  "type": "any"
}

or:

json
{
  "type": "tool",
  "name": "get_project_status"
}

Claude Opus 5.5 does not support these forced tool-selection modes.

The API can return:

text
tool_choice: type "tool" and "any" are not supported for this model.

The documented alternatives are:

For example:

python
response = client.messages.create(
    model="claude-opus-5-5",
    max_tokens=4096,
    output_config={
        "effort": "medium"
    },
    tools=tools,
    tool_choice={
        "type": "auto"
    },
    messages=[
        {
            "role": "user",
            "content": """
            If project status information is needed,
            call the project status tool before answering.
            """
        }
    ]
)

This lets the model select the tool according to the request while avoiding the unsupported forced-selection mode.

If a workflow requires a strict structured result, validate the output in the application rather than assuming that the model will always select a specific tool.

8. Computer-Use Tool Compatibility

Developers using desktop or browser automation should also check tool versions.

Claude Opus 5.5 supports the documented:

text
computer_toolset_20260801

Some older computer-use configurations may be rejected by the Claude API.

For example, the computer_20251124 tool version can return a 400 error on the Claude API, although platform-specific exceptions exist, including the documented Amazon Bedrock compatibility path.

When migrating an existing computer-use application, check:

Do not assume that an older tool schema remains valid simply because the model can still perform computer-use tasks.

9. Connect Claude Through a Unified API Access Layer

For developers managing Claude alongside GPT, Gemini, DeepSeek, and other model families, endpoint configuration can become another maintenance task.

An API gateway can provide a centralized model access layer, but protocol compatibility needs to be checked carefully.

Claude Messages API is not simply identical to OpenAI Chat Completions.

In particular, the application needs to preserve:

4SAPI provides support for Anthropic-compatible API integration as part of its multi-model gateway architecture.

For a Claude Opus 5.5 deployment, verify that the selected route preserves the required Anthropic Messages request and response structures.

Do not assume that translating every request into a generic chat message is sufficient for a multi-turn Agent workflow.

A gateway should simplify connectivity, not silently discard protocol information required by the application.

10. Production Validation Checklist

Before deploying a Claude Opus 5.5 application, review these items:

Frequently Asked Questions

Why does Claude Opus 5.5 return an empty thinking field?

The default display configuration can omit visible thinking content. The presence of a thinking block should not be interpreted as an ordinary text response. Preserve the block according to the API documentation.

Can I remove thinking blocks to reduce API usage?

Do not remove them indiscriminately from a conversation that will continue using the same model state. The API may require them for valid multi-turn history. Follow the documented model and conversation rules.

Why does a request work without tools but fail when tools are enabled?

Tool use introduces additional content blocks and message-history requirements. Check the request's tool_choice, tool schema, previous thinking blocks, and message ordering.

Can I use Claude Opus 5.5 with an OpenAI-compatible API gateway?

A gateway may provide multiple protocol interfaces, but the specific Anthropic Messages route and its supported features must be verified. Basic text compatibility does not guarantee full tool-use compatibility.

Does switching to another model preserve the same thinking history?

Not necessarily. Thinking blocks are associated with the model that produced them. Consult the official compatibility rules before switching models in an active conversation.

Conclusion

Claude Opus 5.5 requires developers to pay closer attention to the structure of multi-turn API conversations.

The most important lesson is that an assistant response is not always just a text string.

Thinking blocks, tool-use blocks, and tool results form part of the application's conversational state. Removing or reconstructing them without respecting the API's rules can create failures that are difficult to diagnose.

For production Agent systems, preserve the original content-block structure, keep conversation history consistent, validate tool-selection behavior, and treat model switching as a compatibility decision.

These practices make it easier to maintain reliable Claude integrations while retaining the flexibility to manage multiple model providers through a shared API access layer.

Further Reading

Official Anthropic documentation

  1. Claude Opus 5.5 Model Overview
  2. Claude Opus 5.5 Migration Guide
  3. What's New in Claude Opus 5.5
  4. Anthropic Messages API
  5. Anthropic Tool Use Documentation
  6. Anthropic Thinking Documentation
  7. Anthropic Model Versioning

Related 4SAPI articles

Tags:Claude Opus 5.5Anthropic APITool CallingThinking BlocksAI Agents

Recommended reading

Explore more frontier insights and industry know-how.