Claude Agent SDK and Claude Code interview questions and answers
10 questions from the Claude Agent SDK and Claude Code Interview Mock practice bank, spread across its domains. Pick your answer, then open the explanation to see why each option is right or wrong.
- Question 1Agent SDK Core
Which statement about the Agent SDK's
effortandthinkingoptions is accurate?- A
effortis a shorthand formaxThinkingTokens, soeffort: "low"disables extended thinking - B
"xhigh"behaves the same on every model, andeffortcan only be set for the whole session, never per subagent - C
They are independent: you can run
effort: "low"with extended thinking enabled, oreffort: "max"without it - D
Setting
thinking: { type: "disabled" }makes the SDK reject anyeffortvalue at startup
Show the answer and explanation
Answer: C
effort(lowtomax) trades latency and token cost for reasoning depth.thinkingis{ type: 'adaptive' }(the default on models that support it),{ type: 'enabled', budgetTokens }or{ type: 'disabled' }, and it takes precedence over the deprecatedmaxThinkingTokens. Use low effort for routine lookups and higher effort for debugging and refactors.Why the other options are wrong
A.
maxThinkingTokensis deprecated in favour ofthinking, andeffortis a separate control rather than a token budget.B.
xhighis only for the models that support it, andAgentDefinitionhas its owneffortfield that overrides the session level.D. Nothing in the docs or types says this; the two options are set independently.
- A
- Question 2Extending the Agent
A forecast tool needs an optional
hoursargument that defaults to 12. Which two definitions let Claude leave it out? (Choose two.)Choose 2.
- A
TypeScript:
hours: z.number().int().optional()in the shape, andargs.hours ?? 12in the handler - B
Python: a full JSON Schema dict with
hoursinpropertiesbut not inrequired, read withargs.get('hours', 12) - C
Python: the simple dict schema
{'latitude': float, 'longitude': float, 'hours': int} - D
Python: a JSON Schema that keeps
hoursinrequiredbut adds'optional': Trueinside its property - E
TypeScript:
hours: z.number()plus{ annotations: { idempotentHint: true } }as extras
Show the answer and explanation
Answer: A and B
Declare the parameter optional in the schema and apply the default in the handler. In TypeScript that means
.optional()on the Zod field. Python's simple dict schema requires every key ({'a': float}becomesrequired: ['a']), so use the full JSON Schema form, or a TypedDict with optional keys, and read the value withargs.get().Why the other options are wrong
C. The simple dict schema marks every key as required.
D. JSON Schema has no
optionalkeyword; whilehoursis inrequired, Claude must send it.E. Annotations describe behaviour; they do not change the input schema.
- A
- Question 3Claude Code Automation and Operations
Traces show an agent calling the same failing tool with identical input 30 times in a row before it hits
maxTurns. You want to stop the repetition after three identical calls, tell Claude why so it can change approach, and keep a hard ceiling. Which design fits?- A
Lower
maxTurnsto 3 for every session, so repeated calls cannot pile up - B
A
Stophook that inspects the transcript when the session ends and flags repeated calls for review - C
Set
maxBudgetUsdlow enough that a loop runs out of budget quickly - D
A
PreToolUsehook that denies the fourth identical call with a reason, withmaxTurnskept
Show the answer and explanation
Answer: D
Loop detection belongs in a hook that sees every call before it runs: key on tool name plus a hash of the input, and return
permissionDecision: "deny"with apermissionDecisionReasonexplaining the repetition. KeepmaxTurnsand a budget cap as hard limits behind it.Why the other options are wrong
A. That also cuts off healthy sessions that legitimately need more turns, and Claude is never told what went wrong.
B. It runs too late: the 30 calls have already happened by the time it fires.
C. A blunt cap that ends the whole run on any expensive work, and it gives Claude no feedback about the loop.
- A
- Question 4Messages API Foundations
Claude returned two
tool_useblocks with idstoolu_01andtoolu_02. How does the API know which of your results belongs to which call?- A
By position: the first
tool_resultanswers the firsttool_use - B
Each
tool_resultcarries atool_use_idequal to theidof the call it answers - C
Each
tool_resultrepeats the toolname, and names are matched - D
You send each result in its own follow-up request, tagged with an
x-tool-call-idheader naming the call
Show the answer and explanation
Answer: B
A
tool_useblock hasid,nameandinput. The reply is a user message whose content includes onetool_resultper call, each withtool_use_idset to that call'sid, plus optionalcontent(string or blocks of text, image, document) and optionalis_error.Why the other options are wrong
A. Order is not how results are matched; ids are. Relying on position breaks as soon as you run calls concurrently.
C. Two calls can use the same tool with different inputs, so the name is not a unique key;
tool_resulthas nonamefield.D. There is no such header. All results go back as content blocks in the next user message.
- A
- Question 5Agent SDK Core
In Python you interrupt a slow task, then ask a new question:
await client.query("Count to 100 slowly using bash sleep") await asyncio.sleep(2) await client.interrupt() await client.query("What is 2 + 2?") async for m in client.receive_response(): print(m)The output shows the counting task's messages and a
ResultMessage, but no answer to 2 + 2. Why?- A
interrupt()closed the session, so the secondquery()was silently dropped - B
receive_response()only works once per client; create a new client for each question - C
The second prompt needs a different
session_id, otherwise it is merged into the interrupted turn - D
interrupt()does not clear the buffer, so the firstreceive_response()returns the interrupted task's messages; drain them before reading the new answer
Show the answer and explanation
Answer: D
The Python reference says
interrupt()sends a stop signal but leaves messages the task already produced, including itsResultMessage, in the stream. Drain them withreceive_response()straight after interrupting. Also avoidbreakout of these async iterations, because it can cause asyncio cleanup problems; use flags instead.Why the other options are wrong
A.
interrupt()stops the current task; it does not disconnect the client. The second message is still processed.B.
receive_response()can be called once per exchange; it stops after eachResultMessage.C. Session IDs are not the issue. The leftover messages from the interrupted task are still in the stream.
- A
- Question 6Extending the Agent
Nesting is on at the default depth. A
researchersubagent should keep spawning helpers, but asecurity-reviewersubagent must never spawn subagents of its own. Which changes achieve exactly that? (Choose two.)Choose 2.
- A
Give
security-revieweran explicittoolslist that does not includeAgent - B
Add
Agenttosecurity-reviewer'sdisallowedTools - C
Set
CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH=1inenv - D
Put
Agent(researcher)insecurity-reviewer'stoolsso it can only spawn that type - E
Set
permissionMode: "plan"onsecurity-reviewer
Show the answer and explanation
Answer: A and B
Subagents can nest up to three layers by default. The depth variable is global; per-agent control is done by leaving
Agentout oftoolsor listing it indisallowedTools. TheAgent(type)allowlist syntax only applies to an agent running as the main thread.Why the other options are wrong
C. That turns nesting off for every subagent, so
researcherloses its helpers too.D. This allows spawning rather than blocking it, and the type list in parentheses is ignored inside a subagent definition anyway.
E. Plan mode stops edits but does not remove the
Agenttool, and depending on the parent's mode the setting may not even apply.
- A
- Question 7Claude Code Automation and Operations
In a CI run with
--permission-mode dontAsk, addingAskUserQuestionto--allowedToolslets Claude ask the user clarifying questions.- A
True
- B
False
Show the answer and explanation
Answer: B
AskUserQuestionis one of the actions no permission mode auto-approves, because it needs a person. IndontAskit is denied outright, together with explicitaskrules and MCP tools marked as requiring user interaction. If a pipeline really needs a person's input, use a permission host such as an SDKcanUseToolcallback, or defer the call and resume later.Why the other options are wrong
A.
dontAskdeniesAskUserQuestioneven when an allow rule matches it.
- A
- Question 8Messages API Foundations
A support bot marks its system prompt with
cache_control, butcache_read_input_tokensis 0 on every request, even for back-to-back identical questions. Which causes could explain this? (Choose two.)Choose 2.
- A
The system prompt begins with
Current time: {now()} - B
Tool definitions are built from a dict iterated in a different order per process, so the
toolsJSON varies - C
The user question at the end of
messagesdiffers between requests - D
Requests arrive about 90 seconds apart
- E
The responses are streamed rather than returned in one piece
Show the answer and explanation
Answer: A and B
Caching is a byte-exact prefix match over
tools, thensystem, thenmessages. Silent invalidators are anything dynamic early in the prefix: timestamps, request ids, per-user interpolation, unsorted JSON, or a tool list that varies per user. Fix by moving the dynamic part after the last breakpoint or making it deterministic, then confirm withcache_read_input_tokens > 0.Why the other options are wrong
C. Content after the breakpoint does not affect the cached prefix; varying questions are exactly what caching expects.
D. That is well inside the 5-minute TTL, and every hit refreshes the timer.
E. Streaming is a transport choice; it is not part of the cached prefix.
- A
- Question 9Agent SDK Core
You set
maxBudgetUsd: 1.00. The run ends witherror_max_budget_usd, buttotal_cost_usdis 1.07 and finance flags it as over budget. What explains the overshoot, and how should you size the cap?- A
The cap is a monthly organisation limit, so other sessions pushed the total over; set it in the Console
- B
Subagent spend is not counted against the cap, so subagents add cost on top; disable subagents
- C
The SDK rounds the cap up to the next 10 cents; use a value that is already a multiple of 0.10
- D
Spend is checked after each response arrives, so the response that crosses the cap still completes, and running subagents may spend more before stopping; leave headroom
Show the answer and explanation
Answer: D
Claude Code compares the client-side cost estimate with the cap after each model response. The response that crosses it still counts toward
total_cost_usd, and background subagents still running are stopped. Set the cap below your real limit. In TypeScript, the cap counts only this call's own spend; totals restored from a resumed session do not count.Why the other options are wrong
A.
maxBudgetUsdis a per-query cap enforced by Claude Code, not an organisation or Console limit.B. The opposite: subagent spend counts toward the total, and spawning a new subagent fails once the cap is reached.
C. No rounding rule like this exists.
- A
- Question 10Extending the Agent
With
enableFileCheckpointing: true, which of these file changes made by the main agent canrewindFiles()undo?- A
A file the
Writetool created and another theEdittool modified - B
A config file rewritten by
sed -ithrough theBashtool - C
A
build/directory created withmkdir - D
A row the agent inserted into a remote Postgres database through an MCP server tool
Show the answer and explanation
Answer: A
File checkpointing tracks only the Write, Edit and NotebookEdit tools. Bash edits, directory operations, remote or network files and most subagent edits are not covered, and the conversation is not rewound either. It is a convenience for local edits, not a replacement for git or for idempotent external side effects.
Why the other options are wrong
B. Bash changes are not captured by checkpointing.
C. Creating, moving or deleting directories is not undone, and this one was made through Bash too.
D. Only local files changed by the file-editing tools are tracked; remote systems are out of scope.
- A
Practise all 450 Claude Agent SDK and Claude Code questions
Start with the free 15-question diagnostic. It shows where to focus, and your results carry over if you sign up.