Home / Function/ test_structured_output_thinking_force_tool_use() — langchain Function Reference

test_structured_output_thinking_force_tool_use() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  c856a71d_5853_ee2c_98e1_1beb111327f8["test_structured_output_thinking_force_tool_use()"]
  f27640dd_3870_5548_d153_f9504ae1021f["test_chat_models.py"]
  c856a71d_5853_ee2c_98e1_1beb111327f8 -->|defined in| f27640dd_3870_5548_d153_f9504ae1021f
  style c856a71d_5853_ee2c_98e1_1beb111327f8 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/anthropic/tests/integration_tests/test_chat_models.py lines 1178–1191

def test_structured_output_thinking_force_tool_use() -> None:
    # Structured output currently relies on forced tool use, which is not supported
    # when `thinking` is enabled. When this test fails, it means that the feature
    # is supported and the workarounds in `with_structured_output` should be removed.
    llm = ChatAnthropic(
        model="claude-sonnet-4-5-20250929",  # type: ignore[call-arg]
        max_tokens=5_000,  # type: ignore[call-arg]
        thinking={"type": "enabled", "budget_tokens": 2_000},
    ).bind_tools(
        [GenerateUsername],
        tool_choice="GenerateUsername",
    )
    with pytest.raises(BadRequestError):
        llm.invoke("Generate a username for Sally with green hair")

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free