Merge pull request #2863 from MoerAI/fix/task-schema-mutual-exclusion
fix(delegate-task): reject when both category and subagent_type provided (fixes #2847)
This commit is contained in:
@@ -465,7 +465,7 @@ describe("sisyphus-task", () => {
|
||||
expect(args.subagent_type).toBe("Sisyphus-Junior")
|
||||
}, { timeout: 10000 })
|
||||
|
||||
test("category overrides subagent_type and still maps to sisyphus-junior", async () => {
|
||||
test("rejects when both category and subagent_type are provided", async () => {
|
||||
//#given
|
||||
const { createDelegateTask } = require("./tools")
|
||||
|
||||
@@ -507,14 +507,7 @@ describe("sisyphus-task", () => {
|
||||
abort: new AbortController().signal,
|
||||
}
|
||||
|
||||
const args: {
|
||||
description: string
|
||||
prompt: string
|
||||
category: string
|
||||
subagent_type: string
|
||||
run_in_background: boolean
|
||||
load_skills: string[]
|
||||
} = {
|
||||
const args = {
|
||||
description: "Override test",
|
||||
prompt: "Do something",
|
||||
category: "quick",
|
||||
@@ -523,12 +516,8 @@ describe("sisyphus-task", () => {
|
||||
load_skills: [],
|
||||
}
|
||||
|
||||
//#when
|
||||
const result = await tool.execute(args, toolContext)
|
||||
|
||||
//#then
|
||||
expect(args.subagent_type).toBe("Sisyphus-Junior")
|
||||
expect(result).toContain("Background task launched")
|
||||
//#when + #then
|
||||
await expect(tool.execute(args, toolContext)).rejects.toThrow("mutually exclusive")
|
||||
}, { timeout: 10000 })
|
||||
|
||||
test("proceeds without error when systemDefaultModel is undefined", async () => {
|
||||
|
||||
@@ -102,20 +102,23 @@ export function createDelegateTask(options: DelegateTaskToolOptions): ToolDefini
|
||||
prompt: tool.schema.string().describe("Full detailed prompt for the agent"),
|
||||
run_in_background: tool.schema.boolean().describe("REQUIRED. true=async (returns task_id), false=sync (waits). Use false for task delegation, true ONLY for parallel exploration."),
|
||||
category: tool.schema.string().optional().describe(`REQUIRED if subagent_type not provided. Do NOT provide both category and subagent_type.`),
|
||||
subagent_type: tool.schema.string().optional().describe("REQUIRED if category not provided. Do NOT provide both category and subagent_type."),
|
||||
subagent_type: tool.schema.string().optional().describe("REQUIRED if category not provided. Do NOT provide both category and subagent_type. Valid values: explore, librarian, oracle, metis, momus"),
|
||||
session_id: tool.schema.string().optional().describe("Existing Task session to continue"),
|
||||
command: tool.schema.string().optional().describe("The command that triggered this task"),
|
||||
},
|
||||
async execute(args: DelegateTaskArgs, toolContext) {
|
||||
const ctx = toolContext as ToolContextWithMetadata
|
||||
|
||||
if (args.category && args.subagent_type) {
|
||||
throw new Error(
|
||||
`Invalid arguments: 'category' and 'subagent_type' are mutually exclusive. Provide EXACTLY ONE.\n` +
|
||||
` - You provided: category="${args.category}", subagent_type="${args.subagent_type}"\n` +
|
||||
` - Use category for task delegation (e.g., category="${categoryExamples.split(", ")[0]}")\n` +
|
||||
` - Use subagent_type for direct agent invocation (e.g., subagent_type="explore")\n` +
|
||||
` - Valid subagent_type values: explore, librarian, oracle, metis, momus`
|
||||
)
|
||||
}
|
||||
if (args.category) {
|
||||
if (args.subagent_type && args.subagent_type !== SISYPHUS_JUNIOR_AGENT) {
|
||||
log("[task] category provided - overriding subagent_type to sisyphus-junior", {
|
||||
category: args.category,
|
||||
subagent_type: args.subagent_type,
|
||||
})
|
||||
}
|
||||
args.subagent_type = SISYPHUS_JUNIOR_AGENT
|
||||
}
|
||||
await ctx.metadata?.({
|
||||
|
||||
Reference in New Issue
Block a user