refactor: migrate delegate_task to task tool with metadata fixes

- 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
This commit is contained in:
YeonGyu-Kim
2026-02-06 16:01:54 +09:00
parent f1c794e63e
commit a691a3ac0a
78 changed files with 1182 additions and 403 deletions
+16 -16
View File
@@ -86,7 +86,7 @@ describe("atlas hook", () => {
// when - calling with undefined output
const result = await hook["tool.execute.after"](
{ tool: "delegate_task", sessionID: "session-123" },
{ tool: "task", sessionID: "session-123" },
undefined as unknown as { title: string; output: string; metadata: Record<string, unknown> }
)
@@ -94,8 +94,8 @@ describe("atlas hook", () => {
expect(result).toBeUndefined()
})
test("should ignore non-delegate_task tools", async () => {
// given - hook and non-delegate_task tool
test("should ignore non-task tools", async () => {
// given - hook and non-task tool
const hook = createAtlasHook(createMockPluginInput())
const output = {
title: "Test Tool",
@@ -138,7 +138,7 @@ describe("atlas hook", () => {
// when
await hook["tool.execute.after"](
{ tool: "delegate_task", sessionID },
{ tool: "task", sessionID },
output
)
@@ -162,14 +162,14 @@ describe("atlas hook", () => {
// when
await hook["tool.execute.after"](
{ tool: "delegate_task", sessionID },
{ tool: "task", sessionID },
output
)
// then - standalone verification reminder appended
expect(output.output).toContain("Task completed successfully")
expect(output.output).toContain("MANDATORY:")
expect(output.output).toContain("delegate_task(session_id=")
expect(output.output).toContain("task(session_id=")
cleanupMessageStorage(sessionID)
})
@@ -199,7 +199,7 @@ describe("atlas hook", () => {
// when
await hook["tool.execute.after"](
{ tool: "delegate_task", sessionID },
{ tool: "task", sessionID },
output
)
@@ -208,7 +208,7 @@ describe("atlas hook", () => {
expect(output.output).toContain("SUBAGENT WORK COMPLETED")
expect(output.output).toContain("test-plan")
expect(output.output).toContain("LIE")
expect(output.output).toContain("delegate_task(session_id=")
expect(output.output).toContain("task(session_id=")
cleanupMessageStorage(sessionID)
})
@@ -238,7 +238,7 @@ describe("atlas hook", () => {
// when
await hook["tool.execute.after"](
{ tool: "delegate_task", sessionID },
{ tool: "task", sessionID },
output
)
@@ -275,7 +275,7 @@ describe("atlas hook", () => {
// when
await hook["tool.execute.after"](
{ tool: "delegate_task", sessionID },
{ tool: "task", sessionID },
output
)
@@ -311,7 +311,7 @@ describe("atlas hook", () => {
// when
await hook["tool.execute.after"](
{ tool: "delegate_task", sessionID },
{ tool: "task", sessionID },
output
)
@@ -348,7 +348,7 @@ describe("atlas hook", () => {
// when
await hook["tool.execute.after"](
{ tool: "delegate_task", sessionID },
{ tool: "task", sessionID },
output
)
@@ -385,12 +385,12 @@ describe("atlas hook", () => {
// when
await hook["tool.execute.after"](
{ tool: "delegate_task", sessionID },
{ tool: "task", sessionID },
output
)
// then - should include session_id instructions and verification
expect(output.output).toContain("delegate_task(session_id=")
expect(output.output).toContain("task(session_id=")
expect(output.output).toContain("[x]")
expect(output.output).toContain("MANDATORY:")
@@ -425,8 +425,8 @@ describe("atlas hook", () => {
// then
expect(output.output).toContain("ORCHESTRATOR, not an IMPLEMENTER")
expect(output.output).toContain("delegate_task")
expect(output.output).toContain("delegate_task")
expect(output.output).toContain("task")
expect(output.output).toContain("task")
})
test("should append delegation reminder when orchestrator edits outside .sisyphus/", async () => {
+10 -10
View File
@@ -44,7 +44,7 @@ You just performed direct file modifications outside \`.sisyphus/\`.
**You are an ORCHESTRATOR, not an IMPLEMENTER.**
As an orchestrator, you should:
- **DELEGATE** implementation work to subagents via \`delegate_task\`
- **DELEGATE** implementation work to subagents via \`task\`
- **VERIFY** the work done by subagents
- **COORDINATE** multiple tasks and ensure completion
@@ -54,7 +54,7 @@ You should NOT:
- Implement features yourself
**If you need to make changes:**
1. Use \`delegate_task\` to delegate to an appropriate subagent
1. Use \`task\` to delegate to an appropriate subagent
2. Provide clear instructions in the prompt
3. Verify the subagent's work after completion
@@ -128,7 +128,7 @@ You (Atlas) are attempting to directly modify a file outside \`.sisyphus/\`.
**THIS IS FORBIDDEN** (except for VERIFICATION purposes)
As an ORCHESTRATOR, you MUST:
1. **DELEGATE** all implementation work via \`delegate_task\`
1. **DELEGATE** all implementation work via \`task\`
2. **VERIFY** the work done by subagents (reading files is OK)
3. **COORDINATE** - you orchestrate, you don't implement
@@ -146,11 +146,11 @@ As an ORCHESTRATOR, you MUST:
**IF THIS IS FOR VERIFICATION:**
Proceed if you are verifying subagent work by making a small fix.
But for any substantial changes, USE \`delegate_task\`.
But for any substantial changes, USE \`task\`.
**CORRECT APPROACH:**
\`\`\`
delegate_task(
task(
category="...",
prompt="[specific single task with clear acceptance criteria]"
)
@@ -193,7 +193,7 @@ function buildVerificationReminder(sessionId: string): string {
**If ANY verification fails, use this immediately:**
\`\`\`
delegate_task(session_id="${sessionId}", prompt="fix: [describe the specific failure]")
task(session_id="${sessionId}", prompt="fix: [describe the specific failure]")
\`\`\``
}
@@ -688,12 +688,12 @@ export function createAtlasHook(
return
}
// Check delegate_task - inject single-task directive
if (input.tool === "delegate_task") {
// Check task - inject single-task directive
if (input.tool === "task") {
const prompt = output.args.prompt as string | undefined
if (prompt && !prompt.includes(SYSTEM_DIRECTIVE_PREFIX)) {
output.args.prompt = `<system-reminder>${SINGLE_TASK_DIRECTIVE}</system-reminder>\n` + prompt
log(`[${HOOK_NAME}] Injected single-task directive to delegate_task`, {
log(`[${HOOK_NAME}] Injected single-task directive to task`, {
sessionID: input.sessionID,
})
}
@@ -732,7 +732,7 @@ export function createAtlasHook(
return
}
if (input.tool !== "delegate_task") {
if (input.tool !== "task") {
return
}