Agent ArchitectureMulti-agent coordinationPrincipal
How do you prevent discarded speculative agent branches from committing external effects?
By Amit Kumar2 min readWorked answer includedReviewed 28 Sept 2026
The question
Interview question
A planner explores two branches and discards one after it has submitted a card charge. Design a boundary between speculative proposals and committed actions, including winner selection and stable operation identity. Explain recovery for an already sent charge and the additional ownership required for temporary reservations.
Draft your approach first
Take a few minutes before you read the answer. Name the constraint that matters most, the failure you are designing for and how you would know it worked.
Reveal the worked answerWorked answer
The planner ran two branches to compare options. One branch issued a payment call before the winner was chosen. Dropping that branch's text, memory or workflow state did not undo a request already sent to a payment provider. Cancelling local branch work does not reverse a provider request already sent. Temporal's cancellation guidance describes cancellation reaching activities at the next available opportunity, which is useful context but not a guarantee that the remote service has reversed anything.
I would draw a hard boundary between speculative investigation and committed action. Competing branches may read prices, build proposals and validate constraints. They should not send an irreversible tool call until the coordinator selects one concrete proposal, binds it to an approval if needed and submits it through an action service. That service checks the selected branch ID, current authority, amount and target, and assigns a stable idempotency key for this business action. A losing branch has no capability to commit. This is more reliable than asking every branch to cancel itself quickly enough.
Make winner selection and commit eligibility explicit. If branches A and B propose different purchases for one intent, the coordinator must durably select one proposal revision. The action service validates that selected revision when accepting the operation, rather than trusting a branch’s claim that it won. A stale selection message cannot create another accepted intent after the coordinator changes course. If a first operation is already submitted, an intent change starts reconciliation and a new decision, not an automatic replacement charge.
If the unsafe call already went out, trace branch IDs, tool request IDs, provider response, action state and when the coordinator declared a winner. The provider may have charged even if our tool timed out. Reconcile against the provider using a stable operation identity before retrying or issuing a refund. Do not assume compensating a charge is equivalent to making it never happen. Fees, customer notifications and accounting entries may survive compensation.
The interviewer may ask about fast speculative work that needs reservations. A reservation can be a deliberate, expiring side effect with a bounded hold and a release protocol, but it still consumes inventory and needs ownership and cleanup. Decide whether that cost is acceptable, then make reservation IDs visible to the coordinator. The agent rolled back a failed branch. Why does the next model call remember it? deals with a failed branch whose inference state still influences the next model call. This case is about a losing branch whose real-world effect cannot be removed by clearing the model state.
Related questions
Keep practising agent architecture
Follow another question in this area, or search the complete library.
Get my essays on AI engineering and distributed systems by email. Subscribe to ArchCrux