From d556937c8e48775ae665ab7a97538e744f1459b8 Mon Sep 17 00:00:00 2001 From: Ze-Xuan Liu Date: Thu, 19 Feb 2026 19:30:45 -0600 Subject: [PATCH] fix(background-output): stop defaulting full_session=true for running tasks background_output auto-enabled full_session when the task was still running, returning the entire session transcript on every poll. When the parent agent had no other work and polled in a tight loop, this caused massive token waste because each response dumped thousands of tokens into the conversation history. Default full_session to false so running-task checks return a compact status table (~200 tokens). Callers can still pass full_session=true explicitly when they need the full transcript. --- .../background-task/create-background-output.ts | 2 +- src/tools/background-task/tools.test.ts | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/tools/background-task/create-background-output.ts b/src/tools/background-task/create-background-output.ts index 50b9c9b4c..0b63f2f50 100644 --- a/src/tools/background-task/create-background-output.ts +++ b/src/tools/background-task/create-background-output.ts @@ -78,7 +78,7 @@ export function createBackgroundOutput(manager: BackgroundOutputManager, client: } const isActive = task.status === "pending" || task.status === "running" - const fullSession = args.full_session ?? isActive + const fullSession = args.full_session ?? false const includeThinking = isActive || (args.include_thinking ?? false) const includeToolResults = isActive || (args.include_tool_results ?? false) diff --git a/src/tools/background-task/tools.test.ts b/src/tools/background-task/tools.test.ts index a74b2f196..79b084ce7 100644 --- a/src/tools/background-task/tools.test.ts +++ b/src/tools/background-task/tools.test.ts @@ -232,7 +232,7 @@ describe("background_output full_session", () => { expect(output).toContain("Has more: true") }) - test("defaults to full_session when task is running", async () => { + test("defaults to compact status when task is running", async () => { // #given const task = createTask({ status: "running" }) const manager = createMockManager(task) @@ -242,6 +242,21 @@ describe("background_output full_session", () => { // #when const output = await tool.execute({ task_id: "task-1" }, mockContext) + // #then + expect(output).toContain("# Task Status") + expect(output).not.toContain("# Full Session Output") + }) + + test("returns full session when explicitly requested for running task", async () => { + // #given + const task = createTask({ status: "running" }) + const manager = createMockManager(task) + const client = createMockClient({}) + const tool = createBackgroundOutput(manager, client) + + // #when + const output = await tool.execute({ task_id: "task-1", full_session: true }, mockContext) + // #then expect(output).toContain("# Full Session Output") })