Home / Function/ test_tool_injected_tool_call_id_with_custom_schema() — langchain Function Reference

test_tool_injected_tool_call_id_with_custom_schema() — langchain Function Reference

Architecture documentation for the test_tool_injected_tool_call_id_with_custom_schema() function in test_tools.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  ce3caf8d_002a_1ac0_ca08_38c0eefc0b0c["test_tool_injected_tool_call_id_with_custom_schema()"]
  8e7836ae_e72c_f670_72a5_4ca6d46e3555["test_tools.py"]
  ce3caf8d_002a_1ac0_ca08_38c0eefc0b0c -->|defined in| 8e7836ae_e72c_f670_72a5_4ca6d46e3555
  2e3e4f6c_89c9_ecff_fc2e_2cff26c11792["injected_tool()"]
  ce3caf8d_002a_1ac0_ca08_38c0eefc0b0c -->|calls| 2e3e4f6c_89c9_ecff_fc2e_2cff26c11792
  style ce3caf8d_002a_1ac0_ca08_38c0eefc0b0c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/test_tools.py lines 2444–2478

def test_tool_injected_tool_call_id_with_custom_schema() -> None:
    """Ensure InjectedToolCallId works with custom args schema."""

    class InputSchema(BaseModel):
        x: int

    @tool(args_schema=InputSchema)
    def injected_tool(
        x: int, tool_call_id: Annotated[str, InjectedToolCallId]
    ) -> ToolMessage:
        """Tool with injected tool_call_id and custom schema."""
        return ToolMessage(str(x), tool_call_id=tool_call_id)

    # Test that tool_call_id is properly injected even though not in custom schema
    result = injected_tool.invoke(
        {
            "type": "tool_call",
            "args": {"x": 42},
            "name": "injected_tool",
            "id": "test_call_id",
        }
    )
    assert result == ToolMessage("42", tool_call_id="test_call_id")

    # Test that it still raises error when invoked without a ToolCall
    with pytest.raises(
        ValueError,
        match="When tool includes an InjectedToolCallId argument, "
        "tool must always be invoked with a full model ToolCall",
    ):
        injected_tool.invoke({"x": 42})

    # Test that tool_call_id can be passed directly in input dict
    result = injected_tool.invoke({"x": 42, "tool_call_id": "direct_id"})
    assert result == ToolMessage("42", tool_call_id="direct_id")

Domain

Subdomains

Frequently Asked Questions

What does test_tool_injected_tool_call_id_with_custom_schema() do?
test_tool_injected_tool_call_id_with_custom_schema() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/test_tools.py.
Where is test_tool_injected_tool_call_id_with_custom_schema() defined?
test_tool_injected_tool_call_id_with_custom_schema() is defined in libs/core/tests/unit_tests/test_tools.py at line 2444.
What does test_tool_injected_tool_call_id_with_custom_schema() call?
test_tool_injected_tool_call_id_with_custom_schema() calls 1 function(s): injected_tool.

Analyze Your Own Codebase

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

Try Supermodel Free