TL;DR: Schedule the batch instead of firing it. Run the independent reads concurrently, run writes in issue order, and refuse a second write to the same record in the same turn with an error that tells the model to reissue it after seeing the first result. Underneath, protect the record with optimistic concurrency (a version check on every write), because the same race can also come from another run, a person or a retry.
How to approach it
Ask what the writes are and whether they commute. Setting a delivery note and cancelling the order do not commute: the cancel can make the note meaningless, and their order matters. Then ask whether the record has a version or ETag, because that decides how much protection exists below the agent.
A strong answer
- 01model4 tool calls in one turn
model
4 tool calls in one turn
The scheduling rules, as a dispatcher implements them:
- Classify each call from tool metadata: read or write, and the resource it touches (here, the order id).
- Run reads concurrently, each with its own timeout and its own failure.
- Run writes after the reads, one at a time, in the order the model issued them.
- Refuse a second write to the same resource in the same turn. The model decided both writes before seeing either result, so the second is based on stale information. Refusing it costs one turn and gives the model the current state; racing it risks a corrupted or confusing record.
- Return every result under its call id, in issue order, including the refusal, so the model can pair them correctly.
Why refuse rather than run both in order? Running in issue order is acceptable when the writes are known to be independent (two different fields that never interact), but tool metadata rarely captures that, and guessing wrong is a data bug. Refusal is the conservative default; a tool that knows its writes commute can declare it and opt out.
Below the dispatcher: optimistic concurrency. The dispatcher only sees one run's batch. The same order can be changed by another run, a support agent in the admin console, or a retry from a crashed worker. The record itself needs protection: each read returns a version, each write sends the version it was based on, and the service rejects a write whose version is stale (precondition_failed: order changed since you read it). The model then rereads and decides again. This is the same compare-and-set any API uses for concurrent editors; agents just make concurrent editing more common.
And the writes still need idempotency keys. Refusal and version checks stop races; they do not stop the same write being repeated after a timeout. Every write carries a key derived from its intent.
What interviewers probe next
"The two writes touch different orders but share a customer credit limit. Is your per-resource rule enough?" No: the invariant spans resources. Either declare the customer's credit as the resource both writes touch, or enforce the limit in the service with a transaction, so the check and the deduction cannot interleave.
"Wouldn't it be simpler to turn off parallel tool calls?" For a write-heavy agent, possibly; measure turns per task and conflict rates both ways. For a read-heavy agent you would give up most of the latency win for a problem the scheduler already solves.
"What does the model see when the version check fails?" A correctable error with the current state ("order ord_004471 is now cancelled; your note was not saved") so its next decision is based on fact.
How it's scored
Weak: Runs all four calls concurrently, or runs them all sequentially without saying why, and does not consider the conflict.
Hire: Parallelises reads, serialises writes in issue order and refuses or orders conflicting writes to the same record with a clear error.
Strong Hire: Schedules from read/write and resource metadata, explains why refusal beats racing, adds optimistic concurrency on the record for races from outside the batch, keeps idempotency keys on writes, and handles invariants that span resources in the service.
Common mistakes
asyncio.gatherover every call because the API returned them together.- Assuming the dispatcher's batch is the only source of concurrent writes.
- Returning results in completion order, so the model attributes the cancel's result to the note.
- Treating a version-check failure as a terminal error instead of a reason to reread.