- Rename delegate_task tool to task across codebase (100 files) - Update model references: claude-opus-4-6 → 4-5, gpt-5.3-codex → 5.2-codex - Add tool-metadata-store to restore metadata overwritten by fromPlugin() - Add session ID polling for BackgroundManager task sessions - Await async ctx.metadata() calls in tool executors - Add ses_ prefix guard to getMessageDir for performance - Harden BackgroundManager with idle deferral and error handling - Fix duplicate task key in sisyphus-junior test object literals - Fix unawaited showOutputToUser in ast_grep_replace - Fix background=true → run_in_background=true in ultrawork prompt - Fix duplicate task/task references in docs and comments
66 lines
1.6 KiB
TypeScript
66 lines
1.6 KiB
TypeScript
const { describe, test, expect } = require("bun:test")
|
|
|
|
import { executeBackgroundTask } from "./executor"
|
|
import type { DelegateTaskArgs, ToolContextWithMetadata } from "./types"
|
|
|
|
describe("task tool metadata awaiting", () => {
|
|
test("executeBackgroundTask awaits ctx.metadata before returning", async () => {
|
|
// given
|
|
let metadataResolved = false
|
|
const abort = new AbortController()
|
|
|
|
const ctx: ToolContextWithMetadata = {
|
|
sessionID: "ses_parent",
|
|
messageID: "msg_parent",
|
|
agent: "sisyphus",
|
|
abort: abort.signal,
|
|
metadata: async () => {
|
|
await new Promise<void>((resolve) => setTimeout(resolve, 50))
|
|
metadataResolved = true
|
|
},
|
|
}
|
|
|
|
const args: DelegateTaskArgs = {
|
|
load_skills: [],
|
|
description: "Test task",
|
|
prompt: "Do something",
|
|
run_in_background: true,
|
|
subagent_type: "explore",
|
|
}
|
|
|
|
const executorCtx = {
|
|
manager: {
|
|
launch: async () => ({
|
|
id: "task_1",
|
|
description: "Test task",
|
|
prompt: "Do something",
|
|
agent: "explore",
|
|
status: "pending",
|
|
sessionID: "ses_child",
|
|
}),
|
|
getTask: () => undefined,
|
|
},
|
|
} as any
|
|
|
|
const parentContext = {
|
|
sessionID: "ses_parent",
|
|
messageID: "msg_parent",
|
|
}
|
|
|
|
// when
|
|
const result = await executeBackgroundTask(
|
|
args,
|
|
ctx,
|
|
executorCtx,
|
|
parentContext,
|
|
"explore",
|
|
undefined,
|
|
undefined,
|
|
)
|
|
|
|
// then
|
|
expect(result).toContain("Background task launched")
|
|
expect(metadataResolved).toBe(true)
|
|
})
|
|
})
|