Durable and Asynchronous Agent Work › Deadlines

Michael BrenndoerferDecember 1, 20263 min read
Language AI HandbookAll chapters
Part 49 of 67Long-Horizon Agents and Interoperability
Chapter 376Durable and Asynchronous Agent Work › Deadlines
Reading section 10 of 15 · Deadlines · 3 minSection 10 of 15 · 3 min

Section 10 of 15 · 3 min read

Reading settings

Definitions

Choose how many terms have tooltips.

Article links

Make inline references clickable

Notes & comments

A claim can expire after admission. The worker tests the deadline in the same transaction as each state transition. The demo sets the persisted deadline to the past after claiming the task, then checks that no tool executes.

The SQLite runner only checks whether the persisted deadline has elapsed. It does not forecast a step’s duration or pass a timeout to the stub. The separate cost illustration asks whether a proposed step would fit in a hypothetical remaining budget. A production executor needs its own timeout or cancellation contract for work that has already started.

PythonIn [31]
CollapseExpand
EXECUTED.clear()
tid4 = submit("draft_report", {"topic": "deadline"}, deadline_seconds=60)
task4 = claim_task("D")
# Inject deadline expiry after admission without waiting for the wall clock.
expired_at = time.time() - 1
with tx() as con:
    con.execute(
        "UPDATE tasks SET deadline = ? WHERE id = ?", (expired_at, tid4)
    )
task4["deadline"] = expired_at
deadline_exceeded = time.time() > task4["deadline"]
res = run_task("D", task4)
ConsoleOut [32]
CollapseExpand
deadline already exceeded: True
result: failed:deadline
tools executed: []
final status: failed

The result reports a deadline failure and the stub call list stays empty. If the deadline instead passes during a stub, its cache row can already exist when the guarded completion rejects the result event. Later reconciliation can then see a cached but unrecorded call. This demo does not cancel work that had already started.

This separate example schedules hypothetical steps using their known toy costs. The 20-second budget and step costs 1, 8, 9, and 6 seconds leave 20, 19, 11, and 2 seconds before the respective steps. Only the first three fit.

PythonIn [33]
CollapseExpand
budget_seconds = 20.0
step_costs = np.array([1.0, 8.0, 9.0, 6.0])
cumulative_cost = np.cumsum(step_costs)
remaining_before = budget_seconds - np.concatenate(
    ([0.0], cumulative_cost[:-1])
)
would_fit = remaining_before >= step_costs
VisualizationOut [34]
CollapseExpand
Grouped bars comparing step cost versus remaining deadline budget.
Each step's cost compared against the remaining deadline budget. A hypothetical forecast-based admission check would stop at the first step that exceeds the remaining budget.

The hard deadline blocks further guarded transitions and causes the runner to record failure when a valid owner next reaches a deadline check. A soft deadline can leave time to return partial work. The service executing a call needs its own timeout or cancellation to bound work already underway.

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