Whetstone.
Build agentsBuild agents
Focus area: Build22 min

Build agents

Ten Build questions for LCAE Mock Exam C. Study them one at a time here, or take the whole timed paper in exam mode.

Practice

Try it yourself

Quiz

Reversed after-hook order

Your create_agent middleware array is [AuthMiddleware, LoggingMiddleware, MetricsMiddleware] and each defines an after_model hook. When the model returns, which after_model hook runs first?

  1. AAuthMiddleware, because it is first in the array
  2. BLoggingMiddleware, because it sits in the middle
  3. CMetricsMiddleware, because after-hooks run in reverse array order
  4. DThe order is undefined; hooks run concurrently
Show answer

Correct answer: C — MetricsMiddleware, because after-hooks run in reverse array order

Before-hooks run first-to-last through the array; after-hooks run last-to-first, nesting like context managers, so whatever was set up first is torn down last. MetricsMiddleware is last in the array, so its after_model runs first. Docs: docs.langchain.com/oss/python/langchain/middleware (Build).

Quiz

Legal jump targets

A before_model hook wants to short-circuit the agent loop by jumping. Which set lists ALL and ONLY the legal jump targets?

  1. Aend, tools, model
  2. Bend, tools, model, agent
  3. Cstart, model, end
  4. Dend, agent, human
Show answer

Correct answer: A — end, tools, model

A hook may jump only to end, tools, or model, and a hook that might jump declares can_jump_to up front so the conditional edge is drawn before compile. agent is the seductive wrong option because before_agent / after_agent hooks exist, but there is no jump target named agent. Docs: docs.langchain.com/oss/python/langchain/middleware (Build).

Quiz

Retrying against another provider

A failed model call must be retried against a different provider without the agent loop ever seeing the failure. Which hook shape can do this, and why can an after_model hook not?

  1. Aafter_model, because it can read the error and re-run the model itself
  2. Bwrap_model_call, because only a wrapping hook still holds the handler and can invoke it again
  3. Cbefore_model, because it runs before the failure happens
  4. Dbefore_agent, because it wraps the whole invocation once
Show answer

Correct answer: B — wrap_model_call, because only a wrapping hook still holds the handler and can invoke it again

Only a wrap hook receives the handler and may call it zero, one, or many times, so wrap_model_call can catch the failure and re-invoke. An after_model hook can see that a call failed but has nothing left to invoke. Docs: docs.langchain.com/oss/python/langchain/middleware (Build).

Quiz

Two limits, two exit defaults

You add both ModelCallLimitMiddleware and ToolCallLimitMiddleware with default settings. When each limit is reached, what does the agent do by default?

  1. ABoth end the run
  2. BBoth let the agent continue
  3. CModel Call Limit ends the run; Tool Call Limit lets the agent continue
  4. DModel Call Limit continues; Tool Call Limit ends the run
Show answer

Correct answer: C — Model Call Limit ends the run; Tool Call Limit lets the agent continue

They look like siblings and differ. Model Call Limit's default exit behaviour is end (out of model calls, the agent cannot think further); Tool Call Limit's default is continue (the agent can still answer without that one tool). Docs: docs.langchain.com/oss/python/langchain/middleware/built-in (Build).

Quiz

A summarizer that never fires

A SummarizationMiddleware is constructed with only a model argument and attached to a plain create_agent. After a very long conversation, when does it compress the history?

  1. AAt 85% of the model's context window
  2. BAfter 20 messages
  3. CNever
  4. DAt 100,000 tokens
Show answer

Correct answer: C — Never

trigger has no default; keep defaults to 20 messages but nothing fires it, so an unconfigured summarizer silently never compresses. The 85% / 10% figures are the deep-agent preconfiguration, not middleware defaults. Docs: docs.langchain.com/oss/python/langchain/middleware/built-in (Build).

Quiz

Default deep-agent tools

