Home / Function/ test_builtin_tools_computer_use() — langchain Function Reference

test_builtin_tools_computer_use() — langchain Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

libs/partners/anthropic/tests/integration_tests/test_chat_models.py lines 585–623

def test_builtin_tools_computer_use() -> None:
    """Test computer use tool integration.

    Beta header should be automatically appended based on tool type.

    This test only verifies tool call generation.
    """
    llm = ChatAnthropic(
        model="claude-sonnet-4-5-20250929",  # type: ignore[call-arg]
    )
    tool = {
        "type": "computer_20250124",
        "name": "computer",
        "display_width_px": 1024,
        "display_height_px": 768,
        "display_number": 1,
    }
    llm_with_tools = llm.bind_tools([tool])
    response = llm_with_tools.invoke(
        "Can you take a screenshot to see what's on the screen?",
    )
    assert isinstance(response, AIMessage)
    assert response.tool_calls

    content_blocks = response.content_blocks
    assert len(content_blocks) >= 2
    assert content_blocks[0]["type"] == "text"
    assert content_blocks[0]["text"]

    # Check that we have a tool_call for computer use
    tool_call_blocks = [b for b in content_blocks if b["type"] == "tool_call"]
    assert len(tool_call_blocks) >= 1
    assert tool_call_blocks[0]["name"] == "computer"

    # Verify tool call has expected action (screenshot in this case)
    tool_call = response.tool_calls[0]
    assert tool_call["name"] == "computer"
    assert "action" in tool_call["args"]
    assert tool_call["args"]["action"] == "screenshot"

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free