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:
YeonGyu-Kim
2026-04-05 15:46:24 +09:00
parent 6e8fc1464a
commit afd554b2d9
4 changed files with 85 additions and 4 deletions
@@ -127,4 +127,52 @@ Use \`background_output(task_id="<id>")\` to retrieve each result.
expect(notification).toBe(expectedNotification)
})
})
describe("#given all tasks completed with undefined descriptions", () => {
test("#when building the final notification #then it uses task ID as fallback instead of 'undefined'", () => {
// given
const notification = buildBackgroundTaskNotificationText({
task: {
id: "bg_abc123",
description: undefined as unknown as string,
status: "completed",
},
duration: "5s",
statusText: "COMPLETED",
allComplete: true,
remainingCount: 0,
completedTasks: [
{ id: "bg_abc123", description: undefined as unknown as string, status: "completed" },
{ id: "bg_def456", description: undefined as unknown as string, status: "completed" },
],
})
// then
expect(notification).not.toContain(": undefined")
expect(notification).toContain("bg_abc123")
expect(notification).toContain("bg_def456")
})
})
describe("#given a single task notification with undefined description", () => {
test("#when building the partial notification #then it uses task ID as fallback", () => {
// given
const notification = buildBackgroundTaskNotificationText({
task: {
id: "bg_xyz789",
description: undefined as unknown as string,
status: "completed",
},
duration: "3s",
statusText: "COMPLETED",
allComplete: false,
remainingCount: 2,
completedTasks: [],
})
// then
expect(notification).not.toContain("undefined")
expect(notification).toContain("bg_xyz789")
})
})
})