Build agents
The Build domain is create_agent, deep agents, and middleware, the high-level surface that sits on top of the LangGraph runtime. Ten questions.
Try it yourself
The create_agent import
Which import gives you the high-level agent constructor in LangChain 1.0?
Show answer
Correct answer: A — from langchain.agents import create_agent
create_agent lives in langchain.agents in LangChain 1.0; StateGraph is the lower-level LangGraph API it compiles down to. Docs: docs.langchain.com/oss/python/langchain (Build).
Structured output
You want the agent to return a validated Pydantic object instead of free text. Which parameter do you set, and where do you read the result?
Show answer
Correct answer: B — response_format=<schema>, read result["structured_response"]
response_format=<schema> validates output, and you read it at result["structured_response"]. Docs: docs.langchain.com/oss/python/langchain (Build).
What an agent is
In the create_agent mental model, what is an "agent"?
Show answer
Correct answer: C — A model calling tools in a loop until the task is complete
The core definition: an agent is a model calling tools in a loop until the task is complete. Docs: docs.langchain.com/oss/python/langchain (Build).
The messages field
Which statement about the built-in messages field of AgentState is correct?
Show answer
Correct answer: D — It is append-only: new messages are added, never replaced
messages is append-only; new messages are added and existing ones are never replaced. Docs: docs.langchain.com/oss/python/langchain (Build).
Once per invocation
A middleware hook that must run exactly once before the agent starts (not once per model call) is:
Show answer
Correct answer: A — before_agent
before_agent runs once per invocation, whereas before_model runs before each model call. Docs: docs.langchain.com/oss/python/langchain/middleware (Build).
Why wrap_model_call
What makes wrap_model_call more powerful than before_model / after_model?
Show answer
Correct answer: B — It can call the handler zero, one, or many times (short-circuit, normal, or retry)
Wrap hooks control the handler: calling it zero times short-circuits, once is normal, and many times retries. Docs: docs.langchain.com/oss/python/langchain/middleware (Build).
Human approval of tools
You need a human to approve certain tool calls before they execute. Which built-in middleware, and how is it targeted?
Show answer
Correct answer: C — HumanInTheLoopMiddleware, matched against each tool's .name via interrupt_on
HumanInTheLoopMiddleware uses interrupt_on, matched against each tool's .name. Docs: docs.langchain.com/oss/python/langchain/middleware (Build).
SummarizationMiddleware
The primary purpose of SummarizationMiddleware is:
Show answer
Correct answer: D — Context management, compressing history so it fits the window
SummarizationMiddleware is a context-management primitive that compresses history. Docs: docs.langchain.com/oss/python/langchain/middleware (Build).
Deep agent capabilities
Which are the four capabilities create_deep_agent adds on top of create_agent?
Show answer
Correct answer: A — Planning (todo), a virtual filesystem, subagents, and memory
Deep agents add planning (a todo list), a virtual filesystem, subagents, and memory. Docs: docs.langchain.com/oss/python/deepagents (Build).
thread_id vs context
What is the difference between passing thread_id and passing context to an agent invocation?
Show answer
Correct answer: C — thread_id scopes the persisted conversation/checkpoints; context carries per-run data read at invocation time
thread_id scopes the persisted conversation and its checkpoints; context is per-run data read at invocation time. Docs: docs.langchain.com/oss/python/langchain (Build).