Skip to content

bug(platform): a task run that runs out of memory after 15 minutes of work is retried without end #5148

Closed

Description

@tale-code-bot

Split from #3977 ("OOM deaths are classified and backed off" and "Person-started retries are
capped"), re-checked against main at b2560c2 (TALE-47). Line references are against that
commit.

What happens

Since #4633 and #4643, a run whose sandbox ran out of memory fails as resource_exhausted. Its
retry waits 2, then 10, then 30 minutes (RESOURCE_EXHAUSTED_RETRY_DELAYS_MS,
services/platform/backend/core/tasks/task_auto_retry.ts:37). The wait is chosen from the failed
run's attempt (services/platform/backend/domains/tasks/agent-runs.ts:926). But the retry budget
never ends such a chain when each attempt works for a while first:

  1. The budget resets on any long attempt. resolveAutoRetryBudget ends the streak at any
    failure that ran for 15 minutes or more (if (executedMs(row) >= AUTO_RETRY_PROGRESS_MS) break;,
    task_auto_retry.ts:318), whatever its failure code. The retry then shows attempt 1 (:331).
    So the next out-of-memory wait is 10 minutes again and never reaches 30.
  2. A person's runs are never counted. The per-task hourly breaker
    (AUTOMATED_STARTS_PER_TASK_PER_HOUR = 3,
    services/platform/backend/domains/tasks/delegated-start.ts:160) counts only runs that carry
    started_via (:279). The retry job admits the retries of a person's run without that check
    (services/platform/backend/jobs/task-list.ts:457-459). A test pins this
    (task-list.agent-retry.test.ts:690), and the docs say so
    (docs/en/platform/projects/task-automation.md:133).
  3. Automated chains pass the breaker too. Each cycle is at least 15 minutes of work plus a
    10-minute wait, so no more than two counted starts fall within any hour.

A task whose work does not fit its sandbox's memory (say, a build OOM-killed after 20 minutes) is
therefore retried about every half hour. That goes on until a person moves, reassigns or cancels
the task, and every attempt pays for the model again. In #3977's incident, one task ran 8 times
and another spent 554 run-minutes over 7 runs.

Expected

  • A resource_exhausted failure counts toward the three-retry budget however long it ran.
    • Once three retries in a row have also run out of memory, the chain ends with the existing
      notice (tasks.agentRun.failure.out_of_memory).
    • The wait grows from 2 to 10 to 30 minutes across them.
    • Unit tests go in task_auto_retry.test.ts, plus an integration case for settle → held retry
      → retry.
  • The automation lane resets the same way (services/platform/backend/core/automations/agent_retry.ts:268).
    Apply the same rule there, or say on this issue why not. feat(platform): hold an automation agent node that ran out of memory for 10 and 30 minutes too #4723 covers that lane's wait.
  • Decide whether a person's run's automatic retries also count against a per-task cap, as Bug: concurrent runs of one agent pile into one sandbox session and can exhaust the host #3977
    asked, and record the decision here. If they do, the test at :690 and the docs at :133
    change with it.
  • The user docs name the out-of-memory case. task-automation.md:137 says retries "start right
    away except in the cases below". Neither those cases nor When the agent can't finish
    (:151) mention running out of memory.

Related

Activity

  1. added
    agent-ready
    on Oct 30, 2026
  2. tale-code-bot commented on Oct 30, 2026

    @tale-code-bot
    CollaboratorAuthor

    Decisions for this issue, from board task TALE-244. The change is on branch fix/oom-retry-budget (head 214cc86b85476b23178d95bbb1153099900fdb63, on train at 3024254a0df1b2c6c4a6149bd0845e0d8402f430) and waits for review. Once landed, it reaches main with the next fix train.

    An out-of-memory failure counts however long it ran. There is now one rule, refreshesRetryBudget in services/platform/backend/core/tasks/task_auto_retry.ts: an attempt that worked 15 minutes or more refreshes the retry budget, unless it failed resource_exhausted. resolveAutoRetryBudget uses it, and so does the attempt a free credential rotation keeps. A run that keeps running out of memory is now retried as attempts 1, 2 and 3, after waits of 2, 10 and 30 minutes. When the third retry runs out of memory too, the run fails for good with the existing out-of-memory notice.

    The automation lane follows the same rule. planWorkflowAgentRetry in services/platform/backend/core/automations/agent_retry.ts calls the same refreshesRetryBudget, so an agent node that keeps running out of memory stops after its third re-kick. That lane's wait is unchanged and stays with #4723.

    Decision: a person's run's automatic retries count against the per-task cap. The hourly breaker (AUTOMATED_STARTS_PER_TASK_PER_HOUR = 3) now counts every automatic retry, whoever started the run it continues: it counts each run row with started_via or the auto_retry trigger. The retry job admits every retry through admitAutomatedStart, and a refused retry ends that run's retries with the failure notice. A person's own Start (Start agent, a mention, a move to In progress) is still never counted or refused.

    Why:

    The tests and docs changed with the decision:

    • task-list.agent-retry.test.ts: the test at :690 now pins that the retry is counted, and a new test pins its refusal once the hour holds three automated starts.
    • The spec: TASK-R12 is rewritten, and the new TASK-R84 is the out-of-memory rule.
    • The docs, in EN, DE and FR: task-automation.md, triggers.md and execution-logs.md.

    The user docs name the out-of-memory case. task-automation.md now gives the 2, 10 and 30 minute waits and says that an out-of-memory failure counts however long the run worked. When the agent can't finish gains a row for a sandbox that ran out of memory.

    Proof

    • Unit tests pass in the worker, under [TASK-R84] and [TASK-R12], in:
      • task_auto_retry.test.ts
      • agent_retry.test.ts
      • delegated-start.budget.test.ts
      • task-list.agent-retry.test.ts
    • A new real-Postgres lane, checkOutOfMemoryRetryBudget in backend:integration, runs settle → held retry (2, 10, 30 min) → retry three times, then the final failure. The worker has no Postgres, so that lane and the two lanes changed with the breaker were typechecked but not run there. The fix train's pull request runs them.
  3. added a commit that references this issue on Oct 30, 2026
    4f5a013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readybug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions