Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(agent): scope pi colon-to-slash normalization to legacy format (#2309)
Bohan Jiang0eb23df2341b
diff --git a/server/pkg/agent/models.go b/server/pkg/agent/models.goindex b6a120a64c..f096c22d95 100644--- a/server/pkg/agent/models.go+++ b/server/pkg/agent/models.go@@ -299,6 +299,11 @@ func discoverPiModels(ctx context.Context, executablePath string) ([]Model, erroreturn parsePiModels(text), nil}+// parsePiModels accepts the `pi --list-models` output. Pi historically+// emitted `provider:model` per line and now emits a multi-column table+// (`provider model context …`); both shapes are normalized to+// `provider/model` to match opencode/UI conventions. The case-insensitive+// `provider` token in column 0 is treated as the table header and skipped.func parsePiModels(output string) []Model {scanner := bufio.NewScanner(strings.NewReader(output))scanner.Buffer(make([]byte, 0, 64*1024), 1024*1024)@@ -319,13 +324,15 @@ func parsePiModels(output string) []Model {}var id stringif strings.ContainsAny(first, ":/") {- id = first+ // Legacy `provider:model` format — normalize colon to slash.+ // Restricted to this branch so a model name with a `:` in+ // the table format's column 1 is not silently rewritten.+ id = strings.Replace(first, ":", "/", 1)} else if len(fields) >= 2 {id = first + "/" + fields[1]} else {continue}- id = strings.Replace(id, ":", "/", 1)if seen[id] {continue}diff --git a/server/pkg/agent/models_test.go b/server/pkg/agent/models_test.goindex 5ad2b82e1f..b22dd44f50 100644--- a/server/pkg/agent/models_test.go+++ b/server/pkg/agent/models_test.go@@ -202,12 +202,13 @@ func TestParsePiModelsTableFormat(t *testing.T) {bailian-coding-plan glm-4.7 202.8K 16.4K no nobailian-coding-plan qwen3.6-plus 1M 65.5K no yesopencode claude-sonnet-4-6 1M 64K yes yes+opencode claude-sonnet-4-6:exp 1M 64K yes yesopencode claude-sonnet-4-6 1M 64K yes yesbareword-only-line`models := parsePiModels(input)- if len(models) != 3 {- t.Fatalf("expected 3 models (header skipped, duplicate deduped, bareword skipped), got %d: %+v", len(models), models)+ if len(models) != 4 {+ t.Fatalf("expected 4 models (header skipped, duplicate deduped, bareword skipped), got %d: %+v", len(models), models)}if models[0].ID != "bailian-coding-plan/glm-4.7" || models[0].Provider != "bailian-coding-plan" {t.Errorf("unexpected first model: %+v", models[0])@@ -218,6 +219,11 @@ bareword-only-lineif models[2].ID != "opencode/claude-sonnet-4-6" || models[2].Provider != "opencode" {t.Errorf("unexpected third model: %+v", models[2])}+ // Colon inside a model name in column 1 must be preserved — only+ // the legacy `provider:model` form gets colon→slash normalization.+ if models[3].ID != "opencode/claude-sonnet-4-6:exp" || models[3].Provider != "opencode" {+ t.Errorf("expected ':' inside table-format model name to be preserved: %+v", models[3])+ }}func TestParseOpenclawAgents(t *testing.T) {