Q25: runs leave outcomes and failure causes as searchable memory
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
12e2d9dcd5
commit
8c70111c93
4 files changed
+136
No files matched your search
@@ -0,0 +1,22 @@
|
||||
import type { DatabaseSync } from "node:sqlite";
|
||||
import { KnowledgeService } from "./knowledge-service";
|
||||
|
||||
const MEMORY_CHARS = 2_000;
|
||||
|
||||
/** Keeps what a finished or failed run of real work concluded, so later runs can find it. */
|
||||
export function recordRunMemory(
|
||||
db: DatabaseSync,
|
||||
input: { orgId: string; runId: string; taskTitle: string; outcome: "completed" | "failed"; text: string },
|
||||
): void {
|
||||
const text = input.text.trim();
|
||||
if (!text) return;
|
||||
new KnowledgeService(db).create({
|
||||
orgId: input.orgId,
|
||||
topic: `${input.outcome === "completed" ? "Outcome" : "Failure"}: ${input.taskTitle}`,
|
||||
category: input.outcome === "completed" ? "run_outcome" : "failure_cause",
|
||||
content: text.length > MEMORY_CHARS ? `${text.slice(0, MEMORY_CHARS)}…` : text,
|
||||
importance: "normal",
|
||||
sourceType: "task_run",
|
||||
sourceId: input.runId,
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user