fix(delegate-task): validate description parameter and handle undefined in notifications
OpenCode's fromPlugin wrapper skips Zod validation for plugin tools, so LLMs can omit required args like description without getting an error. When Atlas orchestrates and the model omits description, it flows through as undefined to manager.launch() and background task notifications show 'undefined' for all completed tasks. Two fixes: - Add runtime validation for description in delegate-task tool (matches existing run_in_background and load_skills validation pattern) - Defensive fallback in notification template: use task ID when description is missing instead of rendering 'undefined'
This commit is contained in:
@@ -1366,6 +1366,35 @@ describe("sisyphus-task", () => {
|
||||
)).rejects.toThrow("Invalid arguments: 'run_in_background' parameter is REQUIRED")
|
||||
})
|
||||
|
||||
test("#given category without description #when executing #then throws required parameter error", async () => {
|
||||
// given
|
||||
const { createDelegateTask } = require("./tools")
|
||||
const mockManager = { launch: async () => ({}) }
|
||||
const mockClient = {
|
||||
app: { agents: async () => ({ data: [] }) },
|
||||
config: { get: async () => ({ data: { model: SYSTEM_DEFAULT_MODEL } }) },
|
||||
session: {
|
||||
create: async () => ({ data: { id: "test-session" } }),
|
||||
prompt: async () => ({ data: {} }),
|
||||
promptAsync: async () => ({ data: {} }),
|
||||
messages: async () => ({ data: [] }),
|
||||
},
|
||||
}
|
||||
const tool = createDelegateTask({ manager: mockManager, client: mockClient })
|
||||
|
||||
// when
|
||||
// then
|
||||
await expect(tool.execute(
|
||||
{
|
||||
prompt: "Do something",
|
||||
category: "quick",
|
||||
run_in_background: false,
|
||||
load_skills: [],
|
||||
},
|
||||
{ sessionID: "parent-session", messageID: "parent-message", agent: "sisyphus", abort: new AbortController().signal }
|
||||
)).rejects.toThrow("Invalid arguments: 'description' parameter is REQUIRED")
|
||||
})
|
||||
|
||||
test("#given explicit run_in_background=false #when executing #then sync execution succeeds", async () => {
|
||||
// given
|
||||
const { createDelegateTask } = require("./tools")
|
||||
|
||||
@@ -122,6 +122,9 @@ export function createDelegateTask(options: DelegateTaskToolOptions): ToolDefini
|
||||
title: args.description,
|
||||
})
|
||||
|
||||
if (!args.description || typeof args.description !== "string") {
|
||||
throw new Error(`Invalid arguments: 'description' parameter is REQUIRED. Provide a short (3-5 words) task description.`)
|
||||
}
|
||||
if (args.run_in_background === undefined) {
|
||||
throw new Error(`Invalid arguments: 'run_in_background' parameter is REQUIRED. Specify run_in_background=false for task delegation, or run_in_background=true for parallel exploration.`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user