Home / Function/ test_agent_tool_return_direct_in_intermediate_steps() — langchain Function Reference

test_agent_tool_return_direct_in_intermediate_steps() — langchain Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

libs/langchain/tests/unit_tests/agents/test_agent.py lines 342–370

def test_agent_tool_return_direct_in_intermediate_steps() -> None:
    """Test agent using tools that return directly."""
    tool = "Search"
    responses = [
        f"FooBarBaz\nAction: {tool}\nAction Input: misalignment",
        "Oh well\nFinal Answer: curses foiled again",
    ]
    fake_llm = FakeListLLM(responses=responses)
    tools = [
        Tool(
            name="Search",
            func=lambda x: x,
            description="Useful for searching",
            return_direct=True,
        ),
    ]
    agent = initialize_agent(
        tools,
        fake_llm,
        agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
        return_intermediate_steps=True,
    )

    resp = agent("when was langchain made")
    assert isinstance(resp, dict)
    assert resp["output"] == "misalignment"
    assert len(resp["intermediate_steps"]) == 1
    action, _action_intput = resp["intermediate_steps"][0]
    assert action.tool == "Search"

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free