forked from Lilly-Protocol/agentlily-runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruntime-context-fields.test.ts
More file actions
44 lines (38 loc) · 1.39 KB
/
Copy pathruntime-context-fields.test.ts
File metadata and controls
44 lines (38 loc) · 1.39 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
import { describe, it, expect } from "vitest";
import { AgentRuntime } from "../../src/runtime/agent-runtime.js";
import type { ToolInvocation } from "../../src/tools/types.js";
describe("RuntimeContext fields populated per task", () => {
it("provides taskId, agent.agentId, runtimeId and ISO now to tool context", async () => {
let capturedContext: ToolInvocation["context"] | null = null;
const runtime = new AgentRuntime({
runtimeId: "test-runtime-ctx-154",
modelProvider: {
name: "stub",
generate: async () => ({ outputText: "" })
}
});
runtime.registerTool({
name: "captureContext",
description: "Captures invocation context for assertion",
execute: async (invocation: ToolInvocation) => {
capturedContext = invocation.context;
return { ok: true };
}
});
await runtime.start();
await runtime.executeTask({
agentId: "agent-alpha",
taskId: "task-beta",
toolName: "captureContext",
input: "test-input-for-context",
payload: {}
});
expect(capturedContext).not.toBeNull();
expect(capturedContext!.taskId).toBe("task-beta");
expect(capturedContext!.agent.agentId).toBe("agent-alpha");
expect(capturedContext!.runtimeId).toBe("test-runtime-ctx-154");
expect(capturedContext!.now).toMatch(
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/
);
});
});