Skip to content

invalid_request_error when using Code Interpreter with Claude extended thinking enabled #10577

@agluo

Description

@agluo

📱 Client Type

Web (Desktop Browser)

💻 Operating System

Windows

📦 Deployment Platform

Self hosting Docker

🔧 Deployment Mode

server db (lobe-chat-database image)

📌 Version

v2.0.0-next.147

🌐 Browser

Edge

🐛 Bug Description

Description

Getting an invalid_request_error from Anthropic API when trying to execute Python code using the Code Interpreter with Claude Haiku (claude-haiku-4-5-20251001).

Image

Error Message

{
  "error": {
    "type": "invalid_request_error",
    "message": "messages.1.content.0.type: Expected `thinking` or `redacted_thinking`, but found `text`. When `thinking` is enabled, a final `assistant` message must start with a thinking block (preceeding the lastmost set of `tool_use` and `tool_result` blocks). We recommend you include thinking blocks from previous turns. To avoid this requirement, disable `thinking`. Please consult our documentation at https://docs.claude.com/en/docs/build-with-claude/extended-thinking"
  },
  "endpoint": "https://api.anthropic.com",
  "provider": "anthropic"
}

顺带一提,其他插件也会报错

📷 Recurrence Steps

  1. Use Claude Haiku model (claude-haiku-4-5-20251001) with extended thinking enabled
  2. Request to write and execute a Python program via Code Interpreter
  3. Example prompt: "写一段python程序计算第15个素数,并且用插件运行" (Write a Python program to calculate the 15th prime number and run it with the plugin)
  4. Error occurs when trying to execute

🚦 Expected Behavior

The Code Interpreter should execute the Python code successfully without API errors.

📝 Additional Information

Image

🛠️ Willing to Submit a PR?

No, but I am happy to help test the fix

✅ Validations

  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Make sure this is a LobeChat issue and not a third-party library or provider issue.
  • Check that this is a concrete bug. For Q&A, please use GitHub Discussions or join our Discord Server.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions