Unified Agent + reusable Go agent core.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(uniai): preserve /vN version suffix in normalizeOpenAIBase

normalizeOpenAIBase unconditionally appended /v1 to any endpoint
that did not already contain it. This broke providers like zhipuai
(BigModel) whose OpenAI-compatible base URL already ends with a
version segment (e.g. /api/paas/v4) and does not use an additional
/v1 path.

Add a regex check for /v\\d+$ so that any endpoint ending with a
version segment is preserved as-is, while bare domains still get
the automatic /v1 appended.

Fixes 404 errors when using --profile zhipuai.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

authored by

Teteuya
Claude Sonnet 4.6
and committed by
Lyric Wai
16fde14e 6cd4cfc0

+28
+6
providers/uniai/client.go
··· 7 7 "encoding/json" 8 8 "fmt" 9 9 "reflect" 10 + "regexp" 10 11 "strconv" 11 12 "strings" 12 13 "time" ··· 1342 1343 endpoint = strings.TrimRight(endpoint, "/") 1343 1344 if strings.Contains(endpoint, "/backend-api/codex") { 1344 1345 endpoint = strings.TrimSuffix(endpoint, "/v1") 1346 + return endpoint 1347 + } 1348 + // If the endpoint already ends with a version segment like /v1, /v2, /v4, 1349 + // trust it and do not append an extra /v1. 1350 + if matched, _ := regexp.MatchString(`/v\d+$`, endpoint); matched { 1345 1351 return endpoint 1346 1352 } 1347 1353 if strings.HasSuffix(endpoint, "/v1") || strings.Contains(endpoint, "/v1/") {
+22
providers/uniai/client_test.go
··· 1036 1036 }) 1037 1037 } 1038 1038 } 1039 + 1040 + func TestNormalizeOpenAIBase(t *testing.T) { 1041 + tests := []struct { 1042 + input string 1043 + expected string 1044 + }{ 1045 + {"https://api.openai.com", "https://api.openai.com/v1"}, 1046 + {"https://api.openai.com/", "https://api.openai.com/v1"}, 1047 + {"https://token-plan-cn.xiaomimimo.com/v1", "https://token-plan-cn.xiaomimimo.com/v1"}, 1048 + {"https://api.kimi.com/coding/v1", "https://api.kimi.com/coding/v1"}, 1049 + {"https://open.bigmodel.cn/api/paas/v4", "https://open.bigmodel.cn/api/paas/v4"}, 1050 + {"https://open.bigmodel.cn/api/paas/v4/", "https://open.bigmodel.cn/api/paas/v4"}, 1051 + {"https://example.com/api/v5", "https://example.com/api/v5"}, 1052 + {"", ""}, 1053 + } 1054 + for _, tc := range tests { 1055 + got := normalizeOpenAIBase(tc.input) 1056 + if got != tc.expected { 1057 + t.Errorf("normalizeOpenAIBase(%q) = %q, want %q", tc.input, got, tc.expected) 1058 + } 1059 + } 1060 + }