@@ -171,11 +171,8 @@ func (a AgentService) Create(req dto.AgentCreateReq) (*dto.AgentItem, error) {
171171 return nil , buserr .New ("ErrAgentProviderMismatch" )
172172 }
173173 if provider == "custom" || provider == "vllm" {
174- primaryID := customPrimaryModelID (req .Model )
175- if primaryID == "" {
176- primaryID = normalizeCustomModel (req .Model )
177- }
178- runtimeModel = "custom/" + primaryID
174+ customModelID := normalizeCustomModel (req .Model )
175+ runtimeModel = "custom/" + customModelID
179176 }
180177 if provider == "bailian-coding-plan" {
181178 modelID := runtimeModel
@@ -1907,11 +1904,7 @@ func writeOpenclawConfig(confDir, provider, modelName, apiType string, maxTokens
19071904 }
19081905 } else if provider == "custom" || provider == "vllm" {
19091906 customModelID := normalizeCustomModel (modelName )
1910- primaryID := customPrimaryModelID (customModelID )
1911- if primaryID == "" {
1912- primaryID = customModelID
1913- }
1914- primary := provider + "/" + primaryID
1907+ primary := provider + "/" + customModelID
19151908 cfg .Agents .Defaults .Model .Primary = primary
19161909 base := strings .TrimSpace (baseURL )
19171910 plainKey := strings .TrimSpace (apiKey )
@@ -2261,9 +2254,10 @@ func toInt(value interface{}) int {
22612254
22622255func normalizeCustomModel (modelName string ) string {
22632256 trim := strings .TrimSpace (modelName )
2257+ trim = strings .TrimLeft (trim , "/" )
22642258 if parts := strings .SplitN (trim , "/" , 2 ); len (parts ) == 2 {
22652259 if strings .EqualFold (parts [0 ], "custom" ) {
2266- return strings .TrimSpace (parts [1 ])
2260+ return strings .TrimLeft ( strings . TrimSpace (parts [1 ]), "/" )
22672261 }
22682262 }
22692263 return trim
@@ -2313,21 +2307,6 @@ func bailianPrimaryModelID(modelID string) string {
23132307 return trim
23142308}
23152309
2316- func customPrimaryModelID (modelName string ) string {
2317- trim := normalizeCustomModel (modelName )
2318- if trim == "" {
2319- return ""
2320- }
2321- parts := strings .Split (trim , "/" )
2322- for i := len (parts ) - 1 ; i >= 0 ; i -- {
2323- part := strings .TrimSpace (parts [i ])
2324- if part != "" {
2325- return part
2326- }
2327- }
2328- return ""
2329- }
2330-
23312310func normalizeAgentType (agentType string ) string {
23322311 trim := strings .ToLower (strings .TrimSpace (agentType ))
23332312 if trim == "" {
0 commit comments