Agentic AI · Module 38 of 41 · 7 concepts · about 9 min

Interview: Intermediate Questions

The technical-depth round: ReAct and reasoning patterns, memory and state, agentic RAG and context engineering, workflows and frameworks including LangGraph, multi-agent systems, MCP and A2A, structured outputs and prompts, and the coding tasks set at this level.

At work: The hour in which an interviewer decides whether you know how agents work underneath, or only how to call a library.

Intermediate questions: ReAct and reasoning patterns

What it is

Mechanism questions. For each pattern, be ready with how it works, when it helps and how it fails.

Why it matters

Say each answer aloud before reading it.

  • The first sentence should be a complete answer on its own.
  • The rest adds one example or one trade-off.
  • If an answer here surprises you, the module named in the question's topic is where to go back.

In the real world: The commonest coding task at this level is 'write a ReAct loop'; the commonest follow-up is 'now make the tool fail and show me what happens'.

Q: How does ReAct work?

The model alternates a thought, an action and an observation. It reasons about what it needs, requests one tool, reads the real result, and reasons again, until it answers or a limit stops it. Each thought is grounded in a real observation rather than a guess.

Q: How would you implement ReAct?

A loop over a message history: call the model with tools; if it returns a final answer, stop; otherwise validate and run the requested tool, append the result, and repeat up to a step limit. With function calling the action is structured; in the original form it is parsed from text, with generation stopped before the word 'Observation'.

Q: What are ReAct's failure modes?

Loops and repeated calls, drifting from the goal over a long history, hallucinated tools or arguments, ignoring an observation, and cost that grows faster than step count because the history is resent.

Q: ReAct versus plan-and-execute?

ReAct decides one step at a time, adapts instantly, and pays a large-model call per step. Plan-and-execute plans once, allows parallel and cheaper execution and review, and needs replanning when surprised. They are usually nested: a plan outside, short ReAct loops inside.

Q: What is chain-of-thought?

Having the model reason step by step before answering, which improves multi-step accuracy. Current models often do it internally as extended thinking, controlled by a setting rather than a prompt.

Q: What is reflection?

A critique-and-revise pass on a draft. It works when there is something concrete to check against, such as tests, evidence or a rubric, and needs a separate critic and a cap on rounds.

Q: What is Tree of Thoughts?

A search over several lines of reasoning: propose options, score them, expand the best, back up from dead ends. It helps on problems with dead ends and costs many times more, so it is mostly used offline.

Q: How do you choose a reasoning pattern?

Start with one call, add a ReAct loop if tools are needed, add a plan for long predictable tasks, add one round of reflection if output is testable. Keep each addition only if the evaluation set shows it pays for its cost.

Explaining ReAct as a prompt format instead of a loop your code runs.

Intermediate questions: memory and state

What it is

Design questions about what an agent keeps, where, and how it stays correct.

Why it matters

Say each answer aloud before reading it.

  • The first sentence should be a complete answer on its own.
  • The rest adds one example or one trade-off.
  • If an answer here surprises you, the module named in the question's topic is where to go back.

In the real world: Asked to design 'an assistant that remembers users', candidates who separate a small profile from an episode store, and mention deletion unprompted, are noted as having thought about real users.

Q: How would you implement agent memory?

Short-term: the message history in the run's saved state, trimmed and summarised to a budget. Long-term: a structured profile for facts that always apply, loaded each session, plus a vector store of episodes filtered by user and ranked by similarity, recency and importance. A post-conversation extractor writes memories; dedup, overwrite and expiry keep them correct.

Q: What are episodic, semantic and procedural memory?

Episodic is what happened: events with dates. Semantic is what is true: facts and preferences. Procedural is how to do things: instructions and learned procedures. They are stored and updated differently.

Q: How does memory differ from RAG?

RAG retrieves from shared documents written in advance, the same for every user. Memory retrieves what the agent itself recorded, per user, and the agent can write to it. Similar machinery; different content, ownership and privacy rules.

Q: How do you handle a memory that has changed?

Store keyed facts so a new value replaces the old, keep the old with an end date if history matters, timestamp everything, and re-read from the system of record before any action that depends on it.

Q: How do you keep a long conversation within the context window?

Trim tool results at the source, clear stale ones, summarise older turns into a structured summary that keeps ids, amounts and decisions, keep recent turns verbatim, and restate the goal at the end.

Q: Stateless versus stateful agents?

A stateless agent keeps nothing between requests. A stateful one keeps the task's record so it can continue. In production the workers are stateless and the state is in a database, so any worker can resume any run.

Q: What is checkpointing?

Saving the full run state after each step. A crash loses at most one step, the run can resume on any machine, and earlier checkpoints can be inspected or replayed.

Q: How does an agent wait for a human approval?

It saves its state with a 'waiting' status, notifies the approver and stops. The decision event loads the state, adds the decision as the tool's result, and restarts the loop. Nothing runs while it waits.

Q: What privacy issues does memory raise?

