AI Interviews · Question

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 question reported at Stripe (Aug 2026). Sources, confidence and an answer card.

Researched · updated

eng-091 Both tracks AI-assisted coding rounds AI-assisted coding Staff+ Medium confidence
On this page

What they’re really asking

If you only remember one thing, say this in the first minute: “Before I prompt the agent, I’ll write down my assumptions and the module plan: a parser that turns each rule into a condition tree, and an engine that checks rules in order. I’ll build a real parser in part 1, so AND, OR and parentheses each change one function. I’ll write the tests that decide the meaning myself, especially one that fixes how a rule mixing AND and OR is read, and I’ll keep every earlier test as the parts grow. The agent types; the design and the proof are mine.”

The rest of this page explains each part of that answer, so you can say it with understanding.

The problem itself is small. You get payment transactions with attributes (amount, country and so on) and a list of rules. Each rule says ACCEPT or DENY when its condition is true. Part 1 has one condition per rule. Part 2 adds AND and OR “without worrying about precedence”. Part 3 adds nested parentheses.

What makes the round different is the tool. A coding agent is a program built on a large language model (an LLM, a model that reads and writes text). You describe a task in plain words, called a prompt, and the agent writes the code and often runs your tests. What it gives back is a diff: the line changes it wants to make, the same thing you review in a pull request.

So the interviewer is not asking “can you write a parser?”. The agent can. They are asking whether you stay in charge of something that writes code faster than you can read it. Each part is easy alone. The risk is across parts: a quick structure that passes part 2 can block part 3, and a “better” parser in part 3 can silently change what part 2’s rules mean. Your plan and your tests decide the round, not how fast the agent types.

This was reported first-hand by a Staff candidate at Stripe in Aug 2026 (PracHubfirst-hand · Aug 2026).

Clarify first

Two ideas need a word before the questions. Precedence is which operator binds first when a condition mixes them. Most languages bind AND before OR, the “textbook” reading, just as 1 + 2 × 3 is 7 in arithmetic. The other simple reading is to fold left to right: combine conditions in the order written, so a OR b AND c means (a OR b) AND c.

  • Which rule wins when several match? Assume an ordered list where the first match decides, with ACCEPT when nothing matches. Ask whether “any DENY wins” is wanted instead.
  • What does “without worrying about precedence” mean? Either rules never mix AND and OR, or they fold left to right. Assume left to right, and ask again when parentheses arrive.
  • Types: integer amounts in minor units (whole cents, no floats for money), strings, booleans.
  • Bad rules: a typo in a field name should stop the load, not create a rule that never fires. This is failing closed: refuse to run rather than run wrong.
  • Output: the decision plus the id of the rule that made it, so support and audits can see why.

Say it like this: “‘No precedence’ could mean two things. I’ll assume left to right, fix it in place with a test, and check with you again if parentheses come in.”

Answer

One transaction to follow

Use one concrete transaction the whole way through. Call it t1: amount 120_000 (that is $1,200.00 in cents), country BR, currency USD, card not present, first attempt (attempts = 1). A rule looks like big: DENY IF amount > 100000: a name, an action and a condition. For t1 that rule matches, so the answer is ("DENY", "big").

The plan, before the first prompt

Spend five minutes without the agent. Restate the spec (the problem in your own words), write the assumptions, and say the modules out loud. Three words help here. A tokenizer cuts rule text into labelled pieces (word, operator, number, bracket). A parser reads those pieces and builds a condition tree: each leaf is one comparison such as amount > 100000, and each inner node joins two branches with AND or OR. A recursive-descent parser is the simplest hand-written kind: one function per piece of grammar, calling each other to handle nesting.

Rule text ("big: DENY IF amount > 100000")
   │  load once
   ▼
Tokenizer → parser ── checks each field and type against a schema; any bad rule stops the load
   │
   ▼
Ordered list of condition trees
   │  for each transaction
   ▼
decide(rules, t1) ── first true condition wins; nothing true → ACCEPT
   │
   ▼
("DENY", "big")

The tokenizer and parser are the only part that grows. decide and the evaluation function, holds(cond, txn), never change after part 2. A schema is a small dictionary of which fields exist and their types; the parser uses it to refuse bad rules at load time.

Write the part 1 tests yourself, then prompt for one module at a time with explicit “don’t” lines: no AND/OR yet, don’t write tests.

Part by part

PartWhat changesWhat to check in reviewWhat to say
1. One FIELD OP VALUEtokenizer, comparison(), load_rules, decidethe type check; bad rules refused at load”Parsing now saves a rewrite in part 3.”
2. AND and ORone loop in the parser, And/Or in the treerules fold left to right; a hand-written test fixes the tree”This test fixes our reading of ‘no precedence’.“
3. Parenthesesone branch in term()the part 2 test still passes unchanged”Only term() should change. If that test fails, the meaning moved.”

