Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(daemon): log the effective idle watchdog window (#11085)
Danila Katalshov3fce748633b3
diff --git a/server/internal/daemon/daemon.go b/server/internal/daemon/daemon.goindex 41953ef4c0..43910d3d2c 100644--- a/server/internal/daemon/daemon.go+++ b/server/internal/daemon/daemon.go@@ -9489,7 +9489,7 @@ func (d *Daemon) runTask(ctx context.Context, task Task, provider string, slot i"inline_system_prompt", execOpts.SystemPrompt != "","resume_session", execOpts.ResumeSessionID != "","timeout", execOpts.Timeout,- "idle_watchdog", execOpts.IdleWatchdogTimeout,+ "idle_watchdog_override", execOpts.IdleWatchdogTimeout,)// MUL-9013: record what this run is being handed, before it starts, so a@@ -10402,6 +10402,7 @@ func (d *Daemon) executeAndDrain(ctx context.Context, backend agent.Backend, prowatchdogCtx, stopWatchdog := context.WithCancel(agentCtx)defer stopWatchdog()if idleWindow > 0 {+ taskLog.Debug("idle watchdog armed", "window", idleWindow)go d.runIdleWatchdog(watchdogCtx, idleWindow, d.cfg.AgentToolWatchdog, &lastActivityAt, watchdogToolCount, &idleWatchdogFired, &idleWatchdogThreshold, agentCancel, session.Messages, session.InterruptBackgroundTools, terminalObserved, taskLog)}diff --git a/server/internal/daemon/daemon_test.go b/server/internal/daemon/daemon_test.goindex 3db9a9eef6..8cded80357 100644--- a/server/internal/daemon/daemon_test.go+++ b/server/internal/daemon/daemon_test.go@@ -1,6 +1,7 @@package daemonimport (+ "bytes""context""encoding/json""errors"@@ -4733,6 +4734,45 @@ func TestExecuteAndDrain_IdleWatchdog_HappyPathDoesNotFire(t *testing.T) {}}+func TestExecuteAndDrain_LogsEffectiveIdleWatchdog(t *testing.T) {+ t.Parallel()++ for _, tt := range []struct {+ name string+ global time.Duration+ override time.Duration+ want string+ }{+ {name: "global window", global: 15 * time.Minute, want: "window=15m0s"},+ {name: "shorter override", global: 15 * time.Minute, override: 5 * time.Minute, want: "window=5m0s"},+ {name: "longer override", global: 5 * time.Minute, override: 15 * time.Minute, want: "window=5m0s"},+ {name: "globally disabled", override: 5 * time.Minute},+ } {+ t.Run(tt.name, func(t *testing.T) {+ d := newTestDaemon(t)+ d.cfg.AgentIdleWatchdog = tt.global+ backend := &fakeBackend{results: []agent.Result{{Status: "completed"}}}+ var logs bytes.Buffer+ log := slog.New(slog.NewTextHandler(&logs, &slog.HandlerOptions{Level: slog.LevelDebug}))++ _, _, err := d.executeAndDrain(context.Background(), backend, "p",+ agent.ExecOptions{IdleWatchdogTimeout: tt.override}, log, "t-idle-log", "", new(atomic.Int32))+ if err != nil {+ t.Fatalf("run backend: %v", err)+ }++ line := "msg=\"idle watchdog armed\""+ if tt.want == "" {+ if strings.Contains(logs.String(), line) {+ t.Fatalf("disabled watchdog logged as armed: %s", &logs)+ }+ } else if !strings.Contains(logs.String(), line+" "+tt.want) {+ t.Fatalf("missing armed watchdog with %s: %s", tt.want, &logs)+ }+ })+ }+}+// longToolCallBackend simulates a legitimate long-running tool call (e.g.// `npm install`, `docker build`, full test suite). The backend emits a// tool_use, stays silent past the idle window while the tool runs, then emits