Home / Function/ test_wrap_tool_call_modify_args() — langchain Function Reference

test_wrap_tool_call_modify_args() — langchain Function Reference

Architecture documentation for the test_wrap_tool_call_modify_args() function in test_wrap_tool_call.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  4dd0e1f6_a71d_6048_57d5_9b4b42c8a357["test_wrap_tool_call_modify_args()"]
  e783c6bd_e3d7_7d3b_e64d_d062c5c12013["test_wrap_tool_call.py"]
  4dd0e1f6_a71d_6048_57d5_9b4b42c8a357 -->|defined in| e783c6bd_e3d7_7d3b_e64d_d062c5c12013
  style 4dd0e1f6_a71d_6048_57d5_9b4b42c8a357 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_tool_call.py lines 115–149

def test_wrap_tool_call_modify_args() -> None:
    """Test modifying tool arguments with wrap_tool_call decorator."""

    @wrap_tool_call
    def modify_args(
        request: ToolCallRequest, handler: Callable[[ToolCallRequest], ToolMessage | Command[Any]]
    ) -> ToolMessage | Command[Any]:
        assert isinstance(request.tool, BaseTool)
        # Modify the query argument before execution
        if request.tool.name == "search":
            request.tool_call["args"]["query"] = "modified query"
        return handler(request)

    model = FakeToolCallingModel(
        tool_calls=[
            [ToolCall(name="search", args={"query": "original"}, id="1")],
            [],
        ]
    )

    agent = create_agent(
        model=model,
        tools=[search],
        middleware=[modify_args],
        checkpointer=InMemorySaver(),
    )

    result = agent.invoke(
        {"messages": [HumanMessage("Search")]},
        {"configurable": {"thread_id": "test"}},
    )

    tool_messages = [m for m in result["messages"] if isinstance(m, ToolMessage)]
    assert len(tool_messages) == 1
    assert "modified query" in tool_messages[0].content

Domain

Subdomains

Frequently Asked Questions

What does test_wrap_tool_call_modify_args() do?
test_wrap_tool_call_modify_args() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_tool_call.py.
Where is test_wrap_tool_call_modify_args() defined?
test_wrap_tool_call_modify_args() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_tool_call.py at line 115.

Analyze Your Own Codebase

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

Try Supermodel Free