From 1e60cece12f5d11aebae8ef2bf4ccf0f7d0627fc Mon Sep 17 00:00:00 2001 From: Bohan Jiang <52446949+Bohan-J@users.noreply.github.com> Date: Thu, 6 Aug 2026 13:23:50 +0800 Subject: [PATCH] chore(daemon): halve the local version-probe frequency to 10 minutes (#6483) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both local probes ran every 5 minutes. Neither has caused a measured problem, but background work a user never asked for should justify its cadence, and 5 minutes was tighter than either needs. 10 minutes for both, and the remote GitHub poll stays at 6 hours. That split is the point: only the remote poll asks whether a new release exists, so only it should track release cadence. The two local probes ask whether the binary on this machine has already changed, which is bounded by how long a user is willing to wait after acting, not by how often we ship. Not longer than 10 for either. selfReloadCheckInterval compounds, because a tick landing on a busy daemon defers rather than interrupting a task, so the real wait is the first tick that is both due and idle. agentVersionRefreshInterval also gates the below-minimum verdict, so its interval is the window an unsupported CLI keeps claiming work — cost alone should not push it out. Tests override both vars, so none needed updating. Co-authored-by: multica-agent --- server/internal/daemon/agents_refresh.go | 15 ++++++++++++++- server/internal/daemon/auto_update.go | 12 +++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/server/internal/daemon/agents_refresh.go b/server/internal/daemon/agents_refresh.go index b58100c0f0..9594249d3e 100644 --- a/server/internal/daemon/agents_refresh.go +++ b/server/internal/daemon/agents_refresh.go @@ -27,7 +27,20 @@ var agentConvergeMaxBackoff = 30 * time.Minute // of codex/claude is picked up without a restart. A round is one `--version` // fork per installed CLI, fanned out and machine-level — it does not scale with // workspace count or runtime count. Overridable for tests. -var agentVersionRefreshInterval = 5 * time.Minute +// +// This is the one local probe whose cost grows with the host (one fork per +// installed CLI) and which executes third-party binaries, some of whose +// wrappers have visible side effects when run — so it is the one worth +// lengthening if background probing needs to get cheaper. +// +// It is not lengthened further than selfReloadCheckInterval, though, because +// the round does more than refresh a displayed version string: it also keys +// version-sensitive launch policy, and it is what confirms a CLI has dropped +// below its minimum supported version and must stop being given work. The +// interval is therefore also the window in which an unsupported CLI keeps +// claiming tasks, which is why this tracks the reload check rather than being +// pushed out on cost grounds alone. +var agentVersionRefreshInterval = 10 * time.Minute // agentDiscoveryLoop keeps the registered runtime set converged on the agent // CLIs actually installed on this machine, so a CLI installed while the daemon diff --git a/server/internal/daemon/auto_update.go b/server/internal/daemon/auto_update.go index 40b1c22044..646e4e2e14 100644 --- a/server/internal/daemon/auto_update.go +++ b/server/internal/daemon/auto_update.go @@ -73,7 +73,17 @@ var autoUpdateInitialDelay = 2 * time.Minute // re-exec. One fork/exec per tick, machine-level (not per workspace, not per // runtime), so the cost is fixed no matter how big the daemon's workload is. // Overridable for tests. -var selfReloadCheckInterval = 5 * time.Minute +// +// The value bounds how long a user waits after replacing the binary themselves, +// not how often we ship: the "is there a new release" question belongs to +// DefaultAutoUpdateCheckInterval, and only that one should track release +// cadence. It also compounds, because a tick that lands while the daemon is +// busy defers to the next one rather than interrupting a task — so the wait is +// really "the first tick that is both due and idle". Ten minutes keeps the +// average wait around five and the multiplier tolerable on a busy host; an hour +// would not, and would put us back in sight of the "I upgraded and nothing +// happened" problem this check exists to remove. +var selfReloadCheckInterval = 10 * time.Minute // selfReloadProbeTimeout bounds the `--version` fork/exec. Generous: the point // of the timeout is to stop a wedged binary from parking the loop goroutine,