test_agent_iterator.py — langchain Source File
Architecture documentation for test_agent_iterator.py, a python file in the langchain codebase. 9 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 2423e003_42f4_7c6a_3fba_30db54c07a0c["test_agent_iterator.py"] 02f66451_d2a9_e7c3_9765_c3a7594721ad["uuid"] 2423e003_42f4_7c6a_3fba_30db54c07a0c --> 02f66451_d2a9_e7c3_9765_c3a7594721ad f69d6389_263d_68a4_7fbf_f14c0602a9ba["pytest"] 2423e003_42f4_7c6a_3fba_30db54c07a0c --> f69d6389_263d_68a4_7fbf_f14c0602a9ba e929cf21_6ab8_6ff3_3765_0d35a099a053["langchain_core.language_models"] 2423e003_42f4_7c6a_3fba_30db54c07a0c --> e929cf21_6ab8_6ff3_3765_0d35a099a053 121262a1_0bd6_d637_bce3_307ab6b3ecd4["langchain_core.tools"] 2423e003_42f4_7c6a_3fba_30db54c07a0c --> 121262a1_0bd6_d637_bce3_307ab6b3ecd4 e591872a_3e49_bc45_c0f0_f1901792a836["langchain_core.tracers.context"] 2423e003_42f4_7c6a_3fba_30db54c07a0c --> e591872a_3e49_bc45_c0f0_f1901792a836 138c8655_8752_7665_c90c_fe40e072df42["langchain_classic.agents"] 2423e003_42f4_7c6a_3fba_30db54c07a0c --> 138c8655_8752_7665_c90c_fe40e072df42 dd2a6d83_f336_1d7a_768e_6d7de69a6ce3["langchain_classic.schema"] 2423e003_42f4_7c6a_3fba_30db54c07a0c --> dd2a6d83_f336_1d7a_768e_6d7de69a6ce3 a7c8faf0_cc66_b117_a7ac_8a6d65f916cd["tests.unit_tests.agents.test_agent"] 2423e003_42f4_7c6a_3fba_30db54c07a0c --> a7c8faf0_cc66_b117_a7ac_8a6d65f916cd 1546e955_88c9_055e_7a67_db109de543dc["tests.unit_tests.callbacks.fake_callback_handler"] 2423e003_42f4_7c6a_3fba_30db54c07a0c --> 1546e955_88c9_055e_7a67_db109de543dc style 2423e003_42f4_7c6a_3fba_30db54c07a0c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from uuid import UUID
import pytest
from langchain_core.language_models import FakeListLLM
from langchain_core.tools import Tool
from langchain_core.tracers.context import collect_runs
from langchain_classic.agents import (
AgentExecutor,
AgentExecutorIterator,
AgentType,
initialize_agent,
)
from langchain_classic.schema import RUN_KEY
from tests.unit_tests.agents.test_agent import _get_agent
from tests.unit_tests.callbacks.fake_callback_handler import FakeCallbackHandler
def test_agent_iterator_bad_action() -> None:
"""Test react chain iterator when bad action given."""
agent = _get_agent()
agent_iter = agent.iter(inputs="when was langchain made")
outputs = list(agent_iter)
assert isinstance(outputs[-1], dict)
assert outputs[-1]["output"] == "curses foiled again"
def test_agent_iterator_stopped_early() -> None:
"""Test react chain iterator when stopped early.
Test react chain iterator when max iterations or
max execution time is exceeded.
"""
# iteration limit
agent = _get_agent(max_iterations=1)
agent_iter = agent.iter(inputs="when was langchain made")
outputs = list(agent_iter)
# NOTE: we don't use agent.run like in the test for the regular agent executor,
# so the dict structure for outputs stays intact
assert isinstance(outputs[-1], dict)
assert (
outputs[-1]["output"] == "Agent stopped due to iteration limit or time limit."
)
# execution time limit
agent = _get_agent(max_execution_time=1e-5)
agent_iter = agent.iter(inputs="when was langchain made")
outputs = []
for step in agent_iter:
outputs.append(step)
assert isinstance(outputs[-1], dict)
assert (
outputs[-1]["output"] == "Agent stopped due to iteration limit or time limit."
)
// ... (327 more lines)
Domain
Subdomains
Functions
- test_agent_async_iterator_output_structure()
- test_agent_async_iterator_stopped_early()
- test_agent_async_iterator_with_callbacks()
- test_agent_iterator_bad_action()
- test_agent_iterator_custom_stopping_condition()
- test_agent_iterator_empty_input()
- test_agent_iterator_failing_tool()
- test_agent_iterator_manual_run_id()
- test_agent_iterator_output_structure()
- test_agent_iterator_properties_and_setters()
- test_agent_iterator_reset()
- test_agent_iterator_stopped_early()
- test_agent_iterator_with_callbacks()
- test_manually_specify_rid_async()
Classes
Dependencies
- langchain_classic.agents
- langchain_classic.schema
- langchain_core.language_models
- langchain_core.tools
- langchain_core.tracers.context
- pytest
- tests.unit_tests.agents.test_agent
- tests.unit_tests.callbacks.fake_callback_handler
- uuid
Source
Frequently Asked Questions
What does test_agent_iterator.py do?
test_agent_iterator.py is a source file in the langchain codebase, written in python. It belongs to the LangChainCore domain, ApiManagement subdomain.
What functions are defined in test_agent_iterator.py?
test_agent_iterator.py defines 14 function(s): test_agent_async_iterator_output_structure, test_agent_async_iterator_stopped_early, test_agent_async_iterator_with_callbacks, test_agent_iterator_bad_action, test_agent_iterator_custom_stopping_condition, test_agent_iterator_empty_input, test_agent_iterator_failing_tool, test_agent_iterator_manual_run_id, test_agent_iterator_output_structure, test_agent_iterator_properties_and_setters, and 4 more.
What does test_agent_iterator.py depend on?
test_agent_iterator.py imports 9 module(s): langchain_classic.agents, langchain_classic.schema, langchain_core.language_models, langchain_core.tools, langchain_core.tracers.context, pytest, tests.unit_tests.agents.test_agent, tests.unit_tests.callbacks.fake_callback_handler, and 1 more.
Where is test_agent_iterator.py in the architecture?
test_agent_iterator.py is located at libs/langchain/tests/unit_tests/agents/test_agent_iterator.py (domain: LangChainCore, subdomain: ApiManagement, directory: libs/langchain/tests/unit_tests/agents).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free