Home / Function/ _construct_agent_scratchpad() — langchain Function Reference

_construct_agent_scratchpad() — langchain Function Reference

Architecture documentation for the _construct_agent_scratchpad() function in schema.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  f6368511_662f_8ce7_f851_59c84e319be5["_construct_agent_scratchpad()"]
  3b77800e_3db1_de7f_9b6f_e6e8fbe62821["AgentScratchPadChatPromptTemplate"]
  f6368511_662f_8ce7_f851_59c84e319be5 -->|defined in| 3b77800e_3db1_de7f_9b6f_e6e8fbe62821
  45750bb7_a2a7_f029_ac95_0be1565df462["_merge_partial_and_user_variables()"]
  45750bb7_a2a7_f029_ac95_0be1565df462 -->|calls| f6368511_662f_8ce7_f851_59c84e319be5
  style f6368511_662f_8ce7_f851_59c84e319be5 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/agents/schema.py lines 16–30

    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}"
        )

Subdomains

Frequently Asked Questions

What does _construct_agent_scratchpad() do?
_construct_agent_scratchpad() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/agents/schema.py.
Where is _construct_agent_scratchpad() defined?
_construct_agent_scratchpad() is defined in libs/langchain/langchain_classic/agents/schema.py at line 16.
What calls _construct_agent_scratchpad()?
_construct_agent_scratchpad() is called by 1 function(s): _merge_partial_and_user_variables.

Analyze Your Own Codebase

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

Try Supermodel Free