From 7f6b8238e4516b5dc816dd24e286b82c65803f78 Mon Sep 17 00:00:00 2001 From: digua Date: Wed, 10 Jun 2026 00:06:17 +0800 Subject: [PATCH] fix(ai): keep render_chart when chart skill is explicitly selected MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In explicit chart auto mode, the filter at agent/index.ts removed render_chart whenever the user message lacked chart keywords. This caused failures when a user manually selected the built-in chart skill with a message like "analyze message trends" — the skill prompt instructed the AI to produce charts but the tool was unavailable. Add an isExplicitChartSkill guard so the filter is skipped when skillCtx.skillDef.id === CHART_CAPABILITY_SKILL_ID. Co-Authored-By: Claude Sonnet 4.6 --- apps/desktop/main/ai/agent/index.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/desktop/main/ai/agent/index.ts b/apps/desktop/main/ai/agent/index.ts index 403013ae..4be453fb 100644 --- a/apps/desktop/main/ai/agent/index.ts +++ b/apps/desktop/main/ai/agent/index.ts @@ -10,6 +10,7 @@ import { getHistoryForAgent, setPendingDebugContext } from '../chats' import { aiLogger, isDebugMode } from '../logger' import { t as i18nT } from '../../i18n' import { + CHART_CAPABILITY_SKILL_ID, DEFAULT_MAX_TOOL_ROUNDS, buildPlanGuidance, createAnalysisPlanner, @@ -130,7 +131,12 @@ export class Agent { const allowedTools = this.assistantConfig?.allowedBuiltinTools const toolContext = { ...this.context, locale: this.locale } let piTools = getAllTools(toolContext, allowedTools) - if (this.config.chartAutoMode === 'explicit' && !shouldUseChartCapabilityForMessage(userMessage)) { + const isExplicitChartSkill = this.skillCtx?.skillDef?.id === CHART_CAPABILITY_SKILL_ID + if ( + this.config.chartAutoMode === 'explicit' && + !isExplicitChartSkill && + !shouldUseChartCapabilityForMessage(userMessage) + ) { piTools = piTools.filter((tool) => tool.name !== 'render_chart') }