Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(codearts): let model discovery fall back after a timeout (#11087)
Danila Katalshovcfebd296529e
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 3d3ba53e8c..a358878c6b 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -794,7 +794,7 @@ jobs:# still reports cleanup as unconfirmed, and that a descendant holding# inherited stdout neither keeps Result blocked nor survives cleanup.# -v makes RUN/PASS evidence explicit in CI logs.- run: go test ./pkg/agent -v -run '^(TestStartOwnedProcessTreeCapturesImmediateDescendants|TestStartOwnedProcessTreeLeavesNoSuspendedChild|TestWaitProcessGroupGoneWithoutOwnershipReportsUnconfirmed|TestCodexInitializeRetrySupportedWithOwnedProcessTree|TestCodexWindowsDescendantsDieWithTheOwnedProcessTree|TestCodeArtsWindowsCancellationTerminatesDescendants)$' -count=1 -timeout=5m+ run: go test ./pkg/agent -v -run '^(TestStartOwnedProcessTreeCapturesImmediateDescendants|TestStartOwnedProcessTreeLeavesNoSuspendedChild|TestWaitProcessGroupGoneWithoutOwnershipReportsUnconfirmed|TestCodexInitializeRetrySupportedWithOwnedProcessTree|TestCodexWindowsDescendantsDieWithTheOwnedProcessTree|TestCodeArtsWindowsCancellationTerminatesDescendants|TestDiscoverCodeArtsModelsRetriesAfterVerboseTimeout)$' -count=1 -timeout=5m- name: Test Windows Hermes gateway ownership and reservationworking-directory: serverdiff --git a/server/pkg/agent/codearts.go b/server/pkg/agent/codearts.goindex 857924938a..cc301eb9f1 100644--- a/server/pkg/agent/codearts.go+++ b/server/pkg/agent/codearts.go@@ -763,6 +763,10 @@ func buildCodeArtsMCPConfigContent(raw json.RawMessage) (string, error) {// discoverCodeArtsModels uses the model catalog command exposed by CodeArts.// CodeArts does not expose OpenCode variants, so variant metadata is removed.func discoverCodeArtsModels(ctx context.Context, runtimeCmd Command) ([]Model, error) {+ return discoverCodeArtsModelsWithin(ctx, runtimeCmd, 15*time.Second)+}++func discoverCodeArtsModelsWithin(ctx context.Context, runtimeCmd Command, attemptTimeout time.Duration) ([]Model, error) {if runtimeCmd.Path == "" {runtimeCmd.Path = "codearts"}@@ -777,9 +781,10 @@ func discoverCodeArtsModels(ctx context.Context, runtimeCmd Command) ([]Model, e}}- runCtx, cancel := context.WithTimeout(ctx, 15*time.Second)- defer cancel()+ // A stalled verbose listing must leave the plain listing its own budget.run := func(args ...string) []Model {+ runCtx, cancel := context.WithTimeout(ctx, attemptTimeout)+ defer cancel()cmd := runtimeCmd.exec(runCtx, args...)hideAgentWindow(cmd)cmd.Env = buildCodeArtsEnv(nil)diff --git a/server/pkg/agent/codearts_test.go b/server/pkg/agent/codearts_test.goindex 856caf7728..52d173831e 100644--- a/server/pkg/agent/codearts_test.go+++ b/server/pkg/agent/codearts_test.go@@ -194,6 +194,29 @@ func TestDiscoverCodeArtsModels(t *testing.T) {}}+func TestDiscoverCodeArtsModelsRetriesAfterVerboseTimeout(t *testing.T) {+ self, err := os.Executable()+ if err != nil {+ t.Fatal(err)+ }+ t.Setenv(codeartsModelHelperEnv, "1")+ t.Setenv(codeartsModelHelperHangVerbose, "1")+ argvPath := filepath.Join(t.TempDir(), "model-argv.txt")+ t.Setenv(codeartsModelHelperArgvFile, argvPath)++ models, err := discoverCodeArtsModelsWithin(t.Context(), Command{Path: self}, 2*time.Second)+ if err != nil {+ t.Fatal(err)+ }+ if len(models) != 1 || models[0].ID != "huaweicloud-maas/deepseek-v3.2" {+ t.Fatalf("plain listing after verbose timeout: got %+v", models)+ }+ argv, err := os.ReadFile(argvPath)+ if err != nil || string(argv) != "models" {+ t.Fatalf("last probe = %q, err = %v, want plain models", argv, err)+ }+}+func TestDetectVersionUsesCodeArtsCommandPrefix(t *testing.T) {self, err := os.Executable()if err != nil {diff --git a/server/pkg/agent/opencode_stdin_helper_test.go b/server/pkg/agent/opencode_stdin_helper_test.goindex aecfbf08a3..b88ecc8944 100644--- a/server/pkg/agent/opencode_stdin_helper_test.go+++ b/server/pkg/agent/opencode_stdin_helper_test.go@@ -5,6 +5,7 @@ import ("io""os""strings"+ "time")// Env contract between the OpenCode stdin tests and the helper process they@@ -19,8 +20,9 @@ const ()const (- codeartsModelHelperEnv = "CODEARTS_MODEL_TEST_HELPER"- codeartsModelHelperArgvFile = "CODEARTS_MODEL_TEST_HELPER_ARGV_FILE"+ codeartsModelHelperEnv = "CODEARTS_MODEL_TEST_HELPER"+ codeartsModelHelperArgvFile = "CODEARTS_MODEL_TEST_HELPER_ARGV_FILE"+ codeartsModelHelperHangVerbose = "CODEARTS_MODEL_TEST_HELPER_HANG_VERBOSE")func runFakeCodeArtsModelHelper() {@@ -32,6 +34,9 @@ func runFakeCodeArtsModelHelper() {}}for _, arg := range args {+ if arg == "--verbose" && os.Getenv(codeartsModelHelperHangVerbose) == "1" {+ time.Sleep(time.Minute)+ }if arg == "--version" {fmt.Println("CodeArts Agent 1.2.3")return