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:
@@ -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()
|
||||
|
||||
@@ -64,6 +64,7 @@ export function createTask(input: LaunchInput): BackgroundTask {
|
||||
parentModel: input.parentModel,
|
||||
parentAgent: input.parentAgent,
|
||||
model: input.model,
|
||||
writeOutputToFile: input.writeOutputToFile,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user