add subagent in model roles

This commit is contained in:
uinstinct 2025-12-19 21:27:36 +05:30
parent 70d5be8095
commit 08465a6400
5 changed files with 20 additions and 19 deletions

View file

@ -187,6 +187,7 @@ export async function configYamlToContinueConfig(options: {
autocomplete: [],
rerank: [],
summarize: [],
subagent: [],
},
selectedModelByRole: {
chat: null,
@ -196,6 +197,7 @@ export async function configYamlToContinueConfig(options: {
autocomplete: null,
rerank: null,
summarize: null,
subagent: null,
},
rules: [],
requestOptions: { ...config.requestOptions },

View file

@ -314,7 +314,7 @@ export class ModelService
const subagentModels = state.assistant.models
?.filter((model) => !!model)
.filter((model) => !!model.name) // filter out models without a name
.filter((model) => model.roles?.includes("apply")) // filter with role subagent
.filter((model) => model.roles?.includes("subagent")) // filter with role subagent
.filter((model) => !!model.chatOptions?.baseSystemMessage); // filter those with a system message
if (!subagentModels) {

View file

@ -3,7 +3,7 @@ import { services } from "../services/index.js";
/**
* Get an agent by name
*/
export function getAgent(name: string) {
export function getSubagent(name: string) {
return (
services.model
.getSubagentModels()
@ -23,18 +23,14 @@ export function generateSubagentToolDescription(): string {
)
.join("\n");
return `Launch a specialized subagent to handle complex, multi-step tasks autonomously.
// todo: refine this prompt later
return `Launch a specialized subagent to handle a specific task.
Available agent types:
Here are the available subagents:
${agentList}
When to use this tool:
- Complex research tasks requiring multiple file reads and searches
- Multi-step implementation tasks
- Tasks that benefit from autonomous execution
- When you need to parallelize independent work
When NOT to use this tool:
- Tasks you can complete directly with available tools
- Trivial operations that don't require multiple steps`;
`;
}
export function getAgentNames(): string[] {
return services.model.getSubagentModels().map((model) => model.model.name);
}

View file

@ -1,7 +1,8 @@
import { executeSubAgent } from "../subagent/executor.js";
import {
generateSubagentToolDescription,
getAgent,
getSubagent,
getAgentNames as getSubagentNames,
} from "../subagent/get-agents.js";
import { logger } from "../util/logger.js";
@ -28,8 +29,9 @@ export const subagentTool: Tool = {
},
subagent_name: {
type: "string",
description:
"The type of specialized agent to use for this task (e.g., 'general')",
description: `The type of specialized agent to use for this task. Available agents: ${getSubagentNames().join(
", ",
)}`,
},
},
},
@ -37,7 +39,7 @@ export const subagentTool: Tool = {
preprocess: async (args) => {
const { description, subagent_name } = args;
const agent = getAgent(subagent_name);
const agent = getSubagent(subagent_name);
if (!agent) {
throw new Error(
`Unknown agent type: ${subagent_name}. Available agents: general`,
@ -61,7 +63,7 @@ export const subagentTool: Tool = {
logger.debug("subagent args", { args, context });
// Get agent configuration
const agent = getAgent(subagent_name);
const agent = getSubagent(subagent_name);
if (!agent) {
throw new Error(`Unknown agent type: ${subagent_name}`);
}

View file

@ -28,6 +28,7 @@ export const modelRolesSchema = z.enum([
"edit",
"apply",
"summarize",
"subagent",
]);
export type ModelRole = z.infer<typeof modelRolesSchema>;