Whetstone.
Build agentsBuild agents
Focus area: Build22 min

Build agents

The Build domain is create_agent and its parameters, the middleware catalogue, and deep agents. This second set covers the model argument, custom state, the built-in middleware for PII, retries, tool selection, and model fallback, and the deep-agent surface (subagents, skills versus memory, sandboxes). Ten questions.

Practice

Try it yourself

Quiz

Specifying the model

How do you tell create_agent which model to use?

  1. APass a "provider:model" string such as "openai:gpt-5.5", or an initialized model instance
  2. BPass an already-initialized chat model instance only, because a plain string identifier is never accepted
  3. CSet a LANGCHAIN_MODEL environment variable that create_agent reads when it starts up
  4. DGive it the id of a deployed assistant and let the LangSmith platform choose the model for you
Show answer

Correct answer: A — Pass a "provider:model" string such as "openai:gpt-5.5", or an initialized model instance

The model argument accepts a "provider:model" string (e.g. "openai:gpt-5.5") or an initialized model instance. Docs: docs.langchain.com/oss/python/langchain/agents (Build).

Quiz

Custom state fields

You need the agent to track a custom field (say a call_count) that middleware can read and update across the run. What do you do?

  1. AAdd the field to the messages list, which is where all per-run state is stored
  2. BPass it once through context, since context is the mutable per-run scratch space
  3. CEnable response_format with a schema that includes the extra field alongside the answer
  4. DSubclass AgentState to add the field and pass the subclass via state_schema
Show answer

Correct answer: D — Subclass AgentState to add the field and pass the subclass via state_schema

To carry custom state fields, subclass AgentState and pass the subclass via state_schema; context is read-only per-run data, not mutable state. Docs: docs.langchain.com/oss/python/langchain/agents (Build).

Quiz

Relationship to LangGraph

How does an agent built with create_agent relate to LangGraph?

  1. AIt is an alternative to LangGraph that avoids graphs entirely and runs the agent loop by itself
  2. BIt compiles to a LangGraph graph and can be embedded as a node in a larger StateGraph
  3. CIt runs only on the LangSmith servers and has no local LangGraph representation at all
  4. DIt requires a separate LangGraph deployment before the agent can be invoked locally
Show answer

Correct answer: B — It compiles to a LangGraph graph and can be embedded as a node in a larger StateGraph

create_agent compiles to a LangGraph graph and its middleware hooks run inside that compiled graph, so the agent can be dropped into a larger StateGraph as a node or subgraph. Docs: docs.langchain.com/oss/python/langchain/middleware (Build).

Quiz

Handling PII

Which built-in middleware detects sensitive values like emails or credit-card numbers, and how do you control what happens to a match?

  1. ASummarizationMiddleware, with a strategy set to compress the offending message
  2. BHumanInTheLoopMiddleware, which pauses so a human can approve each detected value
  3. CPIIMiddleware, with a strategy such as redact, mask, block, or hash
  4. DModelFallbackMiddleware, which swaps to a safer model when PII is detected
Show answer

Correct answer: C — PIIMiddleware, with a strategy such as redact, mask, block, or hash

PIIMiddleware detects PII (email, credit_card, ip, and others) and its strategy chooses the handling: block, redact, mask, or hash. Docs: docs.langchain.com/oss/python/langchain/middleware/built-in (Build).

Quiz

Retrying a flaky tool

A tool fails intermittently on transient errors and you want it retried automatically with exponential backoff. Which middleware fits?

  1. AToolRetryMiddleware, which retries a failed tool call with a growing backoff delay
  2. BToolCallLimitMiddleware, which caps how many times any tool may be called
  3. CLLMToolSelectorMiddleware, which narrows the tool list before the model call
  4. DHumanInTheLoopMiddleware, which pauses to ask a human whether to run the tool once more
Show answer

Correct answer: A — ToolRetryMiddleware, which retries a failed tool call with a growing backoff delay

