Home / Class/ AgentExecutorIterator Class — langchain Architecture

AgentExecutorIterator Class — langchain Architecture

Architecture documentation for the AgentExecutorIterator class in agent_iterator.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  1acdec4f_565f_ad87_eef0_de1e0c0a695f["AgentExecutorIterator"]
  53553bfd_1550_1d23_d247_d865657bb39e["AgentAction"]
  1acdec4f_565f_ad87_eef0_de1e0c0a695f -->|extends| 53553bfd_1550_1d23_d247_d865657bb39e
  daca522e_1d40_6f23_5fc4_253b7aed0c06["AgentStep"]
  1acdec4f_565f_ad87_eef0_de1e0c0a695f -->|extends| daca522e_1d40_6f23_5fc4_253b7aed0c06
  21559aaf_24e1_3178_8193_1719e6ef11ba["AgentFinish"]
  1acdec4f_565f_ad87_eef0_de1e0c0a695f -->|extends| 21559aaf_24e1_3178_8193_1719e6ef11ba
  5f186261_77f3_45de_7a41_9329514eb66a["agent_iterator.py"]
  1acdec4f_565f_ad87_eef0_de1e0c0a695f -->|defined in| 5f186261_77f3_45de_7a41_9329514eb66a
  bfbd88cb_c053_0edf_2784_3a7d489adbea["__init__()"]
  1acdec4f_565f_ad87_eef0_de1e0c0a695f -->|method| bfbd88cb_c053_0edf_2784_3a7d489adbea
  6803ae24_a1da_9478_3adf_29f98bd8e6d9["inputs()"]
  1acdec4f_565f_ad87_eef0_de1e0c0a695f -->|method| 6803ae24_a1da_9478_3adf_29f98bd8e6d9
  0d6a5694_5fa5_1196_be26_e673a4422ab4["agent_executor()"]
  1acdec4f_565f_ad87_eef0_de1e0c0a695f -->|method| 0d6a5694_5fa5_1196_be26_e673a4422ab4
  8b17e0f6_ab5a_9dfa_64ad_0fc53f111c42["name_to_tool_map()"]
  1acdec4f_565f_ad87_eef0_de1e0c0a695f -->|method| 8b17e0f6_ab5a_9dfa_64ad_0fc53f111c42
  d5e18048_c872_527c_988a_1675d441f42f["color_mapping()"]
  1acdec4f_565f_ad87_eef0_de1e0c0a695f -->|method| d5e18048_c872_527c_988a_1675d441f42f
  421ad2ef_487e_2daf_8ce0_29cbe12a32b1["reset()"]
  1acdec4f_565f_ad87_eef0_de1e0c0a695f -->|method| 421ad2ef_487e_2daf_8ce0_29cbe12a32b1
  847faf55_6918_3855_6a93_5af890acf42f["update_iterations()"]
  1acdec4f_565f_ad87_eef0_de1e0c0a695f -->|method| 847faf55_6918_3855_6a93_5af890acf42f
  f9289611_94e3_3d85_5da2_ccb6948f473e["make_final_outputs()"]
  1acdec4f_565f_ad87_eef0_de1e0c0a695f -->|method| f9289611_94e3_3d85_5da2_ccb6948f473e
  2a4bb887_76c9_9664_f58c_954a68ceedd8["__iter__()"]
  1acdec4f_565f_ad87_eef0_de1e0c0a695f -->|method| 2a4bb887_76c9_9664_f58c_954a68ceedd8
  4eb2a096_c10f_8b10_235c_a7491613fb4c["__aiter__()"]
  1acdec4f_565f_ad87_eef0_de1e0c0a695f -->|method| 4eb2a096_c10f_8b10_235c_a7491613fb4c

Relationship Graph

Source Code

libs/langchain/langchain_classic/agents/agent_iterator.py lines 40–432

class AgentExecutorIterator:
    """Iterator for AgentExecutor."""

    def __init__(
        self,
        agent_executor: AgentExecutor,
        inputs: Any,
        callbacks: Callbacks = None,
        *,
        tags: list[str] | None = None,
        metadata: dict[str, Any] | None = None,
        run_name: str | None = None,
        run_id: UUID | None = None,
        include_run_info: bool = False,
        yield_actions: bool = False,
    ):
        """Initialize the `AgentExecutorIterator`.

        Initialize the `AgentExecutorIterator` with the given `AgentExecutor`,
        inputs, and optional callbacks.

        Args:
            agent_executor: The `AgentExecutor` to iterate over.
            inputs: The inputs to the `AgentExecutor`.
            callbacks: The callbacks to use during iteration.
            tags: The tags to use during iteration.
            metadata: The metadata to use during iteration.
            run_name: The name of the run.
            run_id: The ID of the run.
            include_run_info: Whether to include run info in the output.
            yield_actions: Whether to yield actions as they are generated.
        """
        self._agent_executor = agent_executor
        self.inputs = inputs
        self.callbacks = callbacks
        self.tags = tags
        self.metadata = metadata
        self.run_name = run_name
        self.run_id = run_id
        self.include_run_info = include_run_info
        self.yield_actions = yield_actions
        self.reset()

    _inputs: dict[str, str]
    callbacks: Callbacks
    tags: list[str] | None
    metadata: dict[str, Any] | None
    run_name: str | None
    run_id: UUID | None
    include_run_info: bool
    yield_actions: bool

    @property
    def inputs(self) -> dict[str, str]:
        """The inputs to the `AgentExecutor`."""
        return self._inputs

    @inputs.setter
    def inputs(self, inputs: Any) -> None:
        self._inputs = self.agent_executor.prep_inputs(inputs)

    @property
    def agent_executor(self) -> AgentExecutor:
        """The `AgentExecutor` to iterate over."""
        return self._agent_executor

    @agent_executor.setter
    def agent_executor(self, agent_executor: AgentExecutor) -> None:
        self._agent_executor = agent_executor
        # force re-prep inputs in case agent_executor's prep_inputs fn changed
        self.inputs = self.inputs

    @property
    def name_to_tool_map(self) -> dict[str, BaseTool]:
        """A mapping of tool names to tools."""
        return {tool.name: tool for tool in self.agent_executor.tools}

    @property
    def color_mapping(self) -> dict[str, str]:
        """A mapping of tool names to colors."""
        return get_color_mapping(

Frequently Asked Questions

What is the AgentExecutorIterator class?
AgentExecutorIterator is a class in the langchain codebase, defined in libs/langchain/langchain_classic/agents/agent_iterator.py.
Where is AgentExecutorIterator defined?
AgentExecutorIterator is defined in libs/langchain/langchain_classic/agents/agent_iterator.py at line 40.
What does AgentExecutorIterator extend?
AgentExecutorIterator extends AgentAction, AgentStep, AgentFinish.

Analyze Your Own Codebase

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

Try Supermodel Free