A deep agent (v0.7) is created with no custom tools. Which of the following are registered by DEFAULT? Select all that apply.

  1. Als, read_file, write_file, edit_file, glob, grep, plus execute, task, and delete
  2. BThe six filesystem tools only, with no execute or task
  3. CThe six filesystem tools plus a built-in web_search tool
  4. Dls, read_file, write_file, plus a built-in send_email tool
Show answer

Correct answer: A — ls, read_file, write_file, edit_file, glob, grep, plus execute, task, and delete

The defaults are the six filesystem tools plus execute, task, and delete (added in v0.7). There is no default web_search or email tool; anything reaching the outside world you register yourself, and execute is registered regardless but only works with a sandbox backend. Docs: docs.langchain.com/oss/python/langchain/deep-agents (Build).

Quiz

interrupt_on set to False

In a HumanInTheLoopMiddleware, one tool is mapped to False in interrupt_on. What happens when the agent calls that tool?

  1. AThe call is blocked and denied
  2. BThe call pauses for approval with all four decisions allowed
  3. CThe call runs without pausing (auto-approved)
  4. DThe middleware raises a configuration error
Show answer

Correct answer: C — The call runs without pausing (auto-approved)

The boolean answers "should this pause", not "is this allowed". True pauses with all decisions; a config object pauses with only the listed decisions; False means auto-approve, so the tool runs freely. Reading False as "denied" gives exactly the wrong policy. Docs: docs.langchain.com/oss/python/langchain/middleware/built-in (Build).

Quiz

Configuring the model's temperature

This agent must run at temperature 0 with a 30-second timeout, but as written it cannot express either setting:

python
from langchain.agents import create_agent

agent = create_agent("openai:gpt-5.5", tools=tools)

Which change is correct?

  1. AAdd temperature=0, timeout=30 as keyword arguments to create_agent(...)
  2. BBuild the model with init_chat_model("openai:gpt-5.5", temperature=0, timeout=30) and pass that instance as the first argument
  3. CChange the string to "openai:gpt-5.5:temperature=0"
  4. DSet a LANGCHAIN_TEMPERATURE environment variable before startup
Show answer

Correct answer: B — Build the model with init_chat_model("openai:gpt-5.5", temperature=0, timeout=30) and pass that instance as the first argument

A bare "provider:model" string carries the model's identity and nothing else, and create_agent has no temperature parameter and does not forward model kwargs. Build the instance with init_chat_model and pass the instance. Docs: docs.langchain.com/oss/python/langchain/models (Build).

Quiz

Skill frontmatter limits

A SKILL.md file's frontmatter sets a name and a description. What are the limits, and what must the name match?

  1. Aname up to 1024 characters; description up to 64
  2. Bname 1 to 64 characters and it must match the directory name exactly; description up to 1024 characters
  3. CBoth capped at 256 characters, with no matching rule
  4. Dname must match a registered tool; description is unlimited
Show answer

Correct answer: B — name 1 to 64 characters and it must match the directory name exactly; description up to 1024 characters

name is 1 to 64 characters and must equal the directory name exactly or the skill silently fails to load; description is capped at 1024 because it loads for every skill on every run. Examiners swap 64 and 1024. Docs: docs.langchain.com/oss/python/langchain/deep-agents (Build).

Quiz

A reserved tool argument name

You write a tool function and name one of its arguments runtime. The code looks fine but the tool behaves strangely. Why?

  1. Aruntime is a reserved parameter name (the injected tool runtime), so it collides silently with framework injection
  2. BTool functions cannot take more than two arguments
  3. Cruntime must be capitalized to be valid
  4. DNaming any argument makes the docstring be ignored
Show answer

Correct answer: A — runtime is a reserved parameter name (the injected tool runtime), so it collides silently with framework injection

config (the runnable config) and runtime (the injected tool runtime) are reserved parameter names. An ordinary argument named runtime collides with what the framework injects, a classic spot-the-bug shape. Docs: docs.langchain.com/oss/python/langchain/tools (Build).

Sign in to track your progress →