From e5ede6dc8c8338cf07e46f59e526934b7ca81cd3 Mon Sep 17 00:00:00 2001 From: codeg-dev <12405078+codeg-dev@users.noreply.github.com> Date: Thu, 19 Feb 2026 10:52:43 +0900 Subject: [PATCH] fix(agents): replace background_cancel(all=true) with individual task cancellation Atlas and Sisyphus prompts instructed agents to use background_cancel(all=true) before final answers. This destroys uncollected background task results and contradicts existing NEVER directives in the Sisyphus prompt, causing agents to lose explore/librarian outputs mid-session. Replace with individual task cancellation pattern that preserves completed task results while still cleaning up running disposable tasks. --- src/agents/atlas/default.ts | 3 ++- src/agents/atlas/gpt.ts | 3 ++- src/agents/hephaestus.ts | 3 ++- src/agents/sisyphus.ts | 8 ++++---- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/agents/atlas/default.ts b/src/agents/atlas/default.ts index 9ba07797..405529a4 100644 --- a/src/agents/atlas/default.ts +++ b/src/agents/atlas/default.ts @@ -311,7 +311,8 @@ task(category="quick", load_skills=[], run_in_background=false, prompt="Task 4.. **Background management**: - Collect results: \`background_output(task_id="...")\` -- Before final answer: \`background_cancel(all=true)\` +- Before final answer, cancel DISPOSABLE tasks individually: \`background_cancel(taskId="bg_explore_xxx")\`, \`background_cancel(taskId="bg_librarian_xxx")\` +- **NEVER use \`background_cancel(all=true)\`** — it kills tasks whose results you haven't collected yet diff --git a/src/agents/atlas/gpt.ts b/src/agents/atlas/gpt.ts index 99bddeaa..90d922d2 100644 --- a/src/agents/atlas/gpt.ts +++ b/src/agents/atlas/gpt.ts @@ -298,7 +298,8 @@ task(category="quick", load_skills=[], run_in_background=false, prompt="Task 3.. **Background management**: - Collect: \`background_output(task_id="...")\` -- Cleanup: \`background_cancel(all=true)\` +- Before final answer, cancel DISPOSABLE tasks individually: \`background_cancel(taskId="bg_explore_xxx")\`, \`background_cancel(taskId="bg_librarian_xxx")\` +- **NEVER use \`background_cancel(all=true)\`** — it kills tasks whose results you haven't collected yet diff --git a/src/agents/hephaestus.ts b/src/agents/hephaestus.ts index e300e29e..87714576 100644 --- a/src/agents/hephaestus.ts +++ b/src/agents/hephaestus.ts @@ -254,7 +254,8 @@ Prompt structure for each agent: - NEVER use \`run_in_background=false\` for explore/librarian - Continue your work immediately after launching background agents - Collect results with \`background_output(task_id="...")\` when needed -- BEFORE final answer: \`background_cancel(all=true)\` to clean up +- BEFORE final answer, cancel DISPOSABLE tasks individually: \`background_cancel(taskId="bg_explore_xxx")\`, \`background_cancel(taskId="bg_librarian_xxx")\` +- **NEVER use \`background_cancel(all=true)\`** — it kills tasks whose results you haven't collected yet ### Search Stop Conditions diff --git a/src/agents/sisyphus.ts b/src/agents/sisyphus.ts index 9ac7be1b..1079099b 100644 --- a/src/agents/sisyphus.ts +++ b/src/agents/sisyphus.ts @@ -306,9 +306,9 @@ result = task(..., run_in_background=false) // Never wait synchronously for exp ### Background Result Collection: 1. Launch parallel agents → receive task_ids 2. Continue immediate work -3. When results needed: \`background_output(task_id=\"...\")\` -4. Before final answer, cancel DISPOSABLE tasks (explore, librarian) individually: \`background_cancel(taskId=\"bg_explore_xxx\")\`, \`background_cancel(taskId=\"bg_librarian_xxx\")\` -5. **NEVER cancel Oracle.** ALWAYS collect Oracle result via \`background_output(task_id=\"bg_oracle_xxx\")\` before answering — even if you already have enough context. +3. When results needed: \`background_output(task_id="...")\` +4. Before final answer, cancel DISPOSABLE tasks (explore, librarian) individually: \`background_cancel(taskId="bg_explore_xxx")\`, \`background_cancel(taskId="bg_librarian_xxx")\` +5. **NEVER cancel Oracle.** ALWAYS collect Oracle result via \`background_output(task_id="bg_oracle_xxx")\` before answering — even if you already have enough context. 6. **NEVER use \`background_cancel(all=true)\`** — it kills Oracle. Cancel each disposable task by its specific taskId. ### Search Stop Conditions @@ -444,7 +444,7 @@ If verification fails: 3. Report: "Done. Note: found N pre-existing lint errors unrelated to my changes." ### Before Delivering Final Answer: -- Cancel DISPOSABLE background tasks (explore, librarian) individually via \`background_cancel(taskId=\"...\")\` +- Cancel DISPOSABLE background tasks (explore, librarian) individually via \`background_cancel(taskId="...")\` - **NEVER use \`background_cancel(all=true)\`.** Always cancel individually by taskId. - **Always wait for Oracle**: When Oracle is running and you have gathered enough context from your own exploration, your next action is \`background_output\` on Oracle — NOT delivering a final answer. Oracle's value is highest when you think you don't need it.