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:
@@ -79,7 +79,7 @@ describe("createBackgroundOutput block=true polling", () => {
|
|||||||
expect(output).not.toContain("Timed out waiting")
|
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
|
// #given
|
||||||
let pollCount = 0
|
let pollCount = 0
|
||||||
const task = createTask({ status: "running" })
|
const task = createTask({ status: "running" })
|
||||||
@@ -105,7 +105,7 @@ describe("createBackgroundOutput block=true polling", () => {
|
|||||||
|
|
||||||
// #then
|
// #then
|
||||||
expect(pollCount).toBeGreaterThanOrEqual(2)
|
expect(pollCount).toBeGreaterThanOrEqual(2)
|
||||||
expect(output).toContain("# Full Session Output")
|
expect(output).toContain("# Task Status")
|
||||||
expect(output).toContain("Timed out waiting")
|
expect(output).toContain("Timed out waiting")
|
||||||
expect(output).toContain("still running")
|
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."
|
"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)"),
|
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)"),
|
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)"),
|
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)"),
|
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 isActive = isTaskActiveStatus(resolvedTask.status)
|
||||||
const fullSessionProvided = args.full_session !== undefined
|
const fullSession = args.full_session ?? false
|
||||||
const fullSession = fullSessionProvided
|
|
||||||
? (args.full_session ?? true)
|
|
||||||
: true
|
|
||||||
const includeThinking = isActive || (args.include_thinking ?? false)
|
const includeThinking = isActive || (args.include_thinking ?? false)
|
||||||
const includeToolResults = isActive || (args.include_tool_results ?? false)
|
const includeToolResults = isActive || (args.include_tool_results ?? false)
|
||||||
|
|
||||||
|
|||||||
@@ -232,7 +232,7 @@ describe("background_output full_session", () => {
|
|||||||
expect(output).toContain("Has more: true")
|
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
|
// #given
|
||||||
const task = createTask({ status: "running" })
|
const task = createTask({ status: "running" })
|
||||||
const manager = createMockManager(task)
|
const manager = createMockManager(task)
|
||||||
@@ -243,7 +243,8 @@ describe("background_output full_session", () => {
|
|||||||
const output = await tool.execute({ task_id: "task-1" }, mockContext)
|
const output = await tool.execute({ task_id: "task-1" }, mockContext)
|
||||||
|
|
||||||
// #then
|
// #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 () => {
|
test("returns full session when explicitly requested for running task", async () => {
|
||||||
@@ -341,10 +342,10 @@ describe("background_output full_session", () => {
|
|||||||
|
|
||||||
|
|
||||||
describe("background_output blocking", () => {
|
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
|
// #given a task that transitions running → completed after 2 polls
|
||||||
let pollCount = 0
|
let pollCount = 0
|
||||||
const task = createTask({ status: "running" })
|
const task = createTask({ status: "running", sessionID: "ses-blocking-default" })
|
||||||
const manager: BackgroundOutputManager = {
|
const manager: BackgroundOutputManager = {
|
||||||
getTask: (id: string) => {
|
getTask: (id: string) => {
|
||||||
if (id !== task.id) return undefined
|
if (id !== task.id) return undefined
|
||||||
@@ -356,7 +357,7 @@ describe("background_output blocking", () => {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
const client = createMockClient({
|
const client = createMockClient({
|
||||||
"ses-1": [
|
"ses-blocking-default": [
|
||||||
{
|
{
|
||||||
id: "m1",
|
id: "m1",
|
||||||
info: { role: "assistant", time: "2026-01-01T00:00:00Z" },
|
info: { role: "assistant", time: "2026-01-01T00:00:00Z" },
|
||||||
@@ -366,17 +367,17 @@ describe("background_output blocking", () => {
|
|||||||
})
|
})
|
||||||
const tool = createBackgroundOutput(manager, client)
|
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({
|
const output = await tool.execute({
|
||||||
task_id: "task-1",
|
task_id: "task-1",
|
||||||
block: true,
|
block: true,
|
||||||
timeout: 10000,
|
timeout: 10000,
|
||||||
}, mockContext)
|
}, 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(task.status).toBe("completed")
|
||||||
expect(pollCount).toBeGreaterThanOrEqual(3)
|
expect(pollCount).toBeGreaterThanOrEqual(3)
|
||||||
expect(output).toContain("# Full Session Output")
|
expect(output).toContain("Task Result")
|
||||||
expect(output).toContain("completed result")
|
expect(output).toContain("completed result")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user