siyuan-note/siyuan · error
capability ID collision
Error message
capability ID collision [%s]: %s and %s
What it means
The capability set keeps indexes keyed by both capability ID and model name. The add method rejects a registration whose ID already exists in the set, reporting the colliding ID plus the model names of the existing and new registrations. This preserves the one-to-one mapping between capability IDs and model-facing tool names.
Solutions
- Rename one capability's ID so it is unique (frontend IDs should be namespaced, e.g. 'plugin/frontend/<plugin>/<name>')
- Deduplicate the frontendCapabilities list before calling buildCapabilitySet
- Check the error's two model names to identify which two registrations collide and remove or re-identify one
Example fix
// before
{ID: "frontend/preview", ...} // native and plugin both use this
// after
{ID: "plugin/frontend/myplugin/preview", ...} Defensive patterns
Strategy: validation
Validate before calling
seen := map[string]bool{}
for _, c := range caps {
if seen[c.ID] { return fmt.Errorf("duplicate capability ID %s", c.ID) }
seen[c.ID] = true
} Prevention
- Namespace plugin capability IDs as plugin/frontend/<plugin>/<name>
- Deduplicate merged capability lists before registration
- Log capability IDs at registration to catch collisions early
When it happens
Trigger: buildCapabilitySet registers two capabilities with the same ID — e.g. a native capability and a plugin/frontend capability both using ID 'frontend/foo', or the same frontend capability appears twice in the frontendCapabilities list.
Common situations: Plugin capability IDs clashing with built-in native IDs; duplicate capability declarations after merging multiple sources; a plugin registering capabilities twice after reload.
Understand the failure class
Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.
Related errors
- capability model name collision
- frontend capability description is required
- invalid frontend capability
- agent runtime turn changed
- agent runtime turn is not finalized
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/79f6a8507d1743bb.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/agent/capability.go:298
return nil, err
}
}
sort.Slice(set.definitions, func(i, j int) bool {
return set.definitions[i].Function.Name < set.definitions[j].Function.Name
})
return set, nil
}
func (set *capabilitySet) add(registration *capabilityRegistration) error {
if set.registrations == nil {
set.registrations = map[string]*capabilityRegistration{}
}
if set.ids == nil {
set.ids = map[string]*capabilityRegistration{}
}
if previous := set.ids[registration.ID]; previous != nil {
return fmt.Errorf("capability ID collision [%s]: %s and %s",
registration.ID, previous.ModelName, registration.ModelName)
}
if previous := set.registrations[registration.ModelName]; previous != nil {
return fmt.Errorf("capability model name collision [%s]: %s and %s",
registration.ModelName, previous.ID, registration.ID)
}
set.ids[registration.ID] = registration
set.registrations[registration.ModelName] = registration
set.definitions = append(set.definitions, openai.Tool{
Type: openai.ToolTypeFunction,
Function: &openai.FunctionDefinition{
Name: registration.ModelName,
Description: registration.Description,
Parameters: convertSchema(registration.InputSchema),
},
})
return nil
}View on GitHub (pinned to 9f775e8a12)