Part 1’s trap is a Python detail. The natural type check is isinstance(value, int). But in Python a boolean counts as an integer, so isinstance(True, int) is true, and amount > true would load. A rule that compares an amount to True never does what its author meant. In the family walkthrough’s scratch run, only a hand-written bad-rule test caught it. The fix is type(value) is not want, and it is worth saying out loud.

Part 2’s decision is the meaning of mixed rules. Pin it: fix it in place with one hand-written test, on an example where the two readings disagree. a OR b AND c with a true and c false is false left to right and true under textbook precedence. Follow t1 through the rule country == BR OR amount > 1 AND attempts > 5. The first two comparisons are true and the third is false, because t1 is a first attempt. Left to right, (true OR true) AND false is false: no match. Textbook, true OR (true AND false) is true: a match. Same text, opposite decisions. Assert on the parsed tree, not only on the result, so a parser that gets the right answer for the wrong reason still fails.

Part 3 is one branch in term(): if the next piece is (, parse a whole expression and require ). Tell the agent that the part 2 pin must pass unchanged. Then delegate a property test: instead of one chosen example, it generates many random condition trees, prints each one with brackets around everything, parses the text back and requires the same tree. It is easy to read and hard to fake.

The trap in part 3

Ask for “a parser with parentheses” and an agent usually writes the textbook one, with AND before OR. It is a good parser. It also changes what every unbracketed part 2 rule means. In the walkthrough’s scratch run it failed only the part 2 pin. The 2,000-tree property test passed, because fully bracketed input never touches the ambiguity. That is the point to make: random tests don’t know what you agreed with the interviewer.

If the interviewer wants textbook precedence, change the pin first, out loud, and say that existing rules may change their decisions. Say it like this: “If we switch, I’d replay the current rules against past transactions to see which decisions flip.”

What is reported, exactly

The candidate did all three parts and was rejected. Their own reading is that the interviewer wanted them to “drive the design and write modular code” (PracHubfirst-hand · Aug 2026). That is hindsight, not feedback. The only relayed feedback came from a different round, the feature-flag design round (“trying to force-fit a template from somewhere else”). So nobody outside Stripe knows how the agent round itself was scored. Finishing was clearly not the whole bar, and owning the design costs little to show.

Senior vs Staff

Accept/deny rules with an agent

Senior

  • Builds a real parser from part 1, keeps every part's tests, reviews each diff and finishes with evidence.

Staff

  • Owns the module plan before the first prompt, treats 'no precedence' as a product decision to pin and revisit, fails closed on bad rules, and names replay and rollout of rule changes as the next problem.

In plain words: a Senior candidate keeps control of the code. A Staff candidate also keeps control of what the rules mean, sees the product decision hiding in “no precedence”, and talks about how rule changes ship safely.

Small-team version

At a small company the same discipline applies to a fraud or approval rule feature built with an agent: a one-page spec with acceptance examples, tests you own, small reviewed diffs, and CI (the server that runs your tests on every push) as the gate.

Buy before you build. Check whether your payment processor’s own rule features cover the need. If you do build an engine, the parts you own are load-time validation, returning which rule fired, and replaying a rule change against past transactions before it ships. Keep the agent’s environment free of production credentials.

What the agent costs. Agents are billed per token, a chunk of text of roughly ¾ of a word (not the parser’s tokens). On every step the agent re-sends the whole conversation so far, so long sessions get expensive fast. Prompt caching, where the provider charges much less to re-read text it saw on the last call, cuts that cost. The walkthrough’s assumed 40-step session costs about $6.84 without caching and $1.22 with it; at 10 sessions a day for 22 days, that is about $1,500 or $270 a month. The agent’s cost is small next to your time, but bounded only if you bound it, so set a spend cap on the agents’ API workspace.

The arithmetic behind the numbers (for a Staff-level follow-up)

Assumed session: 40 steps, 20,000 starting tokens, 3,000 tokens added per step, 800 output tokens per step. Claude Sonnet 5 list prices, fetched 2026-10-11: $2 per 1M input, $0.20 per 1M cached input, $10 per 1M output.

  • Input without caching: 40 × 20,000 + 3,000 × 40 × 41 ÷ 2 = 3,260,000 tokens × $2 per 1M = $6.52. Output: 32,000 × $10 per 1M = $0.32. Total $6.84.
  • With caching, only about 140,000 input tokens are new ($0.28); the other 3,120,000 are cached reads (≈ $0.62). With output, ≈ $1.22, before a small cache-write premium.
  • 220 sessions a month: about $1,500 uncached, about $270 cached.

Pitfalls

  • One prompt for the whole solution. It leaves one large file with no seams to extend in parts 2 and 3.
  • Splitting strings on " AND ". It passes part 2 and has to be thrown away in part 3.
  • Letting the agent rewrite old tests. That hides exactly the change in meaning you need to see.
  • A rule with an unknown field that loads. It silently never fires, and a DENY rule that never fires accepts what it was written to stop.
  • Calling the candidate’s hindsight “Stripe’s feedback”. The only relayed feedback is from a different round.

Go deeper

Family