mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-29 14:37:44 +02:00
When the server deletes a task while the daemon's agent is still running (issue removed, agent reassigned, workspace cleanup), GetTaskStatus starts returning 404 "task not found". The previous polling loop only checked for status == "cancelled" and silently swallowed the error, so the local agent kept emitting tool calls against a dead task until its own timeout fired — minutes of wasted model spend and patch_apply operations against a workdir nobody would consume. Changes: - Add isTaskNotFoundError next to isWorkspaceNotFoundError so the daemon can distinguish "task gone" 404 from "workspace gone" 404 (already handled separately) and from generic network errors. - Extract the cancellation polling goroutine in handleTask into watchTaskCancellation, plus a pure shouldInterruptAgent decision helper. The pure helper makes both signals (cancelled status and 404 task) easy to unit-test without spinning up a real backend. - Trigger interruption on the new 404 path. Transient errors (5xx, network) intentionally still don't cancel — the next poll will retry and a flaky link should not kill an in-flight agent. Tests cover the helper truth table, the existing "status cancelled" path, the new "task deleted (404)" path, and a negative case ensuring a running task is not interrupted. Co-authored-by: “646826” <“646826@gmail.com”>
32 KiB
32 KiB