test_agent_iterator_failing_tool() — langchain Function Reference
Architecture documentation for the test_agent_iterator_failing_tool() function in test_agent_iterator.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD c45b4c9f_777c_d824_994d_4d769a269faa["test_agent_iterator_failing_tool()"] 2423e003_42f4_7c6a_3fba_30db54c07a0c["test_agent_iterator.py"] c45b4c9f_777c_d824_994d_4d769a269faa -->|defined in| 2423e003_42f4_7c6a_3fba_30db54c07a0c style c45b4c9f_777c_d824_994d_4d769a269faa fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/tests/unit_tests/agents/test_agent_iterator.py lines 355–386
def test_agent_iterator_failing_tool() -> None:
"""Test AgentExecutorIterator with a tool that raises an exception."""
# Get agent for testing.
bad_action_name = "FailingTool"
responses = [
f"I'm turning evil\nAction: {bad_action_name}\nAction Input: misalignment",
"Oh well\nFinal Answer: curses foiled again",
]
fake_llm = FakeListLLM(responses=responses)
tools = [
Tool(
name="FailingTool",
func=lambda _: 1 / 0, # This tool will raise a ZeroDivisionError
description="A tool that fails",
),
]
agent = initialize_agent(
tools,
fake_llm,
agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
verbose=True,
)
agent_iter = agent.iter(inputs="when was langchain made")
assert isinstance(agent_iter, AgentExecutorIterator)
# initialize iterator
iterator = iter(agent_iter)
with pytest.raises(ZeroDivisionError):
next(iterator)
Domain
Subdomains
Source
Frequently Asked Questions
What does test_agent_iterator_failing_tool() do?
test_agent_iterator_failing_tool() is a function in the langchain codebase, defined in libs/langchain/tests/unit_tests/agents/test_agent_iterator.py.
Where is test_agent_iterator_failing_tool() defined?
test_agent_iterator_failing_tool() is defined in libs/langchain/tests/unit_tests/agents/test_agent_iterator.py at line 355.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free