Home / Function/ test_agent_invalid_tool() — langchain Function Reference

test_agent_invalid_tool() — langchain Function Reference

Architecture documentation for the test_agent_invalid_tool() function in test_agent.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  483920ca_45b5_e175_e86e_129ba5d2e45f["test_agent_invalid_tool()"]
  47a7b285_8e60_f78f_282d_429958c446fa["test_agent.py"]
  483920ca_45b5_e175_e86e_129ba5d2e45f -->|defined in| 47a7b285_8e60_f78f_282d_429958c446fa
  style 483920ca_45b5_e175_e86e_129ba5d2e45f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/tests/unit_tests/agents/test_agent.py lines 426–449

def test_agent_invalid_tool() -> None:
    """Test agent invalid tool and correct suggestions."""
    fake_llm = FakeListLLM(responses=["FooBarBaz\nAction: Foo\nAction Input: Bar"])
    tools = [
        Tool(
            name="Search",
            func=lambda x: x,
            description="Useful for searching",
            return_direct=True,
        ),
    ]
    agent = initialize_agent(
        tools=tools,
        llm=fake_llm,
        agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
        return_intermediate_steps=True,
        max_iterations=1,
    )

    resp = agent("when was langchain made")
    assert (
        resp["intermediate_steps"][0][1]
        == "Foo is not a valid tool, try one of [Search]."
    )

Domain

Subdomains

Frequently Asked Questions

What does test_agent_invalid_tool() do?
test_agent_invalid_tool() is a function in the langchain codebase, defined in libs/langchain/tests/unit_tests/agents/test_agent.py.
Where is test_agent_invalid_tool() defined?
test_agent_invalid_tool() is defined in libs/langchain/tests/unit_tests/agents/test_agent.py at line 426.

Analyze Your Own Codebase

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

Try Supermodel Free