Home / Function/ _construct_scratchpad() — langchain Function Reference

_construct_scratchpad() — langchain Function Reference

Architecture documentation for the _construct_scratchpad() function in agent.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  f61de998_69fc_f269_1fb6_58fe712b9d99["_construct_scratchpad()"]
  37fcc3f3_2798_3648_915c_2bffdd19bff7["Agent"]
  f61de998_69fc_f269_1fb6_58fe712b9d99 -->|defined in| 37fcc3f3_2798_3648_915c_2bffdd19bff7
  398e54db_7082_c561_dd79_f8ba427c6a37["get_full_inputs()"]
  398e54db_7082_c561_dd79_f8ba427c6a37 -->|calls| f61de998_69fc_f269_1fb6_58fe712b9d99
  style f61de998_69fc_f269_1fb6_58fe712b9d99 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/agents/agent.py lines 742–751

    def _construct_scratchpad(
        self,
        intermediate_steps: list[tuple[AgentAction, str]],
    ) -> str | list[BaseMessage]:
        """Construct the scratchpad that lets the agent continue its thought process."""
        thoughts = ""
        for action, observation in intermediate_steps:
            thoughts += action.log
            thoughts += f"\n{self.observation_prefix}{observation}\n{self.llm_prefix}"
        return thoughts

Subdomains

Called By

Frequently Asked Questions

What does _construct_scratchpad() do?
_construct_scratchpad() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/agents/agent.py.
Where is _construct_scratchpad() defined?
_construct_scratchpad() is defined in libs/langchain/langchain_classic/agents/agent.py at line 742.
What calls _construct_scratchpad()?
_construct_scratchpad() is called by 1 function(s): get_full_inputs.

Analyze Your Own Codebase

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

Try Supermodel Free