fix(background-agent): redact archived prompts and cap fallback archive
Store only sanitized completed-task snapshots in archive to avoid retaining sensitive prompts after cleanup. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -6014,7 +6014,41 @@ describe("BackgroundManager regression fixes - resume and aborted notification",
|
||||
|
||||
//#then
|
||||
expect(getTaskMap(manager).has(task.id)).toBe(false)
|
||||
expect(manager.getTask(task.id)?.sessionId).toBe(task.sessionId)
|
||||
const archivedTask = manager.getTask(task.id)
|
||||
expect(archivedTask?.sessionId).toBe(task.sessionId)
|
||||
expect(archivedTask?.prompt).toBe("[redacted]")
|
||||
|
||||
manager.shutdown()
|
||||
})
|
||||
|
||||
test("should cap completed task archive size at 100 entries", () => {
|
||||
//#given
|
||||
const manager = createBackgroundManager()
|
||||
|
||||
//#when
|
||||
for (let index = 0; index < 120; index += 1) {
|
||||
const task: BackgroundTask = {
|
||||
id: `task-archive-${index}`,
|
||||
sessionId: `session-archive-${index}`,
|
||||
parentSessionId: "parent-session",
|
||||
parentMessageId: "msg-1",
|
||||
description: "archive cap regression",
|
||||
prompt: `sensitive-${index}`,
|
||||
agent: "explore",
|
||||
status: "completed",
|
||||
startedAt: new Date(),
|
||||
completedAt: new Date(),
|
||||
}
|
||||
;(cast<{ removeTask: (task: BackgroundTask) => void }>(manager)).removeTask(task)
|
||||
}
|
||||
|
||||
//#then
|
||||
const archive = cast<Map<string, unknown>>(Reflect.get(manager, "completedTaskArchive"))
|
||||
expect(archive.size).toBe(100)
|
||||
expect(archive.has("task-archive-0")).toBe(false)
|
||||
expect(archive.has("task-archive-19")).toBe(false)
|
||||
expect(archive.has("task-archive-20")).toBe(true)
|
||||
expect(archive.has("task-archive-119")).toBe(true)
|
||||
|
||||
manager.shutdown()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user