_construct_scratchpad() — langchain Function Reference
Architecture documentation for the _construct_scratchpad() function in base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD b386edf5_a650_8b71_2e10_b6329c9f0984["_construct_scratchpad()"] 826e6477_6abe_d406_5d34_9df3fbec8707["StructuredChatAgent"] b386edf5_a650_8b71_2e10_b6329c9f0984 -->|defined in| 826e6477_6abe_d406_5d34_9df3fbec8707 style b386edf5_a650_8b71_2e10_b6329c9f0984 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/agents/structured_chat/base.py lines 57–71
def _construct_scratchpad(
self,
intermediate_steps: list[tuple[AgentAction, str]],
) -> str:
agent_scratchpad = super()._construct_scratchpad(intermediate_steps)
if not isinstance(agent_scratchpad, str):
msg = "agent_scratchpad should be of type string."
raise ValueError(msg) # noqa: TRY004
if agent_scratchpad:
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{agent_scratchpad}"
)
return agent_scratchpad
Domain
Subdomains
Source
Frequently Asked Questions
What does _construct_scratchpad() do?
_construct_scratchpad() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/agents/structured_chat/base.py.
Where is _construct_scratchpad() defined?
_construct_scratchpad() is defined in libs/langchain/langchain_classic/agents/structured_chat/base.py at line 57.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free