From 4d3cbda8ce179c784e7226823ed71a194f778bf4 Mon Sep 17 00:00:00 2001 From: ismeth Date: Tue, 3 Mar 2026 18:17:24 +0100 Subject: [PATCH] fix(athena): guide callers to background_wait when athena-junior is force-backgrounded When athena-junior is force-backgrounded (caller passed run_in_background=false), the response now instructs the caller to use background_wait instead of background_output, preventing repeated polling loops. --- src/tools/delegate-task/tools.test.ts | 13 ++++++++++--- src/tools/delegate-task/tools.ts | 3 ++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/tools/delegate-task/tools.test.ts b/src/tools/delegate-task/tools.test.ts index ebacffd9b..458f90110 100644 --- a/src/tools/delegate-task/tools.test.ts +++ b/src/tools/delegate-task/tools.test.ts @@ -799,7 +799,11 @@ describe("sisyphus-task", () => { ) //#then — should be forced to background despite run_in_background=false - expect(String(result)).toContain("Background task launched") + const resultStr = String(result) + expect(resultStr).toContain("Background task launched") + expect(resultStr).toContain("background_wait") + expect(resultStr).toContain("automatically backgrounded") + expect(resultStr).not.toContain("System notifies on completion") }, { timeout: 10000 }) test("athena-junior with run_in_background=true still runs in background normally", async () => { @@ -857,8 +861,11 @@ describe("sisyphus-task", () => { toolContext ) - //#then — should still be background - expect(String(result)).toContain("Background task launched") + //#then — should still be background but with normal (non-forced) message + const resultStr = String(result) + expect(resultStr).toContain("Background task launched") + expect(resultStr).toContain("System notifies on completion") + expect(resultStr).not.toContain("automatically backgrounded") }, { timeout: 10000 }) }) diff --git a/src/tools/delegate-task/tools.ts b/src/tools/delegate-task/tools.ts index 954c7442e..878e6c997 100644 --- a/src/tools/delegate-task/tools.ts +++ b/src/tools/delegate-task/tools.ts @@ -263,7 +263,8 @@ export function createDelegateTask(options: DelegateTaskToolOptions): ToolDefini }) if (effectiveRunInBackground) { - return executeBackgroundTask(args, ctx, options, parentContext, agentToUse, categoryModel, systemContent, fallbackChain) + const wasForced = isAthenaJunior && !runInBackground + return executeBackgroundTask(args, ctx, options, parentContext, agentToUse, categoryModel, systemContent, fallbackChain, wasForced) } return executeSyncTask(args, ctx, options, parentContext, agentToUse, categoryModel, systemContent, modelInfo, fallbackChain)