Let the orchestrator own fan-in for parallel agent subtasks: all, k-of-n or first valid, a deadline, late results that never change the decision, and a veto that must be waited for.
Fan-out is easy, fan-in is the design
Agent systems often split one question into parallel subtasks. A refund request on a help-desk case might go to four checks at once: one reads the refund policy against the order, one looks at the customer's order history, one looks for fraud signals, and one confirms the payment state. Starting four calls in parallel is one line of code. Deciding when the case has an answer is the actual design problem, and it is often left to whatever the framework does by default, which is usually to wait for everything.
Wait-for-all has two problems. The case is as slow as the slowest subtask, so a fraud service that takes nine seconds makes every refund take nine seconds. And one failed subtask can stall or fail the whole decision, even when the remaining results are clear. The opposite default, letting a model read whatever has come back and decide when it has seen enough, makes the join non-deterministic: two runs with the same inputs can stop at different points and use different evidence.
This guide puts the join policy in the orchestrator. The orchestrator chooses among three policies, all, k-of-n agreement and first valid, applies a deadline, treats results that arrive after the decision as late, lists subtasks to cancel, and writes down exactly which results the decision used. It also covers the case that a plain quorum gets wrong: a check that can veto.
Three policies and a deadline
A join policy answers one question: given the results so far, is the decision made?
all: the decision waits for every subtask, or for the deadline. If any subtask failed, the policy cannot be satisfied and the case escalates. If results disagree, it escalates.quorum: the decision is made as soon as k results agree on the same verdict. Failures do not count towards the quorum.first_valid: the first well-formed result decides. Failures are skipped.
Every policy has a deadline. If the policy is not satisfied by then, the verdict is escalate, which in this system means a person reviews the case. The deadline is part of the policy, not a timeout buried in an HTTP client, because it decides the outcome, not just when a call gives up.
Two details make the join auditable. First, the decision record lists the ids of the results it used and the ids of the subtasks that failed. Second, anything that finishes after the decision is late: it is recorded, and it is never allowed to change the verdict. Without that rule, a slow subtask that disagrees can reopen a case that was already answered, and the answer the customer received depends on timing.
The worked run
The companion example simulates four subtasks with fixed timings, in seconds after dispatch:
- policy-reader approves at 0.8 s;
- payment-check fails at 1.2 s, with a timeout calling the payment service;
- order-history approves at 2.5 s;
- fraud-signals rejects at 9.0 s.
Five joins over the same subtasks give five different results.
all with a 12 s deadline waits until 9.0 s, sees the payment-check failure and escalates. Every result arrived, and the policy still could not produce an answer.
all with a 5 s deadline escalates at 5.0 s and lists fraud-signals for cancellation.
quorum with k = 2 and a 5 s deadline approves at 2.5 s. The decision record says it used policy-reader and order-history, that payment-check failed, and that fraud-signals is late.
quorum with k = 3 cannot get a third approval before the deadline and escalates at 5.0 s.
first_valid approves at 0.8 s on policy-reader alone and lists the other three for cancellation.
The k = 2 quorum is the interesting one. It is fast and it approved the refund, and the fraud check that would have said no was ignored, because it was late. Whether that is acceptable depends on what fraud-signals is for, and that is the next section.
A quorum cannot overrule a veto
A quorum treats subtasks as interchangeable voters. That is right when subtasks are redundant: three replicas of the same classifier, or three retrieval strategies looking for the same document. It is wrong when one subtask has a different role. A fraud check is not one vote among four; if it says no, the answer is no, however many other checks approved.
The example models that with a required set. A required subtask must report before any policy can decide, and if it rejects, the verdict is reject immediately:
pending_required.discard(s.id)
if s.id in required and s.verdict == 'reject':
used = [s]
decided_at, verdict, reason = s.finishes_at, 'reject', f'required check {s.id} rejected'
break
if pending_required:
continueWith fraud-signals required and a 12 s deadline, the quorum join waits for it and rejects at 9.0 s, using only fraud-signals. With a 5 s deadline, the required check has not reported in time, so the join escalates at 5.0 s instead of approving. Declaring a veto check costs latency: the decision can never be faster than the veto. That cost is the honest price of the rule, and it is better paid knowingly than discovered in an incident review.
What stays deterministic
The model's job in this design is narrow. Each subtask may well be an agent, with its own model calls and tools. The join is not. Which policy applies, what k is, which checks are required, how long the deadline is, which results were used and what happens to late ones are all orchestrator code and configuration. Two runs with the same subtask results produce the same decision record.
That is the same split workflow engines have always made. AWS Step Functions' Parallel state, for example, runs branches and waits for all of them, and fails the whole state if a branch fails unless the workflow catches the error. Python's asyncio.wait offers FIRST_COMPLETED, FIRST_EXCEPTION and ALL_COMPLETED, which are the primitives a quorum join is built from. The agent era does not change the mechanics; it adds pressure to let a model decide when to stop, and that pressure should be resisted.
Cancelling and ignoring late work
Listing a subtask for cancellation is not the same as stopping it. A subtask that has already called a service may still complete its side effect after the decision, and a model call that is in flight is usually billed whether or not you read the result. Make subtasks safe to abandon: read-only checks are easy, while anything that writes must be idempotent or must wait for the decision before acting. Cancellation should be best effort, and the decision must never depend on it succeeding.
Late results still have value. Record them with the case, because a late fraud rejection on an approved refund is exactly the signal a reviewer wants to see. It belongs in a follow-up queue, not in the decision that already went out.
Choosing a policy
A rough guide from the run above:
- Use
first_validwhen subtasks are redundant ways of getting the same answer, and any valid answer is acceptable. Hedged requests to two replicas are the classic case, described in Dean and Barroso's work on tail latency. - Use
quorumwhen subtasks are independent judges and agreement is the signal, and declare any check with a veto as required. - Use
allwhen every result is an input to the decision rather than a vote, such as gathering documents for a summary, and accept that a failure escalates.
And sometimes one subtask is enough. If the four checks above are really one policy question that a single well-instrumented call can answer, fanning out adds cost, failure modes and a join to maintain without adding evidence. Parallel subtasks earn their place when they bring different evidence or protect against a slow or failing dependency.
Failure modes
A deadline that is too short turns every case into an escalation, which hides the problem in a human queue. Track the escalation rate per reason, because "deadline reached" and "a subtask failed" call for different fixes.
A quorum over correlated judges is weaker than it looks. Two agent subtasks that use the same model and the same retrieved documents are not independent, and their agreement is closer to one vote than two.
Retries inside subtasks interact with the deadline. A subtask that retries three times with backoff may never finish before the deadline, and the join will escalate every time that dependency is slow. Set subtask retry budgets from the join deadline, not separately.
Verification
The companion example has eight tests: wait-for-all escalates on a failure, a deadline escalates when it passes, a two-of-n quorum decides when two agree and names them, failures do not count towards a quorum, late dissent never changes a decision, first valid skips failures, a required veto is waited for and can reject, and invalid inputs are refused. Time is simulated, so every result is deterministic. Run python -m unittest -v in the example directory.
Run the example yourself
The four simulated subtasks, the all, quorum and first-valid joins with a deadline and a required veto, and eight tests. Companion code on GitHub; its README lists the prerequisites, exact commands, expected output and limits.