Leakage between users if the user filter is missing, storing sensitive data that was not needed, and failing to delete on request. The user id is enforced in the storage layer, never chosen by the model.

'We store the chat history in a vector database.' The next questions are about a changed address and a deletion request, and that design answers neither.

Practise it: Design a Multi-Agent AI System, Design a Multi-Agent Incident Response System

Intermediate questions: agentic RAG and context engineering

What it is

Questions about getting the right information in front of the model.

Why it matters

Say each answer aloud before reading it.

  • The first sentence should be a complete answer on its own.
  • The rest adds one example or one trade-off.
  • If an answer here surprises you, the module named in the question's topic is where to go back.

In the real world: A strong answer to 'how would you improve a RAG chatbot that fails on comparison questions?' does not mention a bigger model; it describes a retriever the model can call twice.

Q: What is agentic RAG?

Retrieval as a tool the model controls: it decides whether to search, what query to use, which source, whether the results suffice and when to stop. A plain pipeline always does one search and answers.

Q: When is plain RAG enough?

For single-hop factual questions against one corpus. It is cheaper, faster and more predictable. Route only the complex questions to the agentic path.

Q: What is query rewriting?

Turning the user's message into effective searches: making it stand-alone, splitting compound questions, using the documents' vocabulary, or searching with a hypothetical answer.

Q: What are corrective RAG and self-RAG?

Corrective RAG grades retrieved passages and falls back to another source when they are poor. Self-RAG decides whether to retrieve, grades relevance, and checks that the answer is supported and addresses the question, retrying if not.

Q: What is context engineering?

Deciding what the model reads on each turn: instructions, tools, memories, documents, history and intermediate results, selected, ordered and sized by code. It matters more than prompt wording in long tasks.

Q: What is token budgeting?

Giving each kind of content a ceiling within a working budget well under the model's maximum, reserving room for the reply, and defining what is trimmed or summarised first.

Q: How does prompt caching influence how you build the context?

Caches match an identical prefix, so stable content (system prompt, tool definitions) goes first and changing content last. A timestamp at the top defeats it.

Q: What is context poisoning?

A false value entering the context and being relied on from then on. Prevent it by validating values against tool results before they are written to state or memory, and by removing, not appending corrections to, wrong content.

Intermediate questions: workflows and frameworks

What it is

Questions on orchestration and on the libraries that implement it.

Why it matters

Say each answer aloud before reading it.

  • The first sentence should be a complete answer on its own.
  • The rest adds one example or one trade-off.
  • If an answer here surprises you, the module named in the question's topic is where to go back.

In the real world: Candidates who can map a framework's terms back to the concepts ('a checkpointer is saved state; an interrupt is an approval step') are trusted to learn the next framework too.

Q: What workflow patterns do you know?

Sequential chaining, parallel fan-out and fan-in, routing, conditional branching, evaluator-optimiser loops, orchestrator-workers, human approval steps and event-driven triggers.

Q: What is LangGraph?

A library that models an agent as a graph over a typed state. Nodes are steps, edges and conditional edges decide what runs next, and a checkpointer saves state after each step so runs can pause, resume and be replayed. It is a state machine with model calls in some nodes.

Q: How is the agent loop expressed in LangGraph?

As a cycle: a model node, a conditional edge to a tool node when tools are requested, and an edge back. The exit is the conditional edge returning the end when there are no tool calls or a limit is hit.

Q: How does LangGraph handle human-in-the-loop?

A node calls interrupt, which saves state and returns a payload to the caller. Invoking the graph again on the same thread with a resume command continues. It requires a checkpointer, and code before the interrupt in that node runs again on resume.

Q: LangChain versus LangGraph?

LangChain is the broad toolkit: model interfaces, tools, integrations and a prebuilt agent. LangGraph is the lower-level runtime for explicit, durable control flow, which LangChain's agents run on.

Q: What are the core ideas of CrewAI, AutoGen and the OpenAI Agents SDK?

CrewAI: agents with roles, tasks with expected outputs, crews that run them, and flows for deterministic control. AutoGen: multi-agent conversation with roles and termination conditions; now in maintenance mode with successors. OpenAI Agents SDK: agents, a runner, function tools, hand-offs, guardrails, sessions and tracing.

Q: When would you not use a framework?

For one loop with a few tools: hand-written code is shorter, fully visible and easier to debug. Adopt a framework for persistence, approvals, complex flows or multi-agent wiring.

Q: What does an orchestrator need to provide?

Saved state after each step, retries with backoff, timeouts, idempotent steps, run limits and a record of every step.

Naming a favourite framework before asking what the task needs.

Intermediate questions: multi-agent systems, MCP and A2A

What it is

Questions on when to split work between agents and how they connect.

Why it matters

Say each answer aloud before reading it.

  • The first sentence should be a complete answer on its own.
  • The rest adds one example or one trade-off.
  • If an answer here surprises you, the module named in the question's topic is where to go back.

In the real world: The question 'MCP or A2A?' is answered best by a test, not a definition: 'am I asking for a function to be run, or a goal to be achieved?'.

Q: When would you use multiple agents?

When work splits into independent strands that can run in parallel, when a side-task would flood the main context, when jobs need different tools or models, or when an independent check is needed. Not when steps depend closely on each other.

Q: What is a supervisor architecture?

One agent decomposes the task, briefs workers, collects their reports and synthesises. Workers do not talk to each other. It is easy to trace and parallelise; the supervisor is the bottleneck.

Q: What goes in a delegation brief?

The objective and its purpose, the context already known and what to avoid, the output format, the tools and step limit, and what done means. The worker sees nothing else.

Q: What problems arise in multi-agent communication?

Context explosion from shared transcripts, contradictory conclusions, duplicated work and overhead that grows with the number of channels. Use typed messages, private contexts, one owner per task and a shared ledger of actions.

Q: What is MCP?

An open protocol that standardises how AI applications connect to tools and data. Systems are wrapped once as servers exposing tools, resources and prompts; applications implement a client once. It turns M-times-N integrations into M-plus-N.

Q: How does MCP relate to function calling?

Function calling is how a model requests a tool. MCP is how the application discovers tools and carries the call to the system that implements them. The model sees ordinary tool definitions either way.

Q: What is A2A, and how does it differ from MCP?

An agent-to-agent protocol: agents publish an agent card describing their skills, accept tasks with a lifecycle, and return artifacts, without exposing internals. MCP connects an agent to tools; A2A connects an agent to another autonomous agent.

Q: What are the security concerns with third-party tools and agents?

Untrusted descriptions and results as injection routes, definitions that change after approval, over-broad credentials and delegation loops. Vet and pin, scope tokens narrowly, validate what comes back and log every hop.

Practise it: Design a Multi-Agent Data Analyst

Intermediate questions: structured outputs and prompts

What it is

Questions about making model output usable by code, and instructions effective.

Why it matters

Say each answer aloud before reading it.

  • The first sentence should be a complete answer on its own.
  • The rest adds one example or one trade-off.
  • If an answer here surprises you, the module named in the question's topic is where to go back.

In the real world: Shown a prompt full of capitalised warnings, strong candidates propose building a test set before changing a word.

Q: How do you get reliable structured output?

Use the provider's schema-constrained mode where available, describe each field, validate with a typed model, and on failure feed the exact error back for at most two retries before a safe fallback.

Q: What does a schema not guarantee?

That the values are true. A valid order id may not exist. Semantic validation against real data is still required.

Q: How does an agent's system prompt differ from a chat prompt?

It governs many steps: the goal and what done means, how to work, limits, what to do when blocked and how to finish, with reasons so it generalises.

Q: Where should tool guidance go?

Per-tool guidance in each tool's description; cross-tool rules such as ordering and parallel use in the system prompt.

Q: How do you test a prompt change?

Against a fixed evaluation set, several runs per case, comparing success rates before and after, with held-out cases, changing one thing at a time, and a version tag on every trace.

Q: What makes a good routing prompt?

A few distinct routes with one-line definitions, explicit border cases, a fallback, a rule for multi-intent messages, and an enum output evaluated on labelled examples.

Coding tasks at the intermediate level

What it is

The live-coding tasks most often set, each doable in twenty to forty minutes:

  • A tool executor: look up by name, validate inputs, run, and return a result or a useful error.
  • An agent loop: messages, tool calls, results, and a step limit.
  • Retry with backoff and jitter, retrying only passing faults.
  • An idempotent write: a refund function safe to call twice.
  • A token-budget trimmer: keep the system message and the newest messages within a limit.
  • A conversation summariser that triggers past a threshold.
  • A simple router with structured output and a fallback.
  • A tiny evaluation harness: run cases, check end state, report a pass rate.

Why it matters

None of these needs a framework, and that is the point.

  • Interviewers want to see that you know what the library does for you.
  • In each, the marks are in the edges: the unknown tool, the limit, the duplicate call, the empty result.
  • Talk while you write: say what you are leaving out and why.
  • The exercise ladder in module 34 contains every one of these.

In the real world: A common pairing exercise gives a working loop with no limits and a tool that returns an empty string, and asks the candidate to say what is wrong before running it.

Q: What do interviewers look for in the agent-loop task?

The whole reply appended to history, not only its text; results returned with matching ids, all in one message; a step limit; an unknown tool handled as an error result, not a crash; and identity passed by the code, not by the model.

Q: What about the idempotent-write task?

A key derived from stable facts about the action, a check for an existing record with that key before acting, and the same result returned on a repeat. A random key per attempt fails the task.

Q: And the retry task?

Retrying only timeouts and rate limits, never validation or permission errors; exponential delay with a cap; jitter; honouring a retry-after value; and a final failure that is raised, not swallowed.

Q: And the trimmer?

Keeping the system prompt and the first user goal, keeping the newest messages, never splitting a tool request from its result, and counting tokens rather than characters.

Reaching for a framework import in a live-coding round. Unless told otherwise, write it in plain Python; the task is to show the mechanism.