Home / Function/ test_agent_iterator_stopped_early() — langchain Function Reference

test_agent_iterator_stopped_early() — langchain Function Reference

Architecture documentation for the test_agent_iterator_stopped_early() function in test_agent_iterator.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  386b4207_0959_529e_07f3_ed1e2207c11d["test_agent_iterator_stopped_early()"]
  2423e003_42f4_7c6a_3fba_30db54c07a0c["test_agent_iterator.py"]
  386b4207_0959_529e_07f3_ed1e2207c11d -->|defined in| 2423e003_42f4_7c6a_3fba_30db54c07a0c
  style 386b4207_0959_529e_07f3_ed1e2207c11d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/tests/unit_tests/agents/test_agent_iterator.py lines 30–58

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."
    )

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free