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.

  1. Question 1Agent SDK Core

    Which statement about the Agent SDK's effort and thinking options is accurate?

    • A

      effort is a shorthand for maxThinkingTokens, so effort: "low" disables extended thinking

    • B

      "xhigh" behaves the same on every model, and effort can only be set for the whole session, never per subagent

    • C

      They are independent: you can run effort: "low" with extended thinking enabled, or effort: "max" without it

    • D

      Setting thinking: { type: "disabled" } makes the SDK reject any effort value at startup

    Show the answer and explanation

    Answer: C

    effort (low to max) trades latency and token cost for reasoning depth. thinking is { type: 'adaptive' } (the default on models that support it), { type: 'enabled', budgetTokens } or { type: 'disabled' }, and it takes precedence over the deprecated maxThinkingTokens. Use low effort for routine lookups and higher effort for debugging and refactors.

    Why the other options are wrong

    • A. maxThinkingTokens is deprecated in favour of thinking, and effort is a separate control rather than a token budget.

    • B. xhigh is only for the models that support it, and AgentDefinition has its own effort field that overrides the session level.

    • D. Nothing in the docs or types says this; the two options are set independently.

  2. Question 2Extending the Agent

    A forecast tool needs an optional hours argument 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, and args.hours ?? 12 in the handler

    • B

      Python: a full JSON Schema dict with hours in properties but not in required, read with args.get('hours', 12)

    • C

      Python: the simple dict schema {'latitude': float, 'longitude': float, 'hours': int}

    • D

      Python: a JSON Schema that keeps hours in required but adds 'optional': True inside 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} becomes required: ['a']), so use the full JSON Schema form, or a TypedDict with optional keys, and read the value with args.get().

    Why the other options are wrong

    • C. The simple dict schema marks every key as required.

    • D. JSON Schema has no optional keyword; while hours is in required, Claude must send it.

    • E. Annotations describe behaviour; they do not change the input schema.

  3. 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 maxTurns to 3 for every session, so repeated calls cannot pile up

    • B

      A Stop hook that inspects the transcript when the session ends and flags repeated calls for review

    • C

      Set maxBudgetUsd low enough that a loop runs out of budget quickly

    • D

      A PreToolUse hook that denies the fourth identical call with a reason, with maxTurns kept

    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 a permissionDecisionReason explaining the repetition. Keep maxTurns and 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.

  4. Question 4Messages API Foundations

    Claude returned two tool_use blocks with ids toolu_01 and toolu_02. How does the API know which of your results belongs to which call?

    • A

      By position: the first tool_result answers the first tool_use

    • B

      Each tool_result carries a tool_use_id equal to the id of the call it answers

    • C

      Each tool_result repeats the tool name, and names are matched

    • D

      You send each result in its own follow-up request, tagged with an x-tool-call-id header naming the call

    Show the answer and explanation

    Answer: B

    A tool_use block has id, name and input. The reply is a user message whose content includes one tool_result per call, each with tool_use_id set to that call's id, plus optional content (string or blocks of text, image, document) and optional is_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_result has no name field.

    • D. There is no such header. All results go back as content blocks in the next user message.

  5. 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 second query() 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 first receive_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 its ResultMessage, in the stream. Drain them with receive_response() straight after interrupting. Also avoid break out 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 each ResultMessage.

    • C. Session IDs are not the issue. The leftover messages from the interrupted task are still in the stream.

  6. Question 6Extending the Agent

    Nesting is on at the default depth. A researcher subagent should keep spawning helpers, but a security-reviewer subagent must never spawn subagents of its own. Which changes achieve exactly that? (Choose two.)

    Choose 2.

    • A

      Give security-reviewer an explicit tools list that does not include Agent

    • B

      Add Agent to security-reviewer's disallowedTools

    • C

      Set CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH=1 in env

    • D

      Put Agent(researcher) in security-reviewer's tools so it can only spawn that type

    • E

      Set permissionMode: "plan" on security-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 Agent out of tools or listing it in disallowedTools. The Agent(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 researcher loses 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 Agent tool, and depending on the parent's mode the setting may not even apply.

  7. Question 7Claude Code Automation and Operations

    In a CI run with --permission-mode dontAsk, adding AskUserQuestion to --allowedTools lets Claude ask the user clarifying questions.

    • A

      True

    • B

      False

    Show the answer and explanation

    Answer: B

    AskUserQuestion is one of the actions no permission mode auto-approves, because it needs a person. In dontAsk it is denied outright, together with explicit ask rules and MCP tools marked as requiring user interaction. If a pipeline really needs a person's input, use a permission host such as an SDK canUseTool callback, or defer the call and resume later.

    Why the other options are wrong

    • A. dontAsk denies AskUserQuestion even when an allow rule matches it.

  8. Question 8Messages API Foundations

    A support bot marks its system prompt with cache_control, but cache_read_input_tokens is 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 tools JSON varies

    • C

      The user question at the end of messages differs 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, then system, then messages. 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 with cache_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.

  9. Question 9Agent SDK Core

    You set maxBudgetUsd: 1.00. The run ends with error_max_budget_usd, but total_cost_usd is 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. maxBudgetUsd is 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.

  10. Question 10Extending the Agent

    With enableFileCheckpointing: true, which of these file changes made by the main agent can rewindFiles() undo?

    • A

      A file the Write tool created and another the Edit tool modified

    • B

      A config file rewritten by sed -i through the Bash tool

    • C

      A build/ directory created with mkdir

    • 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.

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.

Go to Claude Agent SDK and Claude Code