From 8a94600b1e2b54303e445b4f7154c7a7cfe7b438 Mon Sep 17 00:00:00 2001 From: DBT Date: Sun, 1 Mar 2026 14:45:43 +0000 Subject: [PATCH] autonomy: avoid immediate redispatch of running tasks after restart until pending timeout --- pkg/autonomy/engine.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/autonomy/engine.go b/pkg/autonomy/engine.go index 25e4a2e..314c188 100644 --- a/pkg/autonomy/engine.go +++ b/pkg/autonomy/engine.go @@ -350,6 +350,11 @@ func (e *Engine) tick() { continue } } + // Keep running tasks intact across ticks/restarts until pending timeout, + // so a gateway restart won't immediately redispatch from scratch. + if !st.LastRunAt.IsZero() && now.Sub(st.LastRunAt) <= time.Duration(e.opts.MaxPendingDurationSec)*time.Second { + continue + } } if st.Status == "blocked" { e.releaseLocksLocked(st.ID)