fix(ai): keep render_chart when chart skill is explicitly selected

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 <noreply@anthropic.com>
This commit is contained in:
diguaandClaude Sonnet 4.6 committed 2026-06-10 00:15:25 +08:00
1 parent 7239589146
commit 7f6b8238e4
1 file changed
+7 -1
+7 -1
View File
@@ -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')
}