Distributed ReliabilityQueue recovery and health restorationPrincipal
How should an agent propagate one end-to-end deadline through retrieval, model calls, retries and tools?
By Amit Kumar2 min readWorked answer includedReviewed 28 Sept 2026
The question
Interview question
A 20-second request spends 12 seconds retrieving and 7 generating a tool call. Downstream gateways and SDK retries each start fresh timeouts. Design remaining-budget propagation, local clocks and cancellation. Explain feasibility near expiry, transport margin and a separately authorized durable background deadline.
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
One end-to-end deadline should bound the user-visible operation. Each hop receives the remaining budget and may choose a smaller local timeout. Resetting the clock at each hop converts a 20-second promise into an unbounded chain of individually legal waits. gRPC's deadline guide describes propagation that subtracts elapsed time rather than blindly forwarding an absolute timestamp across unsynchronized clocks. The implementation details depend on the transport and asynchronous workflow, but the principle holds: queueing, inference, retries and tools all spend from the same budget.
Use a local monotonic clock to measure elapsed time at each process. Forward the remaining duration with a conservative allowance for transit and response/state-recording work. An absolute shared timestamp needs a bounded clock-skew assumption. Passing a duration avoids comparing unsynchronized wall clocks, but forwarding it unchanged after local queueing would still renew the budget accidentally.
I would trace the original deadline and remaining budget at every boundary, including queues. If only one second remains when the tool call is ready, do not start a ten-second action and hope. Return a partial or timeout response, or transition to a separately authorized background task with a new contract. A local database statement timeout and cancellation signal should stop work that no longer helps, but cancellation is not proof an external side effect did not commit. For non-idempotent actions, reconcile the outcome before deciding whether to retry or tell the user it failed.
The scheduler should decide what can finish with the time left. A fast cached answer may be viable while long retrieval is not. Preserve a margin for streaming a coherent response and recording state. For asynchronous agent runs, there can be a durable job deadline separate from the interactive HTTP deadline. Name both and state which operation each governs. Do not hide background continuation behind a user request that was supposedly cancelled.
What if the tool has its own strict minimum runtime? Then either start it earlier, ask for an asynchronous handoff, or decline to promise a 20-second completion for that route. The user closed the chat. Why are GPUs still finishing their answer? covers GPU work continuing after chat disconnect. A model stream fails after the user has seen half an answer covers a stream failing after half an answer. This question is about time budget being recreated at service boundaries, making downstream work exceed the original promise even while every individual component reports a successful timeout policy.
Related questions
Keep practising distributed reliability
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