feat(background-agent): integrate file writing in completion path and remove dead council code

- Add _isCompleting guard and writeTaskOutput call before status flip
- Propagate writeOutputToFile from LaunchInput to BackgroundTask
- Delete council-result-format.ts and tests (no longer needed)
- 38/38 tests passing
This commit is contained in:
ismeth
2026-02-27 15:22:03 +01:00
committed by YeonGyu-Kim
parent b6b956c4c3
commit c644643aef
4 changed files with 12 additions and 330 deletions
+11
View File
@@ -80,6 +80,7 @@ import {
type SubagentSpawnContext,
} from "./subagent-spawn-limits"
import { writeTaskOutput } from "./task-output-writer"
type OpencodeClient = PluginInput["client"]
@@ -1690,6 +1691,16 @@ export class BackgroundManager {
return false
}
// Prevent concurrent re-entry during async file write
if (task._isCompleting) return false
task._isCompleting = true
// Write output to file if requested (before status flip)
if (task.writeOutputToFile) {
const filePath = await writeTaskOutput(task, this.client)
if (filePath) task.outputFilePath = filePath
}
// Atomically mark as completed to prevent race conditions
task.status = "completed"
task.completedAt = new Date()
+1
View File
@@ -64,6 +64,7 @@ export function createTask(input: LaunchInput): BackgroundTask {
parentModel: input.parentModel,
parentAgent: input.parentAgent,
model: input.model,
writeOutputToFile: input.writeOutputToFile,
}
}