TL;DR: The executor runs steps without checking whether the facts the plan was built on still hold. Make plans record what they depend on: the versions of the records they read, preconditions per step, and assumptions about the world. Before each step with side effects, compare those against the current state (compare-and-set where the system supports it), and on a mismatch stop and replan from the current state, accounting for steps already done. Add event-driven triggers for long runs, a plan lifetime, and a replan cap.
How to approach it
Get a concrete failure from the traces: what changed (a record, a price, a person's decision), how long after planning, and what the executor did next. The fix depends on whether the change was visible to the agent (it read it and ignored it) or invisible (nothing told it).
A strong answer
The failure. An operations agent plans at 09:00 to rebalance stock: move 300 units from Pune to Delhi, then raise Delhi's reorder point, then notify the planning team. At 09:20 a person manually moves 250 units to Delhi. At 09:40 the executor runs step one anyway, because nothing in the plan said it depended on Delhi's stock level being what it was at 09:00. Delhi now has far too much stock.
Fix 1: plans carry their dependencies. Each step records the state it was planned against:
PLAN = [
{"step": "transfer", "args": {"from": "pune", "to": "delhi", "units": 300},
"read_versions": {"stock:delhi": 17, "stock:pune": 42}},
{"step": "set_reorder", "args": {"site": "delhi", "point": 500},
"read_versions": {"stock:delhi": 17}},
]
def run_step(step, current_versions, do):
seen = step["read_versions"]
stale = {k: (v, current_versions[k]) for k, v in seen.items()
if current_versions[k] != v}
if stale:
return {"status": "replan", "changed": stale}
return {"status": "done", "result": do(step)}
now = {"stock:delhi": 18, "stock:pune": 42} # someone changed Delhi at 09:20
out = run_step(PLAN[0], now, lambda s: "moved")
print(out["status"], out["changed"]) # => replan {'stock:delhi': (17, 18)}
Fix 2: check where the change happens. A version check in the agent still leaves a gap between the check and the write. Where the target system supports it, send the expected version with the write (compare-and-set, an If-Match header, a conditional update) so the system itself refuses a write against a changed record. The agent then treats the refusal as a replan trigger.
Fix 3: replan from the current state. The replan gets: the original goal, steps already completed and their effects, what changed and its new value, and remaining budget. Here: Delhi already received 250; the new plan might move 50, or nothing, and adjust the reorder point accordingly.
Fix 4: triggers for long runs.
- Before every write: the version check above.
- On events: subscribe to changes on the records the plan depends on, and pause the plan when one fires.
- On time: a plan older than its lifetime (an hour for stock, a day for a migration) is revalidated before continuing.
- On surprise: a step result outside what the plan expected.
Fix 5: limits. Cap replans per run; a run that keeps replanning because the world is changing faster than it can act should hand off to a person.
What interviewers probe next
"Why not replan before every step?" It costs a planning call each time and makes runs unpredictable. Version checks are cheap and say precisely when a replan is needed.
"What about steps already executed that the change made wrong?" The replan must consider compensation: reversing or adjusting completed steps (a transfer back, a cancelled order), with the same idempotency and approval rules as forward steps.
"The changed fact was in a document, not a versioned record." Use what freshness signals exist (a modified timestamp, an ETag, a hash of what was read) and recheck them before acting.
What if?
What if · interview follow-ups
Hold your answer as the constraints change
Your agent's plans record read versions and check them before each write.
Start here
What if the version changes for a reason that does not matter (an unrelated field)?
How specific is the dependency?
Record dependencies at the level that matters, such as the stock quantity field or a hash of the fields read, so unrelated edits do not force replans. Coarse versions cause needless replanning.
Carry it forwardDepend on what you read, not the whole record.
Weak answerTurning off checks because they fire too often.
Constraint changes
What if two agents plan against the same records at once?
Who wins the write?
Compare-and-set makes one write succeed and the other refuse; the loser replans with the new state. Without it, both apply and the later overwrites the earlier.
Carry it forwardConditional writes turn races into replans.
Weak answerA lock held for the whole plan, which blocks people and other agents.
Constraint changes
What if replans keep firing because a busy record changes every minute?
Can the plan keep up?
Shorten the gap between reading and writing for that step (re-read just before), widen the dependency to the decision that matters (enough stock, not exact count), or hand off once the replan cap is hit.
Carry it forwardFast-moving state needs late reads or tolerant conditions.
Weak answerRemoving the cap so it keeps trying.
Now defend it
One-line fix?
Plans record the versions and assumptions they depend on, writes check them (ideally as compare-and-set), and any mismatch replans from current state, with compensation for completed steps and a cap on replans.
How it's scored
Weak: Replans on a timer, or tells the planner to "consider that things may change".
Hire: Records preconditions and checks them before each step, replanning on mismatch.
Strong Hire: Records read versions or hashes per step, enforces them at the target with conditional writes, replans from current state with completed steps and compensation, adds event and lifetime triggers, scopes dependencies to the fields that matter, and caps replans.
Common mistakes
- Checking freshness in the agent but writing unconditionally, leaving a race window.
- Replanning from the original request, repeating completed steps.
- Coarse dependencies that cause constant replanning.
- No cap, so a busy system keeps the agent replanning forever.