AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

ChatAnthropic.Bind_tools() Fails On Anthropic Browser_toolset_20260801 And Drops Toolset_name Metadata

ChatAnthropic incorrectly routes the documented browser_toolset_20260801 client toolset through JSON-schema conversion, raising ValueError. Non-null toolset_name on tool_use blocks is lost in multi-turn requests, and ordinary tool calls expose toolset_name=None.

highConfidence 89%Langchain-AnthropicAffected Vlangchain-Anthropic==1.7.2Affected Vlangchain-Core==1.6.4Affected Vanthropic==1.1.0Fixed Vlangchain-Anthropic>=1.7.3

Origin Analysis

The _BUILTIN_TOOL_PREFIXES tuple lacks 'browser_toolset_', so _is_builtin_tool() returns False and bind_tools treats the client toolset as a conventional tool/JSON schema. Additionally, _format_output() retains toolset_name=None for all tool_use blocks instead of omitting it, and _format_messages()/ToolMessage conversion do not propagate non-null toolset_name from AIMessage.content to Anthropic tool_use/tool_result blocks.
1. Instantiate ChatAnthropic(model='claude-sonnet-4-5-20250929').\n2. Call model.bind_tools([{'type':'browser_toolset_20260801','configs':{'javascript_exec':{'enabled':True}}}])\n3. Observe ValueError: Unsupported function.\n4. Send a multi-turn request with an AIMessage containing a tool_use block with toolset_name='computer' and a paired ToolMessage.\n5. Inspect request payload to see toolset_name missing and tool_result lacking toolset_name.\n6. Run a plain tool call through _format_output and observe toolset_name: None.

Fixing Code Block

Edge Case Audit

This patch relies on anthropic SDK >= version that includes toolset_name on ToolUseBlock (likely 1.0+). If older SDK lacks toolset_name, getattr returns None and behavior is unchanged, but toolset feature won't work; ensure anthropic>=1.1.0. The browser_toolset_ prefix may cause any custom tool definition whose name starts with browser_toolset_ to bypass normal conversion—this is intended for client toolsets but could mask malformed regular tools in that namespace. The reverse search stops at HumanMessage, but if a tool_call_id is reused across multiple tool results in the same assistant turn, the first match from the end is used; that is usually correct because each tool_use id should be unique per turn. Concurrency/streaming: _format_output is per response and thread-safe; _format_messages is per request and no shared mutable state. Rollback: remove browser_toolset_ from _BUILTIN_TOOL_PREFIXES and revert _format_output/_format_messages tool_use/tool_result dict construction to previous versions. Test with computer_toolset_20260801, browser_toolset_20260801, ordinary tool with no toolset_name, and multi-turn toolset where tool_result echoes toolset_name.

Ecosystem Topology