forked from Lilly-Protocol/agentlily-runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask-runner.test.ts
More file actions
52 lines (49 loc) · 1.28 KB
/
Copy pathtask-runner.test.ts
File metadata and controls
52 lines (49 loc) · 1.28 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
import { describe, expect, it } from "vitest";
import {
ActionExecutor,
AgentInstanceManager,
InMemoryMemoryStore,
TaskRunner,
ToolRegistry,
UnconfiguredModelProvider,
InMemoryRuntimeStateStore
} from "../src/index.js";
describe("TaskRunner", () => {
it("wraps unexpected tool failures in EXECUTION_FAILED", async () => {
const toolRegistry = new ToolRegistry();
toolRegistry.register({
name: "explode",
description: "Throws unexpectedly",
execute() {
throw new Error("boom");
}
});
const runner = new TaskRunner(
new ActionExecutor(toolRegistry),
new InMemoryMemoryStore()
);
const agent = new AgentInstanceManager().getOrCreate("agent-1");
await expect(
runner.run(
{
taskId: "task-5",
agentId: "agent-1",
toolName: "explode",
input: "Trigger failure",
payload: {}
},
{
runtimeId: "runtime-1",
taskId: "task-5",
agent,
memory: new InMemoryMemoryStore(),
modelProvider: new UnconfiguredModelProvider(),
state: new InMemoryRuntimeStateStore(),
now: new Date().toISOString()
}
)
).rejects.toMatchObject({
code: "EXECUTION_FAILED"
});
});
});