fix(delegate-task): make plan agent categories/skills dynamic

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
YeonGyu-Kim
2026-02-06 17:31:13 +09:00
parent 3be722b3b1
commit 6b560ebf9e
7 changed files with 268 additions and 79 deletions
+32 -2
View File
@@ -3,6 +3,10 @@ import type { DelegateTaskArgs, ToolContextWithMetadata, DelegateTaskToolOptions
import { DEFAULT_CATEGORIES, CATEGORY_DESCRIPTIONS } from "./constants"
import { log } from "../../shared"
import { buildSystemContent } from "./prompt-builder"
import type {
AvailableCategory,
AvailableSkill,
} from "../../agents/dynamic-agent-prompt-builder"
import {
resolveSkillContent,
resolveParentContext,
@@ -26,6 +30,20 @@ export function createDelegateTask(options: DelegateTaskToolOptions): ToolDefini
const categoryNames = Object.keys(allCategories)
const categoryExamples = categoryNames.map(k => `'${k}'`).join(", ")
const availableCategories: AvailableCategory[] = options.availableCategories
?? Object.entries(allCategories).map(([name, categoryConfig]) => {
const userDesc = userCategories?.[name]?.description
const builtinDesc = CATEGORY_DESCRIPTIONS[name]
const description = userDesc || builtinDesc || "General tasks"
return {
name,
description,
model: categoryConfig.model,
}
})
const availableSkills: AvailableSkill[] = options.availableSkills ?? []
const categoryList = categoryNames.map(name => {
const userDesc = userCategories?.[name]?.description
const builtinDesc = CATEGORY_DESCRIPTIONS[name]
@@ -150,7 +168,13 @@ Prompts MUST be in English.`
})
if (isUnstableAgent && isRunInBackgroundExplicitlyFalse) {
const systemContent = buildSystemContent({ skillContent, categoryPromptAppend, agentName: agentToUse })
const systemContent = buildSystemContent({
skillContent,
categoryPromptAppend,
agentName: agentToUse,
availableCategories,
availableSkills,
})
return executeUnstableAgentTask(args, ctx, options, parentContext, agentToUse, categoryModel, systemContent, actualModel)
}
} else {
@@ -162,7 +186,13 @@ Prompts MUST be in English.`
categoryModel = resolution.categoryModel
}
const systemContent = buildSystemContent({ skillContent, categoryPromptAppend, agentName: agentToUse })
const systemContent = buildSystemContent({
skillContent,
categoryPromptAppend,
agentName: agentToUse,
availableCategories,
availableSkills,
})
if (runInBackground) {
return executeBackgroundTask(args, ctx, options, parentContext, agentToUse, categoryModel, systemContent)