Home / Function/ test_tool_allows_extra_runtime_args_with_custom_schema() — langchain Function Reference

test_tool_allows_extra_runtime_args_with_custom_schema() — langchain Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

libs/core/tests/unit_tests/test_tools.py lines 2414–2441

def test_tool_allows_extra_runtime_args_with_custom_schema(
    schema_format: Literal["model", "json_schema"],
) -> None:
    """Ensure runtime args are preserved even if not in the args schema."""

    class InputSchema(BaseModel):
        query: str

    captured: dict[str, Any] = {}

    @dataclass
    class MyRuntime(_DirectlyInjectedToolArg):
        some_obj: object

    args_schema = (
        InputSchema if schema_format == "model" else InputSchema.model_json_schema()
    )

    @tool(args_schema=args_schema)
    def runtime_tool(query: str, runtime: MyRuntime) -> str:
        """Echo the query and capture runtime value."""
        captured["runtime"] = runtime
        return query

    runtime_obj = object()
    runtime = MyRuntime(some_obj=runtime_obj)
    assert runtime_tool.invoke({"query": "hello", "runtime": runtime}) == "hello"
    assert captured["runtime"] is runtime

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free