ToolRetryMiddleware retries failed tool calls with exponential backoff (max_retries, backoff_factor, initial_delay). Docs: docs.langchain.com/oss/python/langchain/middleware/built-in (Build).

Quiz

Narrowing many tools

Your agent is bound to sixty tools and the model sometimes picks poorly. You want to narrow the candidates before the main model call. Which middleware?

  1. ATodoListMiddleware, which adds a planning tool the model uses to choose tools
  2. BLLMToolSelectorMiddleware, which uses an LLM to pick the relevant tools first
  3. CSummarizationMiddleware, which compresses the tool descriptions to save tokens
  4. DModelCallLimitMiddleware, which limits calls so fewer tools are ever considered
Show answer

Correct answer: B — LLMToolSelectorMiddleware, which uses an LLM to pick the relevant tools first

LLMToolSelectorMiddleware uses an LLM with structured output to select the relevant tools before the main model call (max_tools, always_include). Docs: docs.langchain.com/oss/python/langchain/middleware/built-in (Build).

Quiz

Failing over to another model

Your primary model provider has an outage partway through a run and you want the agent to try a different model automatically. Which middleware, and how does it differ from retrying?

  1. AModelRetryMiddleware, which calls a second provider once the first is exhausted
  2. BModelCallLimitMiddleware, which redirects to a backup model after the call cap
  3. CModelFallbackMiddleware, which tries alternate models when the primary fails
  4. DSummarizationMiddleware, which shortens the prompt so a smaller model can serve it
Show answer

Correct answer: C — ModelFallbackMiddleware, which tries alternate models when the primary fails

ModelFallbackMiddleware tries one or more alternate models when the primary call fails; ModelRetryMiddleware retries the same model, so fallback is the one that changes models. Docs: docs.langchain.com/oss/python/langchain/middleware/built-in (Build).

Quiz

What a subagent sees

A deep agent delegates a subtask to a subagent. What does that subagent work with, and what comes back?

  1. AIt shares the parent agent''s full conversation history and keeps streaming partial updates back to it
  2. BIt writes its intermediate steps directly into the parent agent''s state as it goes
  3. CIt resumes the parent''s thread and appends its own messages to that same thread
  4. DIt gets its own isolated context and returns one final report to the main agent
Show answer

Correct answer: D — It gets its own isolated context and returns one final report to the main agent

Each subagent invocation creates a new agent instance with its own context; it is stateless and returns a single final report to the main agent, quarantining the heavy subtask. Docs: docs.langchain.com/oss/python/deepagents (Build).

Quiz

Skills versus memory files

In a deep agent, how does loading a SKILL.md skill differ from an AGENTS.md memory file?

  1. AThe skill''s full body loads only when a task needs it, while memory files are always loaded
  2. BBoth the skill and the memory file are always loaded into context at agent startup
  3. CBoth are loaded lazily, only once a tool call references them by name during the run
  4. DThe skill is always loaded, and the memory file loads lazily only once a task actually requires it
Show answer

Correct answer: A — The skill''s full body loads only when a task needs it, while memory files are always loaded

A deep agent reads SKILL.md frontmatter at startup and the full skill content only when a task needs it (progressive disclosure), whereas AGENTS.md memory files are always loaded. Docs: docs.langchain.com/oss/python/deepagents (Build).

Quiz

What a sandbox backend adds

You add a sandbox backend to a deep agent. What capability does that add beyond the standard filesystem tools?

  1. AA checkpointer that makes the agent''s thread state durable across restarts
  2. BA write_todos planning tool for tracking the steps of a long-running task
  3. CAn execute tool that runs shell commands in an isolated environment
  4. DAn automatic LLM-as-judge that scores the agent''s output before returning
Show answer

Correct answer: C — An execute tool that runs shell commands in an isolated environment

Sandbox backends expose an execute tool for running shell commands in an isolated environment; the planning tool, durable state, and self-evaluation are separate features. Docs: docs.langchain.com/oss/python/deepagents (Build).

Sign in to track your progress →