forked from Lilly-Protocol/agentlily-runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmemory-append-failure.test.ts
More file actions
66 lines (59 loc) · 1.81 KB
/
Copy pathmemory-append-failure.test.ts
File metadata and controls
66 lines (59 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { describe, it, expect } from "vitest";
import { TaskRunner } from "../../src/tasks/task-runner.js";
import { RuntimeError } from "../../src/errors/runtime-errors.js";
describe("TaskRunner memory append failure propagation", () => {
const stubExecutor = { execute: async () => ({ ok: true }) };
it("propagates memory store append rejection as EXECUTION_FAILED with cause", async () => {
const throwingStore = {
append: async () => {
throw new Error("DB connection lost");
},
listByAgent: async () => []
};
const runner = new TaskRunner(stubExecutor as any, throwingStore as any);
const ctx = {} as any;
try {
await runner.run(
{
taskId: "t1",
agentId: "a1",
toolName: "noop",
input: "go",
payload: {}
},
ctx
);
expect.fail("should have thrown");
} catch (e) {
const err = e as RuntimeError;
expect(err.code).toBe("EXECUTION_FAILED");
expect(err.details?.cause).toContain("DB connection lost");
}
});
it("preserves original RuntimeError from executor without wrapping", async () => {
const failingExecutor = {
execute: async () => {
throw new RuntimeError("TOOL_NOT_FOUND", "Tool missing");
}
};
const noopStore = { append: async () => {}, listByAgent: async () => [] };
const runner = new TaskRunner(failingExecutor as any, noopStore as any);
const ctx = {} as any;
try {
await runner.run(
{
taskId: "t2",
agentId: "a2",
toolName: "missing",
input: "go",
payload: {}
},
ctx
);
expect.fail("should have thrown");
} catch (e) {
const err = e as RuntimeError;
expect(err.code).toBe("TOOL_NOT_FOUND");
}
});
});