Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(agent): report runtime version probe timeouts (#10908)
Danila Katalshov1ebe305375f9
diff --git a/server/pkg/agent/agent_test.go b/server/pkg/agent/agent_test.goindex 9e49efa706..ae5d18e231 100644--- a/server/pkg/agent/agent_test.go+++ b/server/pkg/agent/agent_test.go@@ -2,6 +2,7 @@ package agentimport ("context"+ "errors""fmt""os""path/filepath"@@ -130,8 +131,8 @@ func TestDetectVersionTimesOutOnHang(t *testing.T) {select {case err := <-done:- if err == nil {- t.Fatal("expected an error from a hanging --version probe, got nil")+ if !errors.Is(err, context.DeadlineExceeded) || !strings.Contains(err.Error(), "version probe timed out") {+ t.Fatalf("hanging --version probe error = %v, want an explicit timeout", err)}if elapsed := time.Since(start); elapsed > 5*time.Second {t.Fatalf("detection took %v; expected it to be bounded by the timeout", elapsed)diff --git a/server/pkg/agent/claude.go b/server/pkg/agent/claude.goindex 4b9cad1c35..c7d6d58eaa 100644--- a/server/pkg/agent/claude.go+++ b/server/pkg/agent/claude.go@@ -1569,6 +1569,21 @@ func cleanupMcpConfigTemp(path string) {// tests can shrink it without waiting out the real bound.var detectVersionTimeout = 10 * time.Second+// Keep the deadline in the error chain without its network-timeout wording:+// task failures are also classified from the diagnostic text.+type versionProbeTimeoutError struct {+ limit time.Duration+ cause error+}++func (e *versionProbeTimeoutError) Error() string {+ return fmt.Sprintf("version probe timed out (limit %s): %v", e.limit, e.cause)+}++func (e *versionProbeTimeoutError) Unwrap() []error {+ return []error{context.DeadlineExceeded, e.cause}+}+func detectCLIVersion(ctx context.Context, runtimeCmd Command) (string, error) {ctx, cancel := context.WithTimeout(ctx, detectVersionTimeout)defer cancel()@@ -1661,8 +1676,8 @@ func versionProbeRejectedArgs(ctx context.Context, err error) bool {}// runVersionProbe runs one `<cli> <args>` version probe and returns the-// recognised version line. The error is unwrapped; detectCLIVersion adds the-// command and the exec diagnosis.+// recognised version line. detectCLIVersion adds the command and the exec+// diagnosis to any probe error.func runVersionProbe(ctx context.Context, runtimeCmd Command, args []string) (string, error) {var cmd *exec.Cmd_, zcodeDesktop := zcodeDesktopScript(runtimeCmd.Path)@@ -1697,6 +1712,9 @@ func runVersionProbe(ctx context.Context, runtimeCmd Command, args []string) (stif salvageProbeAnswer(runtimeCmd, strings.Join(args, " "), recognised, err) {return version, nil}+ if ctx.Err() == context.DeadlineExceeded {+ return "", &versionProbeTimeoutError{limit: detectVersionTimeout, cause: err}+ }return "", err}return version, nildiff --git a/server/pkg/agent/version_probe_unix_test.go b/server/pkg/agent/version_probe_unix_test.goindex 8d11a1323b..32d04f4c7d 100644--- a/server/pkg/agent/version_probe_unix_test.go+++ b/server/pkg/agent/version_probe_unix_test.go@@ -4,12 +4,16 @@ package agentimport ("context"+ "errors""fmt""os"+ "os/exec""path/filepath""strings""testing""time"++ "github.com/multica-ai/multica/server/pkg/taskfailure")// fakeHermesForVersionProbe writes a fake hermes that appends each argv it is@@ -108,8 +112,16 @@ func TestDetectVersionHermesDoesNotFallBackOnTimeout(t *testing.T) {detectVersionTimeout = time.Secondt.Cleanup(func() { detectVersionTimeout = orig })- if _, err := DetectVersion(context.Background(), Command{Path: script}.ForVersionProbe("hermes")); err == nil {- t.Fatal("expected an error from a hanging probe, got nil")+ _, err := DetectVersion(context.Background(), Command{Path: script}.ForVersionProbe("hermes"))+ if !errors.Is(err, context.DeadlineExceeded) || !strings.Contains(err.Error(), "version probe timed out") {+ t.Fatalf("hanging Hermes probe error = %v, want an explicit timeout", err)+ }+ var exitErr *exec.ExitError+ if !errors.As(err, &exitErr) || !strings.Contains(err.Error(), exitErr.Error()) || !strings.Contains(err.Error(), script) {+ t.Fatalf("hanging Hermes probe error = %v, want the executable and original process error", err)+ }+ if got := taskfailure.Classify(err.Error()); got != taskfailure.ReasonAgentProcessFailure {+ t.Fatalf("hanging Hermes probe classification = %s, want %s; error: %v", got, taskfailure.ReasonAgentProcessFailure, err)}// The kill can land before a cold shell writes its log line, so assert only// that the root --version never ran.@@ -120,6 +132,15 @@ func TestDetectVersionHermesDoesNotFallBackOnTimeout(t *testing.T) {}}+func TestDetectVersionNonzeroExitIsNotATimeout(t *testing.T) {+ script, _ := fakeHermesForVersionProbe(t, `exit 3`)+ _, err := DetectVersion(context.Background(), Command{Path: script})+ var exitErr *exec.ExitError+ if !errors.As(err, &exitErr) || exitErr.ExitCode() != 3 || errors.Is(err, context.DeadlineExceeded) {+ t.Fatalf("version probe error = %v, want ordinary exit status 3", err)+ }+}+// Every other provider keeps the plain `--version` probe.func TestDetectVersionOtherProvidersKeepRootVersion(t *testing.T) {script, record := fakeHermesForVersionProbe(t, `echo 1.2.3`)