fix(delegate-task): add token counting and truncation to prevent context overflow

Fixes #1815, #1733
This commit is contained in:
YeonGyu-Kim
2026-02-25 14:03:47 +09:00
parent 15519b9580
commit fc1b6e4917
8 changed files with 296 additions and 23 deletions
+5 -4
View File
@@ -5,17 +5,18 @@ import { discoverSkills } from "../../features/opencode-skill-loader"
export async function resolveSkillContent(
skills: string[],
options: { gitMasterConfig?: GitMasterConfig; browserProvider?: BrowserAutomationProvider, disabledSkills?: Set<string>, directory?: string }
): Promise<{ content: string | undefined; error: string | null }> {
): Promise<{ content: string | undefined; contents: string[]; error: string | null }> {
if (skills.length === 0) {
return { content: undefined, error: null }
return { content: undefined, contents: [], error: null }
}
const { resolved, notFound } = await resolveMultipleSkillsAsync(skills, options)
if (notFound.length > 0) {
const allSkills = await discoverSkills({ includeClaudeCodePaths: true, directory: options?.directory })
const available = allSkills.map(s => s.name).join(", ")
return { content: undefined, error: `Skills not found: ${notFound.join(", ")}. Available: ${available}` }
return { content: undefined, contents: [], error: `Skills not found: ${notFound.join(", ")}. Available: ${available}` }
}
return { content: Array.from(resolved.values()).join("\n\n"), error: null }
const contents = Array.from(resolved.values())
return { content: contents.join("\n\n"), contents, error: null }
}