Home / Function/ test_tool_search_beta_headers() — langchain Function Reference

test_tool_search_beta_headers() — langchain Function Reference

Architecture documentation for the test_tool_search_beta_headers() function in test_chat_models.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  2686836f_8150_ac47_0585_17ce797aff2e["test_tool_search_beta_headers()"]
  18428dc5_a41b_90c6_88ad_615296ee3311["test_chat_models.py"]
  2686836f_8150_ac47_0585_17ce797aff2e -->|defined in| 18428dc5_a41b_90c6_88ad_615296ee3311
  style 2686836f_8150_ac47_0585_17ce797aff2e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/anthropic/tests/unit_tests/test_chat_models.py lines 1831–1872

def test_tool_search_beta_headers() -> None:
    """Test that tool search tools auto-append the correct beta headers."""
    # Test regex variant
    model = ChatAnthropic(model=MODEL_NAME)  # type: ignore[call-arg]
    regex_tool = {
        "type": "tool_search_tool_regex_20251119",
        "name": "tool_search_tool_regex",
    }
    model_with_tools = model.bind_tools([regex_tool])
    payload = model_with_tools._get_request_payload(  # type: ignore[attr-defined]
        "test",
        **model_with_tools.kwargs,  # type: ignore[attr-defined]
    )
    assert payload["betas"] == ["advanced-tool-use-2025-11-20"]

    # Test BM25 variant
    model = ChatAnthropic(model=MODEL_NAME)  # type: ignore[call-arg]
    bm25_tool = {
        "type": "tool_search_tool_bm25_20251119",
        "name": "tool_search_tool_bm25",
    }
    model_with_tools = model.bind_tools([bm25_tool])
    payload = model_with_tools._get_request_payload(  # type: ignore[attr-defined]
        "test",
        **model_with_tools.kwargs,  # type: ignore[attr-defined]
    )
    assert payload["betas"] == ["advanced-tool-use-2025-11-20"]

    # Test merging with existing betas
    model = ChatAnthropic(
        model=MODEL_NAME,
        betas=["mcp-client-2025-04-04"],  # type: ignore[call-arg]
    )
    model_with_tools = model.bind_tools([regex_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",
        "advanced-tool-use-2025-11-20",
    ]

Domain

Subdomains

Frequently Asked Questions

What does test_tool_search_beta_headers() do?
test_tool_search_beta_headers() is a function in the langchain codebase, defined in libs/partners/anthropic/tests/unit_tests/test_chat_models.py.
Where is test_tool_search_beta_headers() defined?
test_tool_search_beta_headers() is defined in libs/partners/anthropic/tests/unit_tests/test_chat_models.py at line 1831.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free