BaseMultiActionAgent Class — langchain Architecture
Architecture documentation for the BaseMultiActionAgent class in agent.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD da24d66e_6dad_d8e1_dddc_7885d3e6576f["BaseMultiActionAgent"] 0faae8c7_2812_be15_1073_b6537539cea8["agent.py"] da24d66e_6dad_d8e1_dddc_7885d3e6576f -->|defined in| 0faae8c7_2812_be15_1073_b6537539cea8 89841ced_d4c8_a9a9_7b39_b7558fcc15e0["return_values()"] da24d66e_6dad_d8e1_dddc_7885d3e6576f -->|method| 89841ced_d4c8_a9a9_7b39_b7558fcc15e0 19cba4e1_3ea2_ae4a_fd53_0a8afe0002fd["get_allowed_tools()"] da24d66e_6dad_d8e1_dddc_7885d3e6576f -->|method| 19cba4e1_3ea2_ae4a_fd53_0a8afe0002fd ff3ae374_f735_73ee_26e0_538ba433911c["plan()"] da24d66e_6dad_d8e1_dddc_7885d3e6576f -->|method| ff3ae374_f735_73ee_26e0_538ba433911c 5741fa2f_805c_1a46_0802_547d3beef2d0["aplan()"] da24d66e_6dad_d8e1_dddc_7885d3e6576f -->|method| 5741fa2f_805c_1a46_0802_547d3beef2d0 9baa6edb_c9f6_9619_333a_d58a15a54727["input_keys()"] da24d66e_6dad_d8e1_dddc_7885d3e6576f -->|method| 9baa6edb_c9f6_9619_333a_d58a15a54727 d876ec7b_5f42_b67a_72d4_68fdfa949262["return_stopped_response()"] da24d66e_6dad_d8e1_dddc_7885d3e6576f -->|method| d876ec7b_5f42_b67a_72d4_68fdfa949262 37a48219_72cb_12ae_e400_4af37f3edf60["_agent_type()"] da24d66e_6dad_d8e1_dddc_7885d3e6576f -->|method| 37a48219_72cb_12ae_e400_4af37f3edf60 8921be96_9d38_54f4_d572_0bc8f4e4559d["dict()"] da24d66e_6dad_d8e1_dddc_7885d3e6576f -->|method| 8921be96_9d38_54f4_d572_0bc8f4e4559d 257c3f1d_0639_2e4e_fd2a_a566e69f1c1d["save()"] da24d66e_6dad_d8e1_dddc_7885d3e6576f -->|method| 257c3f1d_0639_2e4e_fd2a_a566e69f1c1d 44883b1a_42f7_853f_11d8_5807fd7e5763["tool_run_logging_kwargs()"] da24d66e_6dad_d8e1_dddc_7885d3e6576f -->|method| 44883b1a_42f7_853f_11d8_5807fd7e5763
Relationship Graph
Source Code
libs/langchain/langchain_classic/agents/agent.py lines 221–358
class BaseMultiActionAgent(BaseModel):
"""Base Multi Action Agent class."""
@property
def return_values(self) -> list[str]:
"""Return values of the agent."""
return ["output"]
def get_allowed_tools(self) -> list[str] | None:
"""Get allowed tools.
Returns:
Allowed tools.
"""
return None
@abstractmethod
def plan(
self,
intermediate_steps: list[tuple[AgentAction, str]],
callbacks: Callbacks = None,
**kwargs: Any,
) -> list[AgentAction] | AgentFinish:
"""Given input, decided what to do.
Args:
intermediate_steps: Steps the LLM has taken to date,
along with the observations.
callbacks: Callbacks to run.
**kwargs: User inputs.
Returns:
Actions specifying what tool to use.
"""
@abstractmethod
async def aplan(
self,
intermediate_steps: list[tuple[AgentAction, str]],
callbacks: Callbacks = None,
**kwargs: Any,
) -> list[AgentAction] | AgentFinish:
"""Async given input, decided what to do.
Args:
intermediate_steps: Steps the LLM has taken to date,
along with the observations.
callbacks: Callbacks to run.
**kwargs: User inputs.
Returns:
Actions specifying what tool to use.
"""
@property
@abstractmethod
def input_keys(self) -> list[str]:
"""Return the input keys."""
def return_stopped_response(
self,
early_stopping_method: str,
intermediate_steps: list[tuple[AgentAction, str]], # noqa: ARG002
**_: Any,
) -> AgentFinish:
"""Return response when agent has been stopped due to max iterations.
Args:
early_stopping_method: Method to use for early stopping.
intermediate_steps: Steps the LLM has taken to date,
along with observations.
Returns:
Agent finish object.
Raises:
ValueError: If `early_stopping_method` is not supported.
"""
if early_stopping_method == "force":
# `force` just returns a constant string
return AgentFinish({"output": "Agent stopped due to max iterations."}, "")
Source
Frequently Asked Questions
What is the BaseMultiActionAgent class?
BaseMultiActionAgent is a class in the langchain codebase, defined in libs/langchain/langchain_classic/agents/agent.py.
Where is BaseMultiActionAgent defined?
BaseMultiActionAgent is defined in libs/langchain/langchain_classic/agents/agent.py at line 221.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free