{"record":{"id":"19f304909958a169","repo":"siyuan-note/siyuan","slug":"capability-is-disabled-or-no-longer-available-s","errorCode":null,"errorMessage":"capability is disabled or no longer available: %s","messagePattern":"capability is disabled or no longer available: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/agent/tools.go","lineNumber":61,"sourceCode":"\t}\n\tif t.ContextHandler == nil && t.Handler == nil {\n\t\treturn nil, nil, fmt.Errorf(\"tool handler unavailable: %s\", toolName)\n\t}\n\tif ctx.Err() != nil {\n\t\treturn nil, nil, fmt.Errorf(\"tool execution was cancelled before it started\")\n\t}\n\tif err := validator.ValidateInputContext(ctx, args); err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"invalid tool arguments: %w\", err)\n\t}\n\treturn t, validator, nil\n}\n\nfunc validateCapabilityCall(ctx context.Context, registration *capabilityRegistration, args map[string]any) error {\n\tif registration == nil {\n\t\treturn fmt.Errorf(\"capability was not exposed in this model round\")\n\t}\n\tif !capabilityStillExecutable(registration, args) {\n\t\treturn fmt.Errorf(\"capability is disabled or no longer available: %s\", registration.ID)\n\t}\n\tif ctx.Err() != nil {\n\t\treturn fmt.Errorf(\"capability execution was cancelled before it started\")\n\t}\n\tif registration.Validator == nil {\n\t\treturn fmt.Errorf(\"capability validator unavailable: %s\", registration.ID)\n\t}\n\tif err := registration.Validator.ValidateInputContext(ctx, args); err != nil {\n\t\treturn fmt.Errorf(\"invalid capability arguments: %w\", err)\n\t}\n\tif !registration.isBrowser() &&\n\t\t(registration.Tool == nil || registration.Tool.ContextHandler == nil && registration.Tool.Handler == nil) {\n\t\treturn fmt.Errorf(\"capability handler unavailable: %s\", registration.ID)\n\t}\n\treturn nil\n}\n\n// executeTool 执行单次工具调用。","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/agent/tools.go#L43-L79","documentation":"validateCapabilityCall calls capabilityStillExecutable(registration, args) and rejects the invocation when it returns false. The capability is registered but has been disabled (e.g. toggled off in settings) or removed since exposure. The registration ID is embedded in the message for diagnosis.","triggerScenarios":"A tool exposed to the model at round start becomes disabled before its call executes: user disables the MCP server or plugin tool, a snapshot/confirm flow invalidates the registration, or capabilityStillExecutable's own checks (re-lookup of the tool, argument-dependent gating) fail.","commonSituations":"User disables a plugin mid-agent-run, MCP server reconnect fails leaving tools unavailable, or long-running agent sessions where the tool set changes between exposure and execution.","solutions":["Re-enable the MCP server / plugin tool that provides the capability ID shown in the message","Verify tool availability before starting the agent round so stale tools are not exposed","Handle the IsError result in the agent loop and inform the model the tool is gone","Check capabilityStillExecutable to confirm which sub-condition failed for this registration"],"exampleFix":"// before: exposing tools without availability check\nfor _, t := range cachedTools {\n    expose(t)\n}\n// after: only expose currently available tools\nfor _, t := range cachedTools {\n    if toolStillAvailable(t) {\n        expose(t)\n    }\n}","handlingStrategy":"validation","validationCode":"if !capabilityStillExecutable(reg, args) {\n    return executedToolResult{Text: \"capability unavailable: \" + reg.ID, IsError: true}\n}","typeGuard":null,"tryCatchPattern":"if err := validateCapabilityCall(ctx, reg, args); err != nil {\n    return executedToolResult{Text: err.Error(), IsError: true}\n}","preventionTips":["Only expose tools whose MCP server/plugin is currently connected","Re-verify availability between exposure and execution in long sessions","Surface tool disabling events to the agent loop immediately"],"tags":["ai","tool-calling","agent","lifecycle"],"backgroundTag":"feature-not-enabled","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"}