Topic 5 of 6 · 5 min read
Live coding with an AI assistant on screen
Goal: Review an agent's suggested change during a live exercise and explain which lines you would accept, edit or reject and why.
In a live round where AI is allowed, the interviewer is scoring how you handle the suggestions, so narrate each decision: what you asked, what came back, what you accept, what you change and why. The assistant's speed is no longer the test. Your review is.
Check yourself · 1 of 3
An assistant suggests a function in a live round. What should you do before accepting it?
Why it matters
If you accept suggestions silently, the interviewer cannot tell whether you understood them. If you reject everything, you look like you cannot use the tool. Thinking aloud makes your judgement visible in real time.
How to do it
- Ask first, in your own words. State the goal and the constraints before you prompt: "I want a function that merges overlapping intervals; inputs can be empty and unsorted."
- Predict before you read. Say what you expect the code to do. Then compare.
- Read the whole suggestion. Skim nothing. Check edge cases (empty input, duplicates, large values), naming and whether it matches the rest of the file.
- Say your decision per part. "I accept the sort. I will change the loop, because it skips the last interval. I reject the helper, we already have one."
- Run it. Write one or two tests or run an example, ideally one the assistant did not suggest. A passing run on your case beats a claim.
- Own the final code. Be ready to explain every line, including ones you kept.
Before and after
Suggestion from the assistant:
def merge(intervals):
intervals.sort()
out = [intervals[0]]
for start, end in intervals[1:]:
if start <= out[-1][1]:
out[-1][1] = end
else:
out.append([start, end])
return out
Weak reaction: pressing accept and saying "looks right".
Better reaction: "Two problems. intervals[0] fails on an empty list. And out[-1][1] = end can shrink an interval, for [1,10] and [2,3]. I will guard the empty case and use max(out[-1][1], end). It also mutates the caller's list, so I will sort a copy." Then you run [[1,10],[2,3]] and show the result.
What goes wrong
- Silent accepting. The interviewer sees no thinking.
- Over-prompting. Asking the tool to solve the whole problem skips the part being scored.
- Fighting the tool. Rejecting good suggestions out of pride wastes time.
- Running only the suggested example. It was chosen to pass.
Examples
Narrating a reject
'The assistant added a retry wrapper. The task has no network call, so I will delete it; it adds code to maintain and nothing to test.'
Narrating an edit
'The query concatenates the id into the string. I will switch to a parameterised query and add a test with a quote character in the id.'
Key points
- State the goal and constraints in your own words before you prompt.
- Predict what the code should do, then compare it with what came back.
- Give a decision for each part: accept, edit or reject, with the reason.
- Run a case of your own choosing, not only the one the assistant picked.
- You must be able to explain every line you keep.
Common mistakes
- Pressing accept without commentary.
- Letting the assistant solve the entire problem in one prompt.
- Testing only with the assistant's own example.
- Rejecting suggestions you cannot explain a flaw in.
Check yourself · 2 of 3
The assistant's code fails on an empty list. How do you handle it on screen?
Check yourself · 3 of 3
Which test case best proves your review of a suggested merge-intervals function?
Practice items, not counted towards your mastery.
Start here
- Machine Learning Interviews book (Chip Huyen) (opens in a new tab)BookFree
Describes how ML and AI interview loops are structured and how to prepare for each round.
- The System Design Primer (opens in a new tab)ToolFree
Core system design vocabulary (caching, queues, load, trade-offs) that LLM design rounds still build on.
- Building a generative AI platform (Chip Huyen) (opens in a new tab)ArticleFree
Walks through the components of an LLM application: context, guardrails, routing, caching and observability.
More for this topic
- Building effective agents (Anthropic) (opens in a new tab)ArticleFree
Separates fixed workflows from agents and says when each is worth its cost and latency.