The prompt
If you only remember one thing, say this in the first minute: “Before I ask the agent for anything, I’ll restate the problem, write down my assumptions and sketch the modules, so the design is mine. Then I’ll write the first tests myself, because a test is a decision about what the code means. I’ll give the agent one small, bounded task at a time, read every change it makes, and run the whole test suite after each one. When the requirements grow, I’ll keep every earlier test, so a new part can’t quietly change what the old parts meant. The agent does the typing; the structure, the meaning and the proof stay with me.”
The rest of this page explains each part of that answer, so you can say it with understanding.
Here is the setup. You get an AI coding agent and a problem that is deliberately bigger, vaguer or longer than one request to the agent can solve. Sometimes the requirements arrive in parts. Sometimes the repo is empty, and sometimes it is a real codebase you have never seen. You split up the work, own the design, instruct the agent in small steps, check what it writes, and explain the result yourself.
What makes this different from a normal coding interview
In a normal coding interview you write every line yourself. The interviewer watches whether you can produce a correct solution under time pressure. Typing speed and recall matter.
In these rounds, a tool writes most of the code for you. A coding agent is a program built on a large language model (an LLM, a model that reads text and writes text). You describe a task in plain words, and the agent reads your files, writes code, and in many setups runs commands such as your tests. The message you send it is called a prompt. What it sends back is usually a diff: the set of line changes it wants to make to your files, the same thing you review in a pull request.
So the question changes. It is no longer “can you write this?” because the agent can write most of it. It is “can you stay in charge of something that writes code faster than you can read it?” You already know this job. It is close to leading a very fast junior engineer who never gets tired, never pushes back, and is sometimes confidently wrong. You would not let that person design the system alone, merge unreviewed code, or change the tests to make their own code pass. The same three rules carry this round.
Two things make the agent version harder than reviewing a colleague:
- The code looks right. Agent output is tidy, idiomatic and well named. The bugs that survive are the ones that look correct when you skim. This page shows two of them, both caught only by tests written by the person who owned the meaning.
- The requirements grow while you work. Many of these problems arrive in parts. Each part is easy alone. The risk is that the agent’s solution to part 3 silently changes how part 2 behaves, and nothing looks wrong.
Words you need first
- Spec: the written description of what the program must do. In these rounds you write a short one yourself, because the problem statement is deliberately incomplete.
- Growing spec: requirements that arrive in parts, each building on the last.
- Pinning a decision: writing one test, by hand, that fixes an agreed meaning in place, so any later change that breaks it fails loudly. “I’ll pin that with a test” is a phrase worth using out loud.
- Fail closed: when something is wrong (here, a bad rule), refuse to run rather than run in a weaker way. The opposite, fail open, keeps running and hopes.
Where this was asked
These rounds are described for six companies, by candidates, by the companies themselves or by prep sites, in formats different enough to change how you work:
Agent-assisted coding round: implement accept/deny rules for transactions, growing from simple checks to AND/OR to nested parentheses. The candidate believes the interviewer wanted them to drive the design and keep the code modular rather than let the agent write one big solution.
Staff signal The rejected candidate's own read: they let the agent drive. Decompose the problem yourself and keep the code modular, and design from the actual requirements rather than a memorized template.
- PracHub Aug 2026
AI-assisted coding round: build a control system that manages aircraft takeoffs and landings. The problem is deliberately ambiguous and product-shaped, so a single prompt can't solve it.
Staff signal Canva says it watches when you reach for AI, how you break down requirements, whether you catch flaws in AI output, and whether the result is production quality.
- Canva Engineering 11 Jun 2025
AI-augmented coding round: design and implement a rate limiter. The AI may write the code, but you explain the algorithm, the alternatives and trade-offs, and show how you instructed the AI, reviewed its output and tested it.
- PracHub 24 Sep 2026
AI-assisted coding round: start from an empty GitHub repo in your own IDE and build with any AI tool (Cursor, Claude Code, ChatGPT, Copilot). Graded on workflow, design, ownership, readability and testing.
Staff signal One candidate reportedly had the AI write all the code and still passed, because she directed it and could explain the output.
- Hello Interview
- The Pragmatic Engineer 18 Sep 2025
"Agentic coding" onsite round, reported as in beta: work with an AI agent in a large existing codebase. The same prep site says AI is otherwise banned in OpenAI interviews.
- interviewing.io 2026
Final-stage work trial: build a feature on part of Cursor's real codebase, with a Slack channel to the team, then present it. Reports differ on format: an 8-9 hour remote onsite (a new-grad account) or two days in the office (the CEO, via Business Insider).
- Exponent (Aced)
- Business Insider (via AOL) 12 Jun 2025
| Company | Reported format | Source |
|---|---|---|
| Stripe (Staff, Aug 2026) | One first-hand report of an “AI programming / agent coding” round: transactions with attributes, a list of rules, accept or deny each one. Part 1 is a simple condition check, part 2 adds AND/OR “without worrying about precedence”, part 3 adds nested parentheses. The candidate did all three parts and was rejected | PracHub |
| Canva (official, Jun 2025) | An AI-Assisted Coding round replaces the CS Fundamentals screen for backend and frontend roles. Candidates use their preferred tools on realistic product problems, such as a control system for aircraft takeoffs and landings at a busy airport | Canva Engineering |
| Shopify | Two AI coding interviews. You get an empty GitHub repo and bring your own IDE (code editor) and tools (Hello Interview, undated prep guide). The head of engineering said of AI in interviews, “We’re embracing it” | Hello Interview The Pragmatic Engineer |
| Snowflake (Sep 2026) | In person, on your own laptop with any AI preinstalled: design and implement a rate limiter, explain the algorithm and its alternatives, and show live how you work with the AI, review and test. The candidate got an offer | PracHub |
| OpenAI (2026, prep site) | interviewing.io reports a beta “agentic coding” onsite round on an existing codebase, with problems “too large and complex to tackle by hand”; AI is otherwise “strictly prohibited”. Not every candidate gets it | interviewing.io |
| Cursor | First technical screens allow no AI beyond autocomplete; the process ends with two days in the office building with the team (CEO via Business Insider). A Nov 2025 BI piece says candidates get “a frozen version of the company’s codebase” (BI via AOL, 2025-11-11). A new-grad account describes “an 8 to 9 hour remote onsite” with a Slack channel and a presentation at the end | Business Insider (via AOL) Exponent (Aced) |
The example that runs through this page
The worked example is the Stripe problem: a small engine that reads payment rules and decides whether to accept or deny a transaction. It is the clearest growing spec in the question bank, and the round where design ownership decided the outcome.
The report gives only the three parts. Everything else is this page’s assumption, chosen to make the example concrete: the rule syntax, the attribute names, the “first matching rule wins” behaviour and every test. The code was written and run in scratch on 2026-10-12 (Python 3.13.7, pytest).
Here is the one transaction we will follow from start to finish:
| Attribute | Value | Meaning |
|---|---|---|
id | t1 | the transaction’s name |
amount | 120_000 | $1,200.00, stored as whole cents |
country | BR | Brazil |
currency | USD | US dollars |
card_present | False | an online payment, no physical card |
attempts | 1 | first try |
A rule looks like this: big: DENY IF amount > 100000. It has a name (big), an action (ACCEPT or DENY) and a
condition. For t1, the amount is above 100,000 cents, so this rule says DENY. By the end of part 3 a rule can
say vip: ACCEPT IF (country == BR OR amount > 1) AND attempts > 5, and the page will show exactly how t1 is
judged by each version of the engine.
What is being tested
These rounds grade ownership. You decide the structure, what the code means and what counts as done; the agent types. Each company says it a little differently.
Canva’s own list is the clearest description of the bar, because Canva published it itself. Interviewers ask whether you understand when and how to use AI, how well you break down complex, ambiguous requirements, whether you make sound technical decisions, whether you can identify and fix issues in AI-generated code, and whether the result meets production standards. Its summary: “The most successful candidates didn’t just prompt AI and accept whatever it generated.” Successful candidates also asked clarifying questions about product requirements, and Canva expects engineers “to take full ownership of any code they produce” (Canva Engineering).
Shopify, as a prep site describes it. Hello Interview lists workflow, design, ownership (“You drive, AI assists”), readability, testing (“Testing is not an afterthought here”) and communication. It also says candidates who “wrote zero code by hand” still passed, as long as they were “clearly directing the AI and could explain what it produced” (Hello Interview). This is a prep guide’s summary of candidate reports, not Shopify’s rubric.
Snowflake: the algorithm stays yours. The candidate writes that you have to explain “which algorithm you chose, why you chose it”, what the alternatives are and the trade-offs, and show live “how you communicate with the AI, how you review the code, and how you test it” (PracHub).
Stripe: what is known and what isn’t. The candidate’s own conclusion is: “I think the interviewer wanted me to drive the design and write modular code”, “not to let the agent solve everything by itself and end up with one monolithic solution” (PracHub). That is the candidate’s hindsight, not feedback. The only feedback the post relays came from a different round, the feature-flag design round: the candidate was “trying to force-fit a template from somewhere else” “instead of designing around the actual requirements”.
Two things follow. The candidate finished all three parts and was still rejected, so finishing is not the whole bar. And nobody outside Stripe knows how the agent round itself was scored. Prepare for the candidate’s reading because it costs little and matches what Canva and Snowflake state, not because Stripe confirmed it.
Calibration works in both directions. Using the tool too little also gets marked down. A Meta machine-learning engineer candidate’s recruiter feedback after two AI coding rounds was “less manual work, more on AI” (PracHub). The skill is choosing what to hand over, not refusing to hand anything over.
This matches the guide’s broader view that checking AI output is now the scarce skill (The AI-native engineer). A useful sentence to say early: “I’ll let the agent type, but I’ll own the design, the tests and the explanation.”
Clarify and scope
Ask about the round before the problem. The answers change how you work for the next hour.
- The tool. Can the agent edit files and run commands, or does it only chat? With chat only, copying code back and forth is the slow part, so ask for smaller pieces.
- Tests. Can you run them as often as you like? Are the parts revealed one at a time?
- What “done” means. Does the interviewer want breadth (all parts) or depth (fewer parts, hardened)? The Stripe interviewer reportedly said the candidate “definitely wouldn’t” finish them all.
- Narration. Should you think aloud while you prompt, or summarize after each step?
Then ask about the problem. For the rules engine, two ideas need a word first.
Precedence is the rule for which operator binds first when a condition mixes them. In school arithmetic,
1 + 2 × 3 is 7, not 9, because multiplication binds before addition. Most programming languages treat AND the
same way: AND binds before OR. That is the “textbook” reading. The other simple reading is to fold left to
right: take the conditions in the order written and combine them one at a time, so a OR b AND c means
(a OR b) AND c.
First match wins means the engine checks rules in order and the first rule whose condition is true decides. Later rules are not checked.
With those two ideas, here are the questions that change the code. Write each assumption down where the interviewer can see it.
| Question | Assumption if unanswered | Why it matters |
|---|---|---|
| When two rules match, which wins? | Rules are ordered; the first match decides; nothing matches → ACCEPT | Payments teams may prefer “any DENY wins”. It changes decide(), nothing else |
| What does “without worrying about precedence” mean? | Rules may mix AND and OR, and they fold left to right: a OR b AND c = (a OR b) AND c | The other reading (rules never mix them) gives the same answers on part 2’s tests but not on part 3’s |
| What types do attributes have? | Integers (amounts in cents, never floats for money), strings, booleans | Decides validation |
| A rule names a field the transaction lacks? | The condition is false | A rule that names a field no transaction can have is a typo: reject it at load |
| What is returned? | The decision and the id of the rule that made it | You need the “why” for support, audits and disputes |
| How many rules and transactions? | Tens to hundreds of rules, in process | Decides whether to compile or index rules (see performance) |
The precedence row is the one that matters most. Say it out loud: “‘Without worrying about precedence’ could mean two things. I’ll assume rules fold left to right, write a test that pins it, and check with you again if parentheses come along.”
Out of scope unless asked: a rule-authoring UI, storage, hot reload and versioning. Name them as follow-ups, so the interviewer knows you saw them.
Plan before code
Spend the first five minutes without the agent. Restate the spec, write the assumptions, and say the module plan out loud. This is the decomposition the Stripe candidate wished they had owned.
A picture of the engine
Three words first. A tokenizer cuts the rule text into labelled pieces: a word, an operator, a number, a
bracket. (These are not the LLM “tokens” that agents are billed by. Same word, different thing.) A parser
reads those pieces and builds a condition tree: a small data structure where each leaf is one comparison,
such as amount > 100000, and each inner node is an AND or an OR joining two branches. A recursive-descent
parser is the simplest kind to write by hand: one function per piece of grammar, and functions call each other,
or themselves, to handle nesting.
Rule text lines ("big: DENY IF amount > 100000", ...)
│ 1. load once, at start-up
▼
load_rules ── splits each line into id, action, condition text
│ 2. parse the condition
▼
Tokenizer → Parser ── checks every field and type against a schema; any bad rule stops the whole load
│ 3. one condition tree per rule
▼
Rule list (in order) ── stored in memory
│ 4. for each transaction
▼
decide(rules, txn) ── walks the rules in order; first true condition wins
│
▼
("DENY", "big") ── the decision plus the id of the rule that made it
load_rules runs once. It turns each line into a rule object, or refuses the whole set. That refusal is the
“fail closed” choice, and the next section shows why it matters.
The tokenizer and parser are where the grammar lives. They also check each rule against a schema: a small dictionary saying which fields exist and what type each one is. This is the only part that changes as the spec grows.
The rule list is just a list. Order matters, because first match wins.
decide is a loop. It asks each rule’s tree “is this true for this transaction?” and stops at the first
yes. If nothing matches, it returns the default, ACCEPT.
The module plan
| Module | Job | Part 2 changes | Part 3 changes |
|---|---|---|---|
conditions.py | The condition tree and holds(cond, txn) | add And, Or | none |
parser.py | Tokenizer and recursive-descent parser; validates fields and types | add the AND/OR loop | add one branch |
engine.py | Load rules (fail on any bad rule), decide first match | none | none |
test_rules.py | Your tests, kept across parts | pin left-to-right | parentheses, a random round-trip test |
Two choices in that plan carry the design:
- Parse once, evaluate many times. Evaluating a tree never changes as the grammar grows, so parts 2 and 3 touch only the parser.
- Tokenize from part 1. The tempting shortcut for part 2 is to split the rule text on
" AND "and" OR ". It passes part 2 and has to be thrown away in part 3, because parentheses need a real parser. With a tokenizer and recursive descent from the start, parentheses are one extra branch. Ten extra minutes in part 1 buys part 3.
Say it like this: “Part 1 is small enough to do with string splitting, but part 3 will need a real parser, so I’ll build the parser now and keep evaluation separate. Then each later part changes one function.”
How you work with the agent
The engine is one system. Your working loop with the agent is the other, and it is worth drawing too:
You ── spec, assumptions, module plan, the first tests
│ 1. one small prompt: what to build, what NOT to touch
▼
Coding agent ── reads files, proposes a diff, may run the tests
│ 2. the diff
▼
Your review ── read every changed line; ask "why?" about anything you didn't expect
│ 3. accept or send back
▼
Full test suite ── every part's tests, every time
│ pass → commit and move on fail → diagnose first, then a new prompt
▼
Next small task
You start every loop. The prompt states the structure, the constraints and what not to do.
The agent does the typing. Small tasks keep its diffs short enough to read in a minute or two.
Your review is where the bugs on this page were caught. Reading is not optional just because the tests pass.
The full suite runs after every accepted change, not only the new tests. That is what stops a growing spec from drifting.
Who does what
| Work | Who | Why |
|---|---|---|
| Spec, assumptions, module boundaries, grammar | you | This is the design being graded |
| The first tests for each part | you (agent may draft, you choose every case) | A test is a decision about meaning |
| Tokenizer regex, parser methods, dataclasses | agent, in small diffs | Easy to check, tedious to type |
| Random-tree generator for a round-trip test (explained in part 3) | agent | Easy to read and check |
| Reviewing every diff, running the suite after each | you | ”Can’t explain it” is the reported failure |
This is the spec-driven flow GitHub describes, Specify, Plan, Tasks, Implement, with small reviewable changes (GitHub, 2025-09-02).
The first tests, written by hand
Write the part 1 tests yourself before the first prompt. They are short, and they tell the agent exactly what
“done” means. Notice that TXN is our transaction t1.
SCHEMA = {"amount": int, "country": str, "currency": str, "card_present": bool, "attempts": int}
TXN = {"id": "t1", "amount": 120_000, "country": "BR", "currency": "USD", "card_present": False, "attempts": 1}
def d(lines, txn):
return decide(load_rules(lines, SCHEMA), txn)
def test_single_comparison_denies():
assert d(["big: DENY IF amount > 100000"], TXN) == ("DENY", "big")
def test_first_match_wins_in_rule_order():
rules = ["vip: ACCEPT IF country == BR", "big: DENY IF amount > 100000"]
assert d(rules, TXN) == ("ACCEPT", "vip")
@pytest.mark.parametrize("bad", [
"x: DENY IF amout > 100", # typo in field: must not load and silently never fire
"x: DENY IF amount > US", # wrong type
"x: DENY IF amount > true", # bool is an int subclass in Python
"x: DENY IF country > US", # ordering on a string
])
def test_bad_rules_fail_at_load_time(bad):
with pytest.raises(RuleSyntaxError):
load_rules([bad], SCHEMA)
Read the second test in plain words: t1 matches both rules, but vip comes first, so t1 is accepted. That
single test fixes “first match wins” in place. The bad-rule tests fix “fail closed” in place.
A rough time box
This split is a suggestion, not a reported schedule. It keeps you from spending 40 minutes on part 1.
| Minutes | What you do | Done when |
|---|---|---|
| 0–5 | Clarify, write assumptions, say the module plan | assumptions are on screen |
| 5–20 | Part 1 with the agent | hand-written tests pass, bad rules refused |
| 20–35 | Part 2 | the left-to-right pin passes |
| 35–50 | Part 3 | parentheses work, the part 2 pin still passes |
| 50–60 | Complexity, what’s missing, questions | you named what you’d do next |
Solution in stages
Part 1: one condition per rule
A good prompt reads like a ticket for a contractor. It states the structure, the constraints, and what not to do yet:
Python 3.12, standard library only. Create conditions.py with a frozen dataclass
Compare(field, op, value) and holds(cond, txn) -> bool; a missing attribute never matches.
Create parser.py with a regex tokenizer and a Parser class. comparison() reads
FIELD OP VALUE, rejects fields not in a schema dict (name -> int|str|bool), values of the
wrong type, and <, <=, >, >= on non-numbers, by raising RuleSyntaxError.
Do NOT handle AND, OR or parentheses yet. Don't write tests; mine are in test_rules.py.
Show the files, then run pytest and paste the output.
Two lines in it do most of the work. “Do NOT handle AND, OR or parentheses yet” keeps the diff small and keeps the design yours. “Don’t write tests; mine are in test_rules.py” stops the agent from writing tests that simply agree with its own code.
The core of what comes back, after review (the two isinstance(c, And/Or) lines arrive in part 2):
@dataclass(frozen=True)
class Compare:
field: str
op: str
value: object
def holds(c, txn: dict) -> bool:
if isinstance(c, And): # added in part 2
return holds(c.left, txn) and holds(c.right, txn)
if isinstance(c, Or): # added in part 2
return holds(c.left, txn) or holds(c.right, txn)
if c.field not in txn: # assumption: a missing attribute never matches
return False
return OPS[c.op](txn[c.field], c.value)
def comparison(self) -> Compare:
field = self.take("WORD")
if field not in self.schema:
raise RuleSyntaxError(f"unknown field {field!r}")
op = self.take("OP")
value = self.literal()
want = self.schema[field]
if type(value) is not want:
raise RuleSyntaxError(f"{field} is {want.__name__}, got {value!r}")
if want is not int and op not in ("==", "!="):
raise RuleSyntaxError(f"{op} needs a number, {field} is {want.__name__}")
return Compare(field, op, value)
For t1 and the rule big: DENY IF amount > 100000, holds finds amount in the transaction, compares
120,000 with 100,000, and returns true. decide returns ("DENY", "big").
The first review point to say out loud is type(value) is not want. The natural way to write that check is
isinstance(value, want). But in Python a boolean is a kind of integer, so isinstance(True, int) is True.
A copy of the parser with the isinstance check was run against the same tests on 2026-10-12. It loaded
amount > true without complaint, and only the hand-written bad-rule test caught it. In a fraud rule, a check
that silently compares an amount to True is a rule that never does what its author meant.
Say it like this: “I’m checking the exact type, not isinstance, because in Python True counts as an int and
amount > true would otherwise load.”
The second review point is failing closed at load. Imagine a DENY rule with a typo in its field name,
amout instead of amount. If the engine accepted it, the rule would load fine and never match, which quietly
accepts the very transactions it was written to stop. So the engine parses every rule when it loads them, and
refuses the whole set if one is bad:
LINE = re.compile(r"^\s*(?P<id>\w+)\s*:\s*(?P<action>ACCEPT|DENY)\s+IF\s+(?P<cond>.+)$")
def load_rules(lines, schema):
rules = []
for n, line in enumerate(lines, 1):
m = LINE.match(line)
if not m:
raise RuleSyntaxError(f"line {n}: expected '<id>: ACCEPT|DENY IF <condition>'")
try:
cond = parse_condition(m["cond"], schema)
except RuleSyntaxError as e:
raise RuleSyntaxError(f"line {n} ({m['id']}): {e}") from None
rules.append(Rule(m["id"], m["action"], cond))
return rules
def decide(rules, txn, default="ACCEPT"):
for rule in rules:
if holds(rule.condition, txn):
return rule.action, rule.rule_id
return default, None
The error message names the line and the rule id. That small detail is what makes a refused load quick to fix instead of a mystery.
Part 2: AND and OR, no precedence
Before prompting, settle what the words mean, and pin it with one example where the two readings disagree.
Take three simple conditions, with a true and c false:
- Left to right:
(a OR b) AND cis(true) AND false, which is false. - Textbook (AND before OR):
a OR (b AND c)istrue OR (anything), which is true.
Same text, opposite answers. That is why this has to be decided, written down and tested before the agent writes anything. In grammar notation, the agreed rule is: an expression is a term, followed by any number of “AND term” or “OR term”, folded left to right. The prompt says exactly that:
Add AND and OR. Grammar: expr := term (("AND" | "OR") term)*, folded LEFT TO RIGHT with
no precedence, so "a OR b AND c" means "(a OR b) AND c". Add And/Or dataclasses to
conditions.py and extend holds(). Leave comparison() unchanged. Show the diff only,
then run the whole suite.
def expr(self):
node = self.term()
while self.peek() in (("WORD", "AND"), ("WORD", "OR")):
joiner = self.take("WORD")
right = self.term()
node = And(node, right) if joiner == "AND" else Or(node, right)
return node
def test_mixed_joiners_fold_left_to_right():
# Pinned in part 2 (assumption agreed with the interviewer).
cond = parse_condition("country == BR OR amount > 1 AND attempts > 5", SCHEMA)
assert cond == And(Or(Compare("country", "==", "BR"), Compare("amount", ">", 1)),
Compare("attempts", ">", 5))
assert holds(cond, TXN) is False
Follow t1 through the pinned test. country == BR is true. amount > 1 is true. attempts > 5 is false,
because t1 is a first attempt. Left to right, that is (true OR true) AND false, so the rule does not
match t1. Under textbook precedence it would be true OR (true AND false), which does match. One
transaction, one rule, two different decisions, depending on a choice nobody wrote in the problem statement.
The pin checks the tree, not only the result. A parser that gets the right answer for the wrong reason still fails. Say it like this: “This test pins our reading of ‘no precedence’. If anything later changes how mixed rules fold, it fails.”
Part 3: nested parentheses
Because part 1 built a recursive-descent parser, part 3 is one branch in term(): if the next piece is an
opening bracket, parse a whole expression inside it and require a closing bracket. The prompt says so, and says
what must not change:
Add parentheses. Change only Parser.term(): if the next token is "(", parse an expr and
require ")". Do NOT change how unparenthesized AND/OR fold; test_mixed_joiners_fold_left_to_right
must still pass unchanged. Run the full suite and paste the output.
def term(self):
if self.peek() == ("LP", "("):
self.take("LP")
node = self.expr()
self.take("RP")
return node
return self.comparison()
Now a rule author can write (country == BR OR amount > 1) AND attempts > 5 and get the same tree as the pinned
example, or write country == BR OR (amount > 1 AND attempts > 5) to get the textbook reading on purpose. For
t1, the first does not match and the second does. Brackets let authors say what they mean.
Your tests for this part: brackets override left to right, a doubly nested rule, and malformed input
((amount > 1, amount > 1), (), a trailing AND, a leading AND).
Then hand the agent a property test. A normal test checks one example you chose. A property test generates thousands of random inputs and checks a rule that must hold for all of them. Here the rule is a round trip: build a random condition tree, print it with brackets around everything, parse the text back, and require the same tree and the same answer on random transactions. It is easy to read and hard to fake, which makes it a good thing to delegate.
def test_round_trip_random_trees():
rng = random.Random(7)
for _ in range(2_000):
tree = random_tree(rng, 5)
parsed = parse_condition(render(tree), SCHEMA)
assert parsed == tree
for _ in range(5):
txn = {"amount": rng.randint(0, 10), "attempts": rng.randint(0, 10),
"country": rng.choice(["BR", "US", "AR"])}
assert holds(parsed, txn) == holds(tree, txn)
The trap in part 3
Ask any agent for “a parser with parentheses” and the textbook answer comes back: AND binds tighter than OR. That is a perfectly good parser. It is also a silent change to what every existing part 2 rule means.
To see what the suite does with it, a textbook-precedence version of expr() (an or_expr over and_expr
over term) was written in scratch and run against the same 21 tests on 2026-10-12:
FAILED test_rules.py::test_mixed_joiners_fold_left_to_right - AssertionError: assert
Or(left=Compare(field='country', ...), right=And(left=Compare(field='amount', ...), ...))
== And(left=Or(left=Compare(field='country', ...), ...), right=Compare(field='attempts', ...))
1 failed, 20 passed
Look at which test caught it. The 2,000-tree property test passed, because fully bracketed input never
touches the ambiguity. Only the one hand-written example from part 2 noticed that every unbracketed mixed rule
had silently changed meaning. In payment terms: with the textbook parser, the rule in the pinned test would
start matching t1. If that rule said ACCEPT or DENY, t1’s decision could flip overnight, with no code review
comment and no failing property test to warn anyone.
Whether textbook precedence is better is a fair product question. Changing it without telling anyone is not. If the interviewer wants textbook precedence in part 3, change the pinned test first, out loud, and accept that existing part 2 rules may change their decisions.
Say it like this: “The agent’s parser is the standard one, but it changes what our part 2 rules mean. If we want that, I’ll update the pinned test on purpose and we should replay existing rules to see which decisions change.”
Verification
Every part ended with evidence you could show the interviewer:
| Part | Evidence | Command |
|---|---|---|
| 1 | Single comparisons, first-match order, missing attribute, five bad rules rejected at load | pytest -q test_rules.py |
| 2 | AND, OR, and the left-to-right tree pinned | same |
| 3 | Parentheses, nesting, five malformed inputs, 2,000 random trees round-tripped | same; 21 passed on 2026-10-12 |
| Reviews | An isinstance check lets amount > true load; textbook precedence fails the part 2 pin | the two variants above, run in scratch |
The habits behind the table:
- Keep every earlier part’s tests. A growing spec is a regression risk at each step. Never let the agent delete or rewrite an old test to make a new part pass.
- One hand-written example per meaning you agreed. Random tests find crashes and round-trip bugs. They don’t know what you agreed with the interviewer.
- Run the whole suite after every accepted change, not only at the end of the part.
- Read every diff before it lands. Ask the agent to explain any line you didn’t expect, then check the explanation against the code.
- Narrate in three beats: what you believe, what you will ask the agent for, and what result would prove you
wrong. “Part 3 should only touch
term(). I’ll ask for that branch. If the part 2 pin fails, the agent changed the folding.”
The three-beat narration matters more than it looks. The interviewer can’t see your thinking while you read a diff. If you go quiet for three minutes, they have nothing to grade.
Complexity and performance
Interviewers usually ask for this in one or two sentences. Here is what each part costs and why.
- Load: parsing reads each piece of rule text once, so it is linear in the length of the rule (O(tokens) per rule, where “token” means a tokenizer piece), and it happens once. Load errors are cheap; bad rules in production are not.
- Decide: checking one rule visits each node of its tree at most once, so it is O(nodes) per rule. AND and OR short-circuit: AND stops at the first false branch and OR stops at the first true one. Per transaction the cost is the sum over rules until the first match. With tens to hundreds of rules this is microseconds of Python and no concern.
- Recursion depth: each level of brackets costs a few Python function calls on the stack. In scratch, 400
nested levels parsed and 1,000 raised
RecursionError. Cap the nesting depth at load with a clear error, rather than let a crafted rule crash the loader. - At payment volume (not part of the reported round): compile each rule once into closures, put cheap and selective rules first, and index rules by the field values they test so most transactions skip most rules. Keep evaluation free of side effects, so a rule set can be replayed against past transactions before it ships.
Say it like this: “Parsing is linear and happens once. Deciding is linear in the rules we check before the first match. At this size that’s microseconds; at payment volume I’d compile and index rules, and keep evaluation pure so we can replay changes.”
Small-team version
At a company of 50–500 people, the engineer who owns AI usually directs agents like this every day, on half-specified features, without an interviewer watching. The round is a compressed version of that job.
What one engineer plus agents does on a real feature
- A one-page spec with assumptions and 5–10 acceptance examples. The examples are the contract.
- Tasks small enough to check in minutes, like the three parts above. Small tasks are easier to review and, as the cost section below shows, cheaper.
- Tests first for each task, written or approved by you, with one pinned example per meaning you agreed.
- Small diffs, each reviewed. CI (continuous integration, the server that runs your tests on every push) runs the full suite and blocks the merge if anything fails.
- A harness that learns. Mitchell Hashimoto describes turning each agent mistake into a rule in an
AGENTS.md file (a plain-text conventions file the agent reads at the start of each session) or into a tool
that checks it (2026-02-05). The
isinstancecatch becomes a line in that file.
Build, buy, skip
- Buy the agent. Building your own coding agent is not a small team’s job.
- Build the harness: tests, CI gates, a conventions file, a sandbox (a separate environment with no production credentials), and a spend cap.
- Skip pipelines where agents write and review code with no human review. StrongDM’s three-engineer team runs one (“Code must not be reviewed by humans”), with held-out scenarios and a guideline of at least $1,000 of tokens per engineer per day, which Simon Willison called “more of a business model exercise” (Willison, 2026-02-07). That is a choice for internal or low-risk code, not for payment rules.
- For the rules engine itself, check whether your payment processor’s own rule features cover the need before you build one. If you do build it, the parts you own are load-time validation, explaining which rule fired, and replaying a rule change against past transactions before it ships.
What an agent session costs
Agents are billed by the token: a chunk of text of roughly ¾ of a word (a different thing from the parser’s tokens above). You pay for input tokens, everything the model reads on each call, and output tokens, everything it writes. Output costs more per token, but input is where the money goes in agent work, for one reason.
An agent session is a loop of many model calls, usually called steps. On each step the agent sends the model the whole conversation so far: your instructions, the files it has read, every diff and every test log. That accumulated text is the context. Because the context grows with every step and is re-sent every time, the total input grows roughly with the square of the number of steps. A 40-step session costs far more than twice a 20-step one.
Prompt caching is the provider-side fix. When the start of the context is the same as on the last call, the provider charges a much lower price for re-reading that part. Agent loops benefit a lot, because almost all of each step’s context was already sent on the step before.
With assumed numbers (40 steps, a 20,000-token starting context, 3,000 tokens added per step) and Claude Sonnet 5 list prices fetched 2026-10-11, one session costs about $6.84 without caching and about $1.22 with it. Splitting the same work into two 20-step sessions with fresh context uses 37% fewer input tokens. At an assumed 10 sessions a day for 22 working days, that is about $1,500 a month without caching and about $270 with it.
The arithmetic behind the numbers (for a Staff-level follow-up)
Input tokens over a session without caching:
total input = N × C0 + Δ × N × (N + 1) ÷ 2
where N is the number of agent steps (model calls), C0 is the tokens in the starting context (instructions, files read), and Δ is the tokens added per step (tool output, diffs, test logs). The second term is the square-of-steps part.
- Assumed N = 40, C0 = 20,000, Δ = 3,000: 40 × 20,000 + 3,000 × 40 × 41 ÷ 2 = 800,000 + 2,460,000 = 3,260,000 input tokens.
- At $2 per 1M input (Claude Sonnet 5 list price, fetched 2026-10-11): $6.52. Plus 40 × 800 output tokens at $10 per 1M = $0.32. Total $6.84.
- With prompt caching (cached reads $0.20 per 1M), only about 140,000 tokens are new (20,000 + 40 × 3,000): $0.28 for new input, plus 3,120,000 cached tokens × $0.20 per 1M ≈ $0.62, plus $0.32 output ≈ $1.22, before a small cache-write premium.
- Two 20-step sessions with fresh context: 2 × (20 × 20,000 + 3,000 × 20 × 21 ÷ 2) = 2 × 1,030,000 = 2,060,000 input tokens, 37% fewer than 3,260,000.
- Monthly at an assumed 10 sessions a day × 22 days = 220 sessions: 220 × $6.84 ≈ $1,500; 220 × $1.22 ≈ $270.
Step counts and context sizes are assumptions; read them off your own tool’s usage logs.
The formula and prices come from the site’s small-team research (Anthropic’s pricing page, fetched 2026-10-11); prices move, so re-check. Set a monthly spend cap on the API workspace the agents use. Anthropic’s docs list caps per usage tier, and at the cap the API returns HTTP 429 (“too many requests”) until the next month (rate-limit docs, fetched 2026-10-11). That is a cap you want to discover before launch day, not during it.
Say it like this: “Short, well-scoped agent tasks are cheaper as well as easier to review, because every step re-sends the whole conversation. I’d turn on caching and set a spend cap from day one.”
Safety controls
Agents run commands, so mistakes are real. Replit’s agent deleted a production database during a code freeze, and Replit responded with automatic separation of development and production and a planning-only mode (TechTarget, Jul 2025). After incidents tied to AI-assisted changes, Amazon reportedly required senior sign-off on such changes from junior and mid-level engineers (Slashdot relaying the FT, Mar 2026). Generated code also has security bugs: Veracode found a vulnerability in 45% of generated samples across 80 tasks and more than 100 models (Veracode, 2025-07-30).
For a one-engineer team the defaults are simple:
- no production credentials in the agent’s environment;
- approval before destructive commands (deleting files, dropping tables, force-pushing);
- generated changes to money or access-control code reviewed line by line.
What the evidence says about the speed-up
People feel faster with agents. The measurements are mixed, and it is worth knowing them before an interviewer asks “how much faster are you with AI?”
- Against large gains: METR’s early-2025 trial had 16 experienced open-source developers on 246 real tasks. With AI they took 19% longer, while expecting to be 24% faster and believing afterwards they had been about 20% faster (METR, 2025-07-10). Its 2026 follow-up (57 developers, 800+ tasks) measured −18% time with a confidence interval of −38% to +9%, and calls it “only very weak evidence” for the size of the gain (METR, 2026-02-24).
- Mixed: DORA, Google’s yearly study of software delivery, associated a 25% rise in AI adoption in 2024 with about 1.5% lower throughput and 7.2% lower stability (InfoQ, Nov 2024; not checked against the primary report). DORA 2025 found a positive relationship with throughput but still “a negative relationship with software delivery stability”, and summarized: “AI doesn’t fix a team; it amplifies what’s already there” (Google Cloud, 2025-09-23).
- For: Anthropic’s internal study reports 67% more merged PRs per engineer per day, with selection and social-desirability bias flagged by its authors, and more than half of engineers able to fully delegate only 0–20% of their work (Anthropic, 2025-12-02).
The practical reading for a small team: don’t trust felt speed, including your own. Track lead time (from first commit to production), change failure rate (the share of deploys that cause a problem) and review time per change, before and after. Expect review to become the bottleneck.
Revisit when
- A second or third engineer joins: shared conventions files and review load start to matter more than prompts.
- The code becomes regulated (payments, health data, access control): more human review, not less.
- Agent spend passes a set share of the engineering budget: shorten sessions, cache, or cap.
- The first incident is traced to an unreviewed agent change.
Senior vs Staff
Driving an agent through a growing spec
Senior
- Clarifies before prompting and writes the assumptions down.
- Builds a parser that survives part 3, not a string splitter that passes part 2.
- Writes the tests that decide meaning and reviews every diff.
- Finishes the parts with evidence for each and can explain every line.
Staff
- Owns the module plan before the first prompt, which is the Stripe candidate’s own hindsight about what was wanted.
- Spots that “no precedence” is a product decision that will collide with parentheses, pins it, and asks again.
- Fails closed on bad rules, returns which rule fired, and names replay and rollout as the next problems.
- Says what was not done and why, and treats the agent’s speed as a cost to manage, not a result to report.
In plain words: a Senior candidate stays in control of the code. A Staff candidate also stays in control of the meaning, sees which product decisions hide inside the spec, and talks about what happens after the code ships.
The only level-tagged report here is the Stripe Staff one, and its outcome can’t be separated from the design round’s feedback (PracHub). The table is this page’s reading of what separates the levels.
Follow-ups
(Reported, Stripe) Part 3: rules can now nest conditions in parentheses.
Add one branch to term() and nothing else. Run the part 2 pin unchanged. Then raise the open question: should
unbracketed mixed rules keep folding left to right? Recommend keeping it, because changing it changes decisions
on rules that already exist. Under textbook precedence, the pinned rule would flip from no match to a match for t1.
(Reported, Snowflake) Explain the algorithm you chose, the alternatives and the trade-offs.
For a rate limiter there are four standard choices. A fixed window keeps one counter per key per minute: cheap, but a client can send twice the limit across a window boundary. A sliding log stores a timestamp for every request: exact, but memory grows with traffic. Sliding-window counters split the window into small buckets: close to exact, constant memory. A token bucket holds permits that refill at a fixed rate: O(1), allows bursts up to its capacity, and gives an exact Retry-After (how long the caller should wait). Then say which fits this API and why, and show the test that proves your implementation keeps the limit when many requests arrive at once.
(Reported, Canva) The problem is deliberately vague. How do you start?
Write a short spec before any prompt: entities, the core rules, what the system outputs, three acceptance examples and what is out of scope. For the airport controller, that means runways, a queue of takeoff and landing requests, a separation time per runway, and a priority rule (emergencies first). Canva says interviewers watch how you break down requirements and whether you ask about product requirements (Canva Engineering).
(Reported, Cursor) You get part of a real codebase and a day. What do you build?
Spend the first hour reading and running it, pick something small enough to finish and demo, and say why it matters to users. The new-grad account describes choosing an add-on to an existing service and presenting scope, reasons and expected product impact at the end (Exponent (Aced)).
(Not reported; a natural next push) Add NOT and IN lists.
NOT is a one-argument branch in term(), and it reopens the precedence question: does NOT a AND b mean
(NOT a) AND b? Pin it with one example before prompting. IN is a comparison operator with a list value, such
as country IN [BR, AR]; check every element’s type at load.
(Not reported; a natural next push) Two matching rules disagree. Which wins, and how would you change that safely?
Today, the first in order. Switching to “any DENY wins” changes one function, but it can change live decisions. So replay the new behaviour over a sample of past transactions and compare the decisions before shipping it.
(Not reported; a natural next push) The agent's code passes your tests but you can't explain one function.
Don’t ship it. Ask the agent to explain it, check the explanation against the code, and write a test that pins the behaviour you now understand. If it is still unclear, rewrite it smaller.
Common mistakes
- Asking for the whole solution in one prompt. You get one large file with no seams to extend. The Stripe candidate’s own hindsight names this (PracHub).
- A string-splitting parser in part 2. It passes and then blocks part 3. Tokenize from the start.
- Letting meaning drift between parts. Pin each agreed meaning with a hand-written test; random tests don’t know what you agreed.
- Letting the agent edit old tests to make a new part pass. That hides exactly the change you need to see.
- Silent failure on bad rules. A typo in a DENY rule must stop the load, not accept the transactions.
- Floats for money. Floating-point numbers can’t store most cent values exactly. Use whole cents.
- The paste-the-error loop. Pasting an error back to the model and its answer back into the code, again and again, without understanding either. A Cursor-focused prep article calls that loop “the fastest rejection in the building” (techinterview.org). Diagnose first, then prompt.
- Under-using the agent when the company expects you to use it. Recruiter feedback of “less manual work, more on AI” is reported (PracHub).
- Going quiet while reading agent output. The interviewer can’t grade what they can’t hear. Narrate in three beats.
Prove it with a lab
Its rules are ordered, the first match wins and a default applies, the same shape as the accept/deny engine. Timed drill (60 min): with an agent, add compound conditions (AND, OR, parentheses) to its targeting rules, pin your precedence choice with one test, and keep every existing test green.
The Snowflake variant. Explain the algorithm and alternatives first, then direct an agent through a fix to the intermittent concurrency test (a check-then-act race) and prove it with a repeated stress run.
Tests pass, though one concurrency test fails intermittently (about 5% to 37% of runs, depending on load).
Do one run with no AI at all, too. Some companies, Anthropic among them, still ban AI in live rounds unless told otherwise (Anthropic), and the unaided version tells you what you can check on your own.
Questions in this family
6 reported questions share this underlying problem. 6 have an answer card. Each one links to its own page with sources and confidence.
- Agent-assisted coding round: implement accept/deny rules for transactions, growing from simple checks to AND/OR to nested parentheses. The candidate believes the interviewer wanted them to drive the design and keep the code modular rather than let the agent write one big solution.
- AI-assisted coding round: build a control system that manages aircraft takeoffs and landings. The problem is deliberately ambiguous and product-shaped, so a single prompt can't solve it.
- "Agentic coding" onsite round, reported as in beta: work with an AI agent in a large existing codebase. The same prep site says AI is otherwise banned in OpenAI interviews.
- AI-assisted coding round: start from an empty GitHub repo in your own IDE and build with any AI tool (Cursor, Claude Code, ChatGPT, Copilot). Graded on workflow, design, ownership, readability and testing.
- Final-stage work trial: build a feature on part of Cursor's real codebase, with a Slack channel to the team, then present it. Reports differ on format: an 8-9 hour remote onsite (a new-grad account) or two days in the office (the CEO, via Business Insider).
- AI-augmented coding round: design and implement a rate limiter. The AI may write the code, but you explain the algorithm, the alternatives and trade-offs, and show how you instructed the AI, reviewed its output and tested it.
Sources
- PracHub
- Canva Engineering
- Hello Interview
- The Pragmatic Engineer
- PracHub
- interviewing.io
- Business Insider (via AOL)
- Exponent (Aced)
- PracHub
- techinterview.org
- Anthropic
- Business Insider via AOL, “Cursor courted top engineers…”, 2025-11-11: https://aol.com/news/cursor-courted-top-engineers-flying-070128578.html
- GitHub Blog, spec-driven development, 2025-09-02: https://github.blog/ai-and-ml/generative-ai/spec-driven-development-with-ai-get-started-with-a-new-open-source-toolkit/
- Mitchell Hashimoto, “My AI adoption journey”, 2026-02-05: https://mitchellh.com/writing/my-ai-adoption-journey
- Simon Willison, “Software factory”, 2026-02-07: https://simonwillison.net/2026/Feb/7/software-factory/
- METR, early-2025 developer study, 2025-07-10: https://metr.org/blog/2025-07-10-early-2025-ai-experienced-os-dev-study/
- METR, uplift update, 2026-02-24: https://metr.org/blog/2026-02-24-uplift-update/
- InfoQ on DORA 2024, Nov 2024: https://www.infoq.com/news/2024/11/2024-dora-report/
- Google Cloud, DORA 2025, 2025-09-23: https://cloud.google.com/blog/products/ai-machine-learning/announcing-the-2025-dora-report
- Anthropic, “How AI is transforming work at Anthropic”, 2025-12-02: https://www.anthropic.com/research/how-ai-is-transforming-work-at-anthropic
- Veracode, AI-generated code security, 2025-07-30: https://www.veracode.com/press-release/ai-generated-code-poses-major-security-risks-in-nearly-half-of-all-development-tasks-veracode-research-reveals/
- TechTarget, Replit agent incident, Jul 2025: https://www.techtarget.com/searchsoftwarequality/news/366627829/Replit-AI-agent-snafu-shot-across-the-bow-for-vibe-coding
- Slashdot relaying the FT, Amazon AI-assisted changes, 2026-03-10: https://slashdot.org/story/26/03/10/212214/
- Anthropic pricing and rate-limit docs, fetched 2026-10-11: https://platform.claude.com/docs/en/about-claude/pricing , https://platform.claude.com/docs/en/api/rate-limits