Skip to content
Merged
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
578ef5e
feat(anthropic): auto append relevant beta headers
mdrxy Nov 27, 2025
1ab885d
Merge branch 'master' into mdrxy/anthropic-auto-append-betas
mdrxy Nov 27, 2025
aec99a5
feat(anthropic,model-profiles): add `effort` support
mdrxy Nov 27, 2025
d084a72
Merge branch 'mdrxy/anthropic-auto-append-betas' into mdrxy/effort-an…
mdrxy Nov 27, 2025
e54a43a
int test
mdrxy Nov 27, 2025
7d5efe0
fix ext tests
mdrxy Nov 27, 2025
2d4c362
.
mdrxy Nov 27, 2025
a6a08ad
.
mdrxy Nov 27, 2025
a28f96d
feat(anthropic): tool search support
mdrxy Nov 27, 2025
e255ce4
docs
mdrxy Nov 27, 2025
05eedf5
feat(core,anthropic): `extras` on `BaseTool`
mdrxy Nov 27, 2025
43a2253
fix hardcoding
mdrxy Nov 28, 2025
dbd85ea
Merge branch 'mdrxy/effort-anthropic' into mdrxy/tool-search-thropic
mdrxy Nov 28, 2025
4e8cdf2
Merge branch 'master' into mdrxy/tool-search-thropic
ccurme Dec 5, 2025
31349e6
revert some changes
ccurme Dec 5, 2025
6de4e66
tests nits
ccurme Dec 8, 2025
211a443
Merge branch 'mdrxy/tool-search-thropic' into mdrxy/extras-suppport
ccurme Dec 8, 2025
870ed37
Merge branch 'master' into mdrxy/extras-suppport
ccurme Dec 8, 2025
3824ab9
let anthropic validate value types
ccurme Dec 8, 2025
fc25413
translate within convert_to_anthropic_tool
ccurme Dec 8, 2025
7509f96
update integration test
ccurme Dec 8, 2025
26b2d85
docstring nit
ccurme Dec 8, 2025
b75a2d7
Merge branch 'master' into mdrxy/extras-suppport
mdrxy Dec 8, 2025
5b1ace0
Merge branch 'master' into mdrxy/extras-suppport
mdrxy Dec 9, 2025
7880326
nits/fix `input_examples`
mdrxy Dec 9, 2025
4695c5c
Merge branch 'master' into mdrxy/extras-suppport
mdrxy Dec 9, 2025
8a7cd97
feat(anthropic): support programmatic tool use (#34271)
ccurme Dec 10, 2025
bbc4be4
first pass
mdrxy Dec 10, 2025
f0bda76
docs
mdrxy Dec 10, 2025
3c279ad
Merge branch 'master' into mdrxy/extras-suppport
mdrxy Dec 10, 2025
ac2e103
Merge remote-tracking branch 'origin/mdrxy/extras-suppport' into mdrx…
mdrxy Dec 10, 2025
8aea30a
cr
mdrxy Dec 10, 2025
f72ee5a
Merge remote-tracking branch 'origin/master' into mdrxy/thropic-tool-…
mdrxy Dec 10, 2025
05fd612
fix mcp docstring
mdrxy Dec 10, 2025
fc4e4bf
remove types
mdrxy Dec 10, 2025
127db00
feat(anthropic): executable callbacks on tools (#34281)
mdrxy Dec 11, 2025
b1bbd5f
cr
mdrxy Dec 11, 2025
57b3e1b
cr
mdrxy Dec 11, 2025
c91c0ae
cr
mdrxy Dec 11, 2025
0805b1f
Merge branch 'master' into mdrxy/thropic-tool-types
mdrxy Dec 11, 2025
dfa34d0
Merge branch 'master' into mdrxy/thropic-tool-types
mdrxy Dec 11, 2025
c01e073
Merge branch 'master' into mdrxy/thropic-tool-types
mdrxy Dec 11, 2025
528bb13
undo docstring examples
mdrxy Dec 11, 2025
d7c0883
Merge branch 'master' into mdrxy/thropic-tool-types
mdrxy Dec 11, 2025
adcf07e
Merge branch 'master' into mdrxy/thropic-tool-types
mdrxy Dec 11, 2025
71276b3
widen type to
mdrxy Dec 11, 2025
21d9d3d
update docstring
mdrxy Dec 11, 2025
155b147
Merge branch 'master' into mdrxy/thropic-tool-types
mdrxy Dec 11, 2025
a8eb56a
comments
mdrxy Dec 11, 2025
2ac4641
Merge branch 'master' into mdrxy/thropic-tool-types
mdrxy Dec 11, 2025
5121a88
Merge branch 'master' into mdrxy/thropic-tool-types
mdrxy Dec 12, 2025
d614934
cr
mdrxy Dec 12, 2025
ee2ba56
delete tools
mdrxy Dec 12, 2025
f8db482
cr
mdrxy Dec 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions libs/partners/anthropic/langchain_anthropic/chat_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2482,7 +2482,7 @@ def _raise_if_no_tool_calls(message: AIMessage) -> AIMessage:

def bind_tools(
self,
tools: Sequence[dict[str, Any] | type | Callable | BaseTool],
tools: Sequence[Mapping[str, Any] | type | Callable | BaseTool],
*,
tool_choice: dict[str, str] | str | None = None,
parallel_tool_calls: bool | None = None,
Expand Down Expand Up @@ -2758,6 +2758,9 @@ def get_weather(location: str) -> str:
See LangChain [docs](https://docs.langchain.com/oss/python/integrations/chat/anthropic#strict-tool-use)
for more detail.
""" # noqa: E501
# Allows built-in tools either by their:
# - Raw `dict` format
# - Extracting extras["provider_tool_definition"] if provided on a BaseTool
formatted_tools = [
tool
if _is_builtin_tool(tool)
Expand Down Expand Up @@ -2984,6 +2987,8 @@ class AnswerWithJustification(BaseModel):

if method == "function_calling":
formatted_tool = cast(AnthropicTool, convert_to_anthropic_tool(schema))
# The result of convert_to_anthropic_tool for 'method=function_calling' will
# always be an AnthropicTool
tool_name = formatted_tool["name"]
if self.thinking is not None and self.thinking.get("type") == "enabled":
llm = self._get_llm_for_structured_output_when_thinking_is_enabled(
Expand Down Expand Up @@ -3131,7 +3136,7 @@ def get_weather(location: str) -> str:


def convert_to_anthropic_tool(
tool: dict[str, Any] | type | Callable | BaseTool,
tool: Mapping[str, Any] | type | Callable | BaseTool,
*,
strict: bool | None = None,
) -> AnthropicTool:
Expand All @@ -3149,6 +3154,15 @@ def convert_to_anthropic_tool(
Returns:
`AnthropicTool` for custom/user-defined tools
"""
if (
isinstance(tool, BaseTool)
and hasattr(tool, "extras")
and isinstance(tool.extras, dict)
and "provider_tool_definition" in tool.extras
):
# Pass through built-in tool definitions
return tool.extras["provider_tool_definition"] # type: ignore[return-value]

if isinstance(tool, dict) and all(
k in tool for k in ("name", "description", "input_schema")
):
Expand Down
Loading