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.
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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")
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user