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 <clio-agent@sisyphuslabs.ai>
This commit is contained in:
YeonGyu-Kim
2026-03-14 13:46:50 +09:00
parent fe4493c6a6
commit e87075b9a4
3 changed files with 13 additions and 15 deletions
@@ -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")
})
@@ -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)
+9 -8
View File
@@ -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")
})
})