{"record":{"id":"4e598abc7a260877","repo":"siyuan-note/siyuan","slug":"capability-model-name-collision-s-s-and-s","errorCode":null,"errorMessage":"capability model name collision [%s]: %s and %s","messagePattern":"capability model name collision \\[(.+?)\\]: (.+?) and (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/agent/capability.go","lineNumber":302,"sourceCode":"\tsort.Slice(set.definitions, func(i, j int) bool {\n\t\treturn set.definitions[i].Function.Name < set.definitions[j].Function.Name\n\t})\n\treturn set, nil\n}\n\nfunc (set *capabilitySet) add(registration *capabilityRegistration) error {\n\tif set.registrations == nil {\n\t\tset.registrations = map[string]*capabilityRegistration{}\n\t}\n\tif set.ids == nil {\n\t\tset.ids = map[string]*capabilityRegistration{}\n\t}\n\tif previous := set.ids[registration.ID]; previous != nil {\n\t\treturn fmt.Errorf(\"capability ID collision [%s]: %s and %s\",\n\t\t\tregistration.ID, previous.ModelName, registration.ModelName)\n\t}\n\tif previous := set.registrations[registration.ModelName]; previous != nil {\n\t\treturn fmt.Errorf(\"capability model name collision [%s]: %s and %s\",\n\t\t\tregistration.ModelName, previous.ID, registration.ID)\n\t}\n\tset.ids[registration.ID] = registration\n\tset.registrations[registration.ModelName] = registration\n\tset.definitions = append(set.definitions, openai.Tool{\n\t\tType: openai.ToolTypeFunction,\n\t\tFunction: &openai.FunctionDefinition{\n\t\t\tName:        registration.ModelName,\n\t\t\tDescription: registration.Description,\n\t\t\tParameters:  convertSchema(registration.InputSchema),\n\t\t},\n\t})\n\treturn nil\n}\n\nfunc validFrontendCapabilityID(id string) bool {\n\tif len(id) > 512 {\n\t\treturn false","sourceCodeStart":284,"sourceCodeEnd":320,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/agent/capability.go#L284-L320","documentation":"The capability set's add method rejects a registration whose internal model/tool name (registration.ModelName, the name exposed as the OpenAI function tool name) is already used by another capability. Unlike error 81 the ID differs; only the derived model name collides. The error names both conflicting capability IDs.","triggerScenarios":"Registering two capabilities with distinct IDs whose ModelName values normalize/derive to the same string, so set.registrations already contains that model name when add is called.","commonSituations":"Two plugins define tools with the same function name; a capability ID sanitizes (e.g. lowercased/truncated) to the same model name as an existing tool; plugin update renamed the ID but kept the function name.","solutions":["Compare the two capability IDs in the error message to find the clashing pair","Change the new capability's ModelName (derived from its tool function name) to a unique value","Rename the tool function name in the plugin/manifest so the derived model name differs","Re-register only one of the two conflicting capabilities"],"exampleFix":"// before: both register ModelName \"frontend_search\"\n// after\nregistration.ModelName = \"frontend_search_v2\"","handlingStrategy":"validation","validationCode":"seen := map[string]bool{}\nfor _, c := range capabilities { if seen[c.ModelName] { return fmt.Errorf(\"duplicate model name %s\", c.ModelName) }; seen[c.ModelName] = true }","typeGuard":null,"tryCatchPattern":"if err := set.Add(reg); err != nil { if strings.Contains(err.Error(), \"model name collision\") { return fmt.Errorf(\"rename tool function for %s: %w\", reg.ID, err) }; return err }","preventionTips":["Keep tool function names globally unique across all plugins","Derive ModelName from the namespaced capability ID so collisions are impossible","Log all registered model names at startup to spot near-duplicates early"],"tags":["agent","capability","collision","naming"],"backgroundTag":"conflicting-config-options","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}