From e87075b9a43577702aa12a9f454f4bb937bcd8e5 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Sat, 14 Mar 2026 13:46:50 +0900 Subject: [PATCH] fix(background-task): restore opt-in full session output Bring background_output back to the legacy contract so callers only get full session transcripts when they explicitly ask for them. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- .../create-background-output.blocking.test.ts | 4 ++-- .../background-task/create-background-output.ts | 7 ++----- src/tools/background-task/tools.test.ts | 17 +++++++++-------- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/tools/background-task/create-background-output.blocking.test.ts b/src/tools/background-task/create-background-output.blocking.test.ts index 82de143e9..b07f82ef6 100644 --- a/src/tools/background-task/create-background-output.blocking.test.ts +++ b/src/tools/background-task/create-background-output.blocking.test.ts @@ -79,7 +79,7 @@ describe("createBackgroundOutput block=true polling", () => { expect(output).not.toContain("Timed out waiting") }) - test("returns latest output with timeout note when task stays running", async () => { + test("returns legacy status output with timeout note when task stays running", async () => { // #given let pollCount = 0 const task = createTask({ status: "running" }) @@ -105,7 +105,7 @@ describe("createBackgroundOutput block=true polling", () => { // #then expect(pollCount).toBeGreaterThanOrEqual(2) - expect(output).toContain("# Full Session Output") + expect(output).toContain("# Task Status") expect(output).toContain("Timed out waiting") expect(output).toContain("still running") }) diff --git a/src/tools/background-task/create-background-output.ts b/src/tools/background-task/create-background-output.ts index 3508052cf..f0e31696e 100644 --- a/src/tools/background-task/create-background-output.ts +++ b/src/tools/background-task/create-background-output.ts @@ -53,7 +53,7 @@ export function createBackgroundOutput(manager: BackgroundOutputManager, client: "Wait for completion (default: false). System notifies when done, so blocking is rarely needed." ), timeout: tool.schema.number().optional().describe("Max wait time in ms (default: 60000, max: 600000)"), - full_session: tool.schema.boolean().optional().describe("Return full session messages with filters (default: true)"), + full_session: tool.schema.boolean().optional().describe("Return full session messages with filters (default: false)"), include_thinking: tool.schema.boolean().optional().describe("Include thinking/reasoning parts in full_session output (default: false)"), message_limit: tool.schema.number().optional().describe("Max messages to return (capped at 100)"), since_message_id: tool.schema.string().optional().describe("Return messages after this message ID (exclusive)"), @@ -122,10 +122,7 @@ export function createBackgroundOutput(manager: BackgroundOutputManager, client: } const isActive = isTaskActiveStatus(resolvedTask.status) - const fullSessionProvided = args.full_session !== undefined - const fullSession = fullSessionProvided - ? (args.full_session ?? true) - : true + 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 7ea7d0748..78d5987c4 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 compact status when task is running", async () => { + test("keeps legacy status output when full_session is not provided", async () => { // #given const task = createTask({ status: "running" }) const manager = createMockManager(task) @@ -243,7 +243,8 @@ describe("background_output full_session", () => { const output = await tool.execute({ task_id: "task-1" }, mockContext) // #then - expect(output).toContain("# Full Session Output") + expect(output).toContain("# Task Status") + expect(output).not.toContain("# Full Session Output") }) test("returns full session when explicitly requested for running task", async () => { @@ -341,10 +342,10 @@ describe("background_output full_session", () => { describe("background_output blocking", () => { - test("block=true waits for task completion even with default full_session=true", async () => { + test("block=true keeps legacy task result output when full_session is not provided", async () => { // #given a task that transitions running → completed after 2 polls let pollCount = 0 - const task = createTask({ status: "running" }) + const task = createTask({ status: "running", sessionID: "ses-blocking-default" }) const manager: BackgroundOutputManager = { getTask: (id: string) => { if (id !== task.id) return undefined @@ -356,7 +357,7 @@ describe("background_output blocking", () => { }, } const client = createMockClient({ - "ses-1": [ + "ses-blocking-default": [ { id: "m1", info: { role: "assistant", time: "2026-01-01T00:00:00Z" }, @@ -366,17 +367,17 @@ describe("background_output blocking", () => { }) const tool = createBackgroundOutput(manager, client) - // #when block=true, full_session not specified (defaults to true) + // #when block=true, full_session not specified const output = await tool.execute({ task_id: "task-1", block: true, timeout: 10000, }, mockContext) - // #then should have waited and returned full session output + // #then should have waited and returned task result output expect(task.status).toBe("completed") expect(pollCount).toBeGreaterThanOrEqual(3) - expect(output).toContain("# Full Session Output") + expect(output).toContain("Task Result") expect(output).toContain("completed result") }) })