AgentScratchPadChatPromptTemplate Class — langchain Architecture
Architecture documentation for the AgentScratchPadChatPromptTemplate class in schema.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 3b77800e_3db1_de7f_9b6f_e6e8fbe62821["AgentScratchPadChatPromptTemplate"] 6be4a9a5_5fe4_e64f_c374_e63767576bf6["ChatPromptTemplate"] 3b77800e_3db1_de7f_9b6f_e6e8fbe62821 -->|extends| 6be4a9a5_5fe4_e64f_c374_e63767576bf6 c5a5326d_2157_aedd_8829_30e2b51eaa85["schema.py"] 3b77800e_3db1_de7f_9b6f_e6e8fbe62821 -->|defined in| c5a5326d_2157_aedd_8829_30e2b51eaa85 75d9b58b_6118_0594_208a_eadaff223189["is_lc_serializable()"] 3b77800e_3db1_de7f_9b6f_e6e8fbe62821 -->|method| 75d9b58b_6118_0594_208a_eadaff223189 f6368511_662f_8ce7_f851_59c84e319be5["_construct_agent_scratchpad()"] 3b77800e_3db1_de7f_9b6f_e6e8fbe62821 -->|method| f6368511_662f_8ce7_f851_59c84e319be5 45750bb7_a2a7_f029_ac95_0be1565df462["_merge_partial_and_user_variables()"] 3b77800e_3db1_de7f_9b6f_e6e8fbe62821 -->|method| 45750bb7_a2a7_f029_ac95_0be1565df462
Relationship Graph
Source Code
libs/langchain/langchain_classic/agents/schema.py lines 8–37
class AgentScratchPadChatPromptTemplate(ChatPromptTemplate):
"""Chat prompt template for the agent scratchpad."""
@classmethod
@override
def is_lc_serializable(cls) -> bool:
return False
def _construct_agent_scratchpad(
self,
intermediate_steps: list[tuple[AgentAction, str]],
) -> str:
if len(intermediate_steps) == 0:
return ""
thoughts = ""
for action, observation in intermediate_steps:
thoughts += action.log
thoughts += f"\nObservation: {observation}\nThought: "
return (
f"This was your previous work "
f"(but I haven't seen any of it! I only see what "
f"you return as final answer):\n{thoughts}"
)
def _merge_partial_and_user_variables(self, **kwargs: Any) -> dict[str, Any]:
intermediate_steps = kwargs.pop("intermediate_steps")
kwargs["agent_scratchpad"] = self._construct_agent_scratchpad(
intermediate_steps,
)
return kwargs
Extends
Source
Frequently Asked Questions
What is the AgentScratchPadChatPromptTemplate class?
AgentScratchPadChatPromptTemplate is a class in the langchain codebase, defined in libs/langchain/langchain_classic/agents/schema.py.
Where is AgentScratchPadChatPromptTemplate defined?
AgentScratchPadChatPromptTemplate is defined in libs/langchain/langchain_classic/agents/schema.py at line 8.
What does AgentScratchPadChatPromptTemplate extend?
AgentScratchPadChatPromptTemplate extends ChatPromptTemplate.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free