{"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/9f775e8a12daef8255556097396f9b2739078892/kernel/agent/capability.go#L284-L320","documentation":"Two distinct capabilities resolved to the same model-facing tool name. capabilityRegistration entries are indexed by ModelName, and add enforces uniqueness so the model never sees two tools with the same function name. The error names the colliding model name and the two capability IDs involved.","triggerScenarios":"Two capability IDs whose frontendCapabilityModelName-derived model names collide — typically IDs that differ only in parts stripped/normalized by the model-name derivation, or an explicit ModelName reused across registrations.","commonSituations":"Capability IDs differing only in a segment discarded by name normalization; two plugins exposing identically named tools; a registration hard-coding a ModelName already taken by a native capability.","solutions":["Change one capability's ID so its derived model name is unique","Inspect the two capability IDs in the error and rename the one you control","If ModelName is set explicitly, give the new registration a distinct ModelName"],"exampleFix":"// before\n{ID: \"frontend/open\", ModelName: \"open\"} and {ID: \"frontend/open_alt\", ModelName: \"open\"}\n// after\n{ID: \"frontend/open_alt\", ModelName: \"frontend_open_alt\"}","handlingStrategy":"validation","validationCode":"names := map[string]string{}\nfor _, c := range caps {\n    m := frontendCapabilityModelName(c.ID)\n    if prev, ok := names[m]; ok { return fmt.Errorf(\"model name %s collides: %s vs %s\", m, prev, c.ID) }\n    names[m] = c.ID\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Test the model-name derivation with the full set of capability IDs to detect normalization collisions","Avoid capability IDs that differ only in segments stripped by frontendCapabilityModelName","Use the kernel's own collision check in a pre-registration dry run"],"tags":["go","agent","capabilities","naming"],"backgroundTag":"invalid-identifier-format","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}