Skip to content

Fix thinking block handling in message construction causing 400 errors #12

@bigboateng

Description

@bigboateng

Bug Report

Description

The browseragent library fails when thinkingBudget is used due to improper thinking block handling in message construction, causing 400 errors from Anthropic's API.

Error Message

400 {"type":"error","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.anthropic.com/en/docs/build-with-claude/extended-thinking"}}

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions