AgentAction Class — langchain Architecture
Architecture documentation for the AgentAction class in agents.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD a835cf98_21c1_0dc9_4dd3_8934600e2826["AgentAction"] f3658565_d05c_7f49_b7f8_622b7ef34f33["Serializable"] a835cf98_21c1_0dc9_4dd3_8934600e2826 -->|extends| f3658565_d05c_7f49_b7f8_622b7ef34f33 81828515_0fcd_6cb4_96b8_62d4fca3e4ff["agents.py"] a835cf98_21c1_0dc9_4dd3_8934600e2826 -->|defined in| 81828515_0fcd_6cb4_96b8_62d4fca3e4ff c89b44dd_882c_3f11_5082_29934f6115e8["__init__()"] a835cf98_21c1_0dc9_4dd3_8934600e2826 -->|method| c89b44dd_882c_3f11_5082_29934f6115e8 e36e696d_19cf_cd3e_d9b0_8307b2666490["is_lc_serializable()"] a835cf98_21c1_0dc9_4dd3_8934600e2826 -->|method| e36e696d_19cf_cd3e_d9b0_8307b2666490 e5f8d2a5_9cb6_3841_758e_9fb4af8e44be["get_lc_namespace()"] a835cf98_21c1_0dc9_4dd3_8934600e2826 -->|method| e5f8d2a5_9cb6_3841_758e_9fb4af8e44be 359cd72a_4765_207f_e3a1_6ec23bf7c8e4["messages()"] a835cf98_21c1_0dc9_4dd3_8934600e2826 -->|method| 359cd72a_4765_207f_e3a1_6ec23bf7c8e4
Relationship Graph
Source Code
libs/core/langchain_core/agents.py lines 44–102
class AgentAction(Serializable):
"""Represents a request to execute an action by an agent.
The action consists of the name of the tool to execute and the input to pass
to the tool. The log is used to pass along extra information about the action.
"""
tool: str
"""The name of the `Tool` to execute."""
tool_input: str | dict
"""The input to pass in to the `Tool`."""
log: str
"""Additional information to log about the action.
This log can be used in a few ways. First, it can be used to audit what exactly the
LLM predicted to lead to this `(tool, tool_input)`.
Second, it can be used in future iterations to show the LLMs prior thoughts. This is
useful when `(tool, tool_input)` does not contain full information about the LLM
prediction (for example, any `thought` before the tool/tool_input).
"""
type: Literal["AgentAction"] = "AgentAction"
# Override init to support instantiation by position for backward compat.
def __init__(self, tool: str, tool_input: str | dict, log: str, **kwargs: Any):
"""Create an `AgentAction`.
Args:
tool: The name of the tool to execute.
tool_input: The input to pass in to the `Tool`.
log: Additional information to log about the action.
"""
super().__init__(tool=tool, tool_input=tool_input, log=log, **kwargs)
@classmethod
def is_lc_serializable(cls) -> bool:
"""`AgentAction` is serializable.
Returns:
`True`
"""
return True
@classmethod
def get_lc_namespace(cls) -> list[str]:
"""Get the namespace of the LangChain object.
Returns:
`["langchain", "schema", "agent"]`
"""
return ["langchain", "schema", "agent"]
@property
def messages(self) -> Sequence[BaseMessage]:
"""Return the messages that correspond to this action."""
return _convert_agent_action_to_messages(self)
Defined In
Extends
Source
Frequently Asked Questions
What is the AgentAction class?
AgentAction is a class in the langchain codebase, defined in libs/core/langchain_core/agents.py.
Where is AgentAction defined?
AgentAction is defined in libs/core/langchain_core/agents.py at line 44.
What does AgentAction extend?
AgentAction extends Serializable.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free