Durable and Asynchronous Agent Work › Duplicate delivery and fencing

Michael BrenndoerferDecember 1, 20262 min read
Language AI HandbookAll chapters
Part 49 of 67Long-Horizon Agents and Interoperability
Chapter 376Durable and Asynchronous Agent Work › Duplicate delivery and fencing
Reading section 8 of 15 · Duplicate delivery and fencing · 2 minSection 8 of 15 · 2 min

Section 8 of 15 · 2 min read

Reading settings

Definitions

Choose how many terms have tooltips.

Article links

Make inline references clickable

Notes & comments

Worker A stalls past its lease. Worker B acquires a new generation. In this fixture A fails its renewal before it can invoke a new step. The state store also checks ownership at commit, since renewal alone cannot protect against an old worker that remains active.

PythonIn [26]
CollapseExpand
EXECUTED.clear()
tid2 = submit("draft_report", {"topic": "split brain"})

t1 = claim_task("A")
t2 = None

# Simulate: A holds the lease, but stalls so long that B can claim.
time.sleep(LEASE_SECONDS + 0.5)
# B claims because A's lease has expired
t2 = claim_task("B")

# Now both A and B "run". A is stale: its renew_lease will fail.
a_result = run_task("A", t1)
b_result = run_task("B", t2)
ConsoleOut [27]
CollapseExpand
A: lost_lease
B: completed
real tool calls: 3 ['search', 'summarize', 'send_email']

Worker A stops when it tries to renew the old claim. Worker B can complete under the newer generation. Rejecting a stale write does not prevent an earlier external operation from taking effect.

The generation check rejects a stale writer even if the worker had earlier passed renewal. The sequence constraint protects event ordering. An external effect requires its own protection at the downstream service.

The local cache can admit a duplicate when both callers miss before either records a result, or when a crash interrupts the operation after an effect but before insertion. A remote service that enforces the logical key can narrow this window under its own contract.

Comments

Add to the conversation

A question, a correction, or an example from your own work.

No comments yet. Be the first to share your thoughts!

Newsletter

Stay up to date

Get new articles, book updates, and notes on AI and technology.

Unsubscribe at any time. Privacy policy