Home / Function/ _aprocess_next_step_output() — langchain Function Reference

_aprocess_next_step_output() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  af9ff3b2_a011_a312_2f5d_9651919ce9f3["_aprocess_next_step_output()"]
  490b6bce_9d4c_017c_89ae_b13ea74223ea["AgentExecutorIterator"]
  af9ff3b2_a011_a312_2f5d_9651919ce9f3 -->|defined in| 490b6bce_9d4c_017c_89ae_b13ea74223ea
  2930b993_0ef7_2ec8_a8f2_724346ce4dde["__aiter__()"]
  2930b993_0ef7_2ec8_a8f2_724346ce4dde -->|calls| af9ff3b2_a011_a312_2f5d_9651919ce9f3
  0a3774fd_ebe1_abde_5275_25554914ae62["_areturn()"]
  af9ff3b2_a011_a312_2f5d_9651919ce9f3 -->|calls| 0a3774fd_ebe1_abde_5275_25554914ae62
  style af9ff3b2_a011_a312_2f5d_9651919ce9f3 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/agents/agent_iterator.py lines 347–374

    async def _aprocess_next_step_output(
        self,
        next_step_output: AgentFinish | list[tuple[AgentAction, str]],
        run_manager: AsyncCallbackManagerForChainRun,
    ) -> AddableDict:
        """Process the output of the next async step.

        Process the output of the next async step,
        handling AgentFinish and tool return cases.
        """
        logger.debug("Processing output of async Agent loop step")
        if isinstance(next_step_output, AgentFinish):
            logger.debug(
                "Hit AgentFinish: _areturn -> on_chain_end -> run final output logic",
            )
            return await self._areturn(next_step_output, run_manager=run_manager)

        self.intermediate_steps.extend(next_step_output)
        logger.debug("Updated intermediate_steps with step output")

        # Check for tool return
        if len(next_step_output) == 1:
            next_step_action = next_step_output[0]
            tool_return = self.agent_executor._get_tool_return(next_step_action)  # noqa: SLF001
            if tool_return is not None:
                return await self._areturn(tool_return, run_manager=run_manager)

        return AddableDict(intermediate_step=next_step_output)

Subdomains

Calls

Called By

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free