Home / Function/ test_filter_tool_runtime_directly_injected_arg() — langchain Function Reference

test_filter_tool_runtime_directly_injected_arg() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  6f3b21f2_3c1e_331d_1ea6_996a7e4d02b5["test_filter_tool_runtime_directly_injected_arg()"]
  8e7836ae_e72c_f670_72a5_4ca6d46e3555["test_tools.py"]
  6f3b21f2_3c1e_331d_1ea6_996a7e4d02b5 -->|defined in| 8e7836ae_e72c_f670_72a5_4ca6d46e3555
  style 6f3b21f2_3c1e_331d_1ea6_996a7e4d02b5 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/test_tools.py lines 3165–3205

def test_filter_tool_runtime_directly_injected_arg() -> None:
    """Test that ToolRuntime (a _DirectlyInjectedToolArg) is filtered."""

    @tool
    def tool_with_runtime(query: str, limit: int, runtime: ToolRuntime) -> str:
        """Tool with ToolRuntime parameter.

        Args:
            query: The search query.
            limit: Max results.
            runtime: The tool runtime (directly injected).
        """
        return f"Query: {query}, Limit: {limit}"

    handler = CallbackHandlerWithInputCapture(captured_inputs=[])

    result = tool_with_runtime.invoke(
        {
            "query": "test",
            "limit": 5,
            "runtime": ToolRuntime(
                context={},
                state={},
                config={},
                stream_writer=lambda _: None,
                tool_call_id=None,
                store=None,
            ),
        },
        config={"callbacks": [handler]},
    )

    assert result == "Query: test, Limit: 5"
    assert handler.tool_starts == 1
    assert len(handler.captured_inputs) == 1

    # Verify that ToolRuntime is filtered out
    captured = handler.captured_inputs[0]
    assert captured is not None
    assert captured == {"query": "test", "limit": 5}
    assert "runtime" not in captured

Domain

Subdomains

Frequently Asked Questions

What does test_filter_tool_runtime_directly_injected_arg() do?
test_filter_tool_runtime_directly_injected_arg() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/test_tools.py.
Where is test_filter_tool_runtime_directly_injected_arg() defined?
test_filter_tool_runtime_directly_injected_arg() is defined in libs/core/tests/unit_tests/test_tools.py at line 3165.

Analyze Your Own Codebase

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

Try Supermodel Free