Home / Function/ _stop() — langchain Function Reference

_stop() — langchain Function Reference

Architecture documentation for the _stop() function in agent_iterator.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  dd6b6d4a_9a73_3cb5_87b9_01faaa9d94e2["_stop()"]
  490b6bce_9d4c_017c_89ae_b13ea74223ea["AgentExecutorIterator"]
  dd6b6d4a_9a73_3cb5_87b9_01faaa9d94e2 -->|defined in| 490b6bce_9d4c_017c_89ae_b13ea74223ea
  a9a06b32_02d8_cc0e_a2b9_4c37ea88936c["__iter__()"]
  a9a06b32_02d8_cc0e_a2b9_4c37ea88936c -->|calls| dd6b6d4a_9a73_3cb5_87b9_01faaa9d94e2
  4d87dde3_a32d_10d0_6e36_d6572758987b["_return()"]
  dd6b6d4a_9a73_3cb5_87b9_01faaa9d94e2 -->|calls| 4d87dde3_a32d_10d0_6e36_d6572758987b
  style dd6b6d4a_9a73_3cb5_87b9_01faaa9d94e2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/agents/agent_iterator.py lines 376–388

    def _stop(self, run_manager: CallbackManagerForChainRun) -> AddableDict:
        """Stop the iterator.

        Stop the iterator and raise a StopIteration exception with the stopped response.
        """
        logger.warning("Stopping agent prematurely due to triggering stop condition")
        # this manually constructs agent finish with output key
        output = self.agent_executor._action_agent.return_stopped_response(  # noqa: SLF001
            self.agent_executor.early_stopping_method,
            self.intermediate_steps,
            **self.inputs,
        )
        return self._return(output, run_manager=run_manager)

Subdomains

Calls

Called By

Frequently Asked Questions

What does _stop() do?
_stop() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/agents/agent_iterator.py.
Where is _stop() defined?
_stop() is defined in libs/langchain/langchain_classic/agents/agent_iterator.py at line 376.
What does _stop() call?
_stop() calls 1 function(s): _return.
What calls _stop()?
_stop() is called by 1 function(s): __iter__.

Analyze Your Own Codebase

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

Try Supermodel Free