feat(delegate-task, agents): check requiresModel for conditional activation
This commit is contained in:
parent
baefd16b3f
commit
2c74f608f0
@ -10,7 +10,7 @@ import { createMetisAgent } from "./metis"
|
|||||||
import { createAtlasAgent } from "./atlas"
|
import { createAtlasAgent } from "./atlas"
|
||||||
import { createMomusAgent } from "./momus"
|
import { createMomusAgent } from "./momus"
|
||||||
import type { AvailableAgent, AvailableCategory, AvailableSkill } from "./dynamic-agent-prompt-builder"
|
import type { AvailableAgent, AvailableCategory, AvailableSkill } from "./dynamic-agent-prompt-builder"
|
||||||
import { deepMerge, fetchAvailableModels, resolveModelWithFallback, AGENT_MODEL_REQUIREMENTS, findCaseInsensitive, includesCaseInsensitive, readConnectedProvidersCache } from "../shared"
|
import { deepMerge, fetchAvailableModels, resolveModelWithFallback, AGENT_MODEL_REQUIREMENTS, findCaseInsensitive, includesCaseInsensitive, readConnectedProvidersCache, isModelAvailable } from "../shared"
|
||||||
import { DEFAULT_CATEGORIES, CATEGORY_DESCRIPTIONS } from "../tools/delegate-task/constants"
|
import { DEFAULT_CATEGORIES, CATEGORY_DESCRIPTIONS } from "../tools/delegate-task/constants"
|
||||||
import { resolveMultipleSkills } from "../features/opencode-skill-loader/skill-content"
|
import { resolveMultipleSkills } from "../features/opencode-skill-loader/skill-content"
|
||||||
import { createBuiltinSkills } from "../features/builtin-skills"
|
import { createBuiltinSkills } from "../features/builtin-skills"
|
||||||
@ -225,6 +225,13 @@ export async function createBuiltinAgents(
|
|||||||
const override = findCaseInsensitive(agentOverrides, agentName)
|
const override = findCaseInsensitive(agentOverrides, agentName)
|
||||||
const requirement = AGENT_MODEL_REQUIREMENTS[agentName]
|
const requirement = AGENT_MODEL_REQUIREMENTS[agentName]
|
||||||
|
|
||||||
|
// Check if agent requires a specific model
|
||||||
|
if (requirement?.requiresModel && availableModels) {
|
||||||
|
if (!isModelAvailable(requirement.requiresModel, availableModels)) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const isPrimaryAgent = isFactory(source) && source.mode === "primary"
|
const isPrimaryAgent = isFactory(source) && source.mode === "primary"
|
||||||
|
|
||||||
const resolution = resolveModelWithFallback({
|
const resolution = resolveModelWithFallback({
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import { getTaskToastManager } from "../../features/task-toast-manager"
|
|||||||
import type { ModelFallbackInfo } from "../../features/task-toast-manager/types"
|
import type { ModelFallbackInfo } from "../../features/task-toast-manager/types"
|
||||||
import { subagentSessions, getSessionAgent } from "../../features/claude-code-session-state"
|
import { subagentSessions, getSessionAgent } from "../../features/claude-code-session-state"
|
||||||
import { log, getAgentToolRestrictions, resolveModel, getOpenCodeConfigPaths, findByNameCaseInsensitive, equalsIgnoreCase, promptWithModelSuggestionRetry } from "../../shared"
|
import { log, getAgentToolRestrictions, resolveModel, getOpenCodeConfigPaths, findByNameCaseInsensitive, equalsIgnoreCase, promptWithModelSuggestionRetry } from "../../shared"
|
||||||
import { fetchAvailableModels } from "../../shared/model-availability"
|
import { fetchAvailableModels, isModelAvailable } from "../../shared/model-availability"
|
||||||
import { readConnectedProvidersCache } from "../../shared/connected-providers-cache"
|
import { readConnectedProvidersCache } from "../../shared/connected-providers-cache"
|
||||||
import { resolveModelWithFallback } from "../../shared/model-resolver"
|
import { resolveModelWithFallback } from "../../shared/model-resolver"
|
||||||
import { CATEGORY_MODEL_REQUIREMENTS } from "../../shared/model-requirements"
|
import { CATEGORY_MODEL_REQUIREMENTS } from "../../shared/model-requirements"
|
||||||
@ -117,9 +117,20 @@ export function resolveCategoryConfig(
|
|||||||
userCategories?: CategoriesConfig
|
userCategories?: CategoriesConfig
|
||||||
inheritedModel?: string
|
inheritedModel?: string
|
||||||
systemDefaultModel?: string
|
systemDefaultModel?: string
|
||||||
|
availableModels?: Set<string>
|
||||||
}
|
}
|
||||||
): { config: CategoryConfig; promptAppend: string; model: string | undefined } | null {
|
): { config: CategoryConfig; promptAppend: string; model: string | undefined } | null {
|
||||||
const { userCategories, inheritedModel, systemDefaultModel } = options
|
const { userCategories, inheritedModel, systemDefaultModel, availableModels } = options
|
||||||
|
|
||||||
|
// Check if category requires a specific model
|
||||||
|
const categoryReq = CATEGORY_MODEL_REQUIREMENTS[categoryName]
|
||||||
|
if (categoryReq?.requiresModel && availableModels) {
|
||||||
|
if (!isModelAvailable(categoryReq.requiresModel, availableModels)) {
|
||||||
|
log(`[resolveCategoryConfig] Category ${categoryName} requires ${categoryReq.requiresModel} but not available`)
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const defaultConfig = DEFAULT_CATEGORIES[categoryName]
|
const defaultConfig = DEFAULT_CATEGORIES[categoryName]
|
||||||
const userConfig = userCategories?.[categoryName]
|
const userConfig = userCategories?.[categoryName]
|
||||||
const defaultPromptAppend = CATEGORY_PROMPT_APPENDS[categoryName] ?? ""
|
const defaultPromptAppend = CATEGORY_PROMPT_APPENDS[categoryName] ?? ""
|
||||||
@ -526,6 +537,7 @@ To continue this session: session_id="${args.session_id}"`
|
|||||||
userCategories,
|
userCategories,
|
||||||
inheritedModel,
|
inheritedModel,
|
||||||
systemDefaultModel,
|
systemDefaultModel,
|
||||||
|
availableModels,
|
||||||
})
|
})
|
||||||
if (!resolved) {
|
if (!resolved) {
|
||||||
return `Unknown category: "${args.category}". Available: ${Object.keys({ ...DEFAULT_CATEGORIES, ...userCategories }).join(", ")}`
|
return `Unknown category: "${args.category}". Available: ${Object.keys({ ...DEFAULT_CATEGORIES, ...userCategories }).join(", ")}`
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user