test_auto_append_betas_for_tool_types() — langchain Function Reference
Architecture documentation for the test_auto_append_betas_for_tool_types() function in test_chat_models.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD fbaaa844_8741_3989_02db_4a50ffe60fbf["test_auto_append_betas_for_tool_types()"] 18428dc5_a41b_90c6_88ad_615296ee3311["test_chat_models.py"] fbaaa844_8741_3989_02db_4a50ffe60fbf -->|defined in| 18428dc5_a41b_90c6_88ad_615296ee3311 style fbaaa844_8741_3989_02db_4a50ffe60fbf fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/anthropic/tests/unit_tests/test_chat_models.py lines 1731–1803
def test_auto_append_betas_for_tool_types() -> None:
"""Test that betas are automatically appended based on tool types."""
# Test web_fetch_20250910 auto-appends web-fetch-2025-09-10
model = ChatAnthropic(model=MODEL_NAME) # type: ignore[call-arg]
tool = {"type": "web_fetch_20250910", "name": "web_fetch", "max_uses": 3}
model_with_tools = model.bind_tools([tool])
payload = model_with_tools._get_request_payload( # type: ignore[attr-defined]
"test",
**model_with_tools.kwargs, # type: ignore[attr-defined]
)
assert payload["betas"] == ["web-fetch-2025-09-10"]
# Test code_execution_20250522 auto-appends code-execution-2025-05-22
model = ChatAnthropic(model=MODEL_NAME) # type: ignore[call-arg]
tool = {"type": "code_execution_20250522", "name": "code_execution"}
model_with_tools = model.bind_tools([tool])
payload = model_with_tools._get_request_payload( # type: ignore[attr-defined]
"test",
**model_with_tools.kwargs, # type: ignore[attr-defined]
)
assert payload["betas"] == ["code-execution-2025-05-22"]
# Test memory_20250818 auto-appends context-management-2025-06-27
model = ChatAnthropic(model=MODEL_NAME) # type: ignore[call-arg]
tool = {"type": "memory_20250818", "name": "memory"}
model_with_tools = model.bind_tools([tool])
payload = model_with_tools._get_request_payload( # type: ignore[attr-defined]
"test",
**model_with_tools.kwargs, # type: ignore[attr-defined]
)
assert payload["betas"] == ["context-management-2025-06-27"]
# Test merging with existing betas
model = ChatAnthropic(
model=MODEL_NAME,
betas=["mcp-client-2025-04-04"], # type: ignore[call-arg]
)
tool = {"type": "web_fetch_20250910", "name": "web_fetch"}
model_with_tools = model.bind_tools([tool])
payload = model_with_tools._get_request_payload( # type: ignore[attr-defined]
"test",
**model_with_tools.kwargs, # type: ignore[attr-defined]
)
assert payload["betas"] == ["mcp-client-2025-04-04", "web-fetch-2025-09-10"]
# Test that it doesn't duplicate existing betas
model = ChatAnthropic(
model=MODEL_NAME,
betas=["web-fetch-2025-09-10"], # type: ignore[call-arg]
)
tool = {"type": "web_fetch_20250910", "name": "web_fetch"}
model_with_tools = model.bind_tools([tool])
payload = model_with_tools._get_request_payload( # type: ignore[attr-defined]
"test",
**model_with_tools.kwargs, # type: ignore[attr-defined]
)
assert payload["betas"] == ["web-fetch-2025-09-10"]
# Test multiple tools with different beta requirements
model = ChatAnthropic(model=MODEL_NAME) # type: ignore[call-arg]
tools = [
{"type": "web_fetch_20250910", "name": "web_fetch"},
{"type": "code_execution_20250522", "name": "code_execution"},
]
model_with_tools = model.bind_tools(tools)
payload = model_with_tools._get_request_payload( # type: ignore[attr-defined]
"test",
**model_with_tools.kwargs, # type: ignore[attr-defined]
)
assert set(payload["betas"]) == {
"web-fetch-2025-09-10",
"code-execution-2025-05-22",
}
Domain
Subdomains
Source
Frequently Asked Questions
What does test_auto_append_betas_for_tool_types() do?
test_auto_append_betas_for_tool_types() is a function in the langchain codebase, defined in libs/partners/anthropic/tests/unit_tests/test_chat_models.py.
Where is test_auto_append_betas_for_tool_types() defined?
test_auto_append_betas_for_tool_types() is defined in libs/partners/anthropic/tests/unit_tests/test_chat_models.py at line 1731.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free