@wavequery/conductor
Version:
Modular LLM orchestration framework
49 lines • 1.68 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const agent_1 = require("../agent");
describe("Agent", () => {
let mockTool;
let mockLLM;
let agent;
beforeEach(() => {
mockTool = {
name: "test-tool",
description: "Test tool",
execute: jest.fn(),
};
mockLLM = {
complete: jest.fn(),
completeWithFunctions: jest.fn(),
};
const config = {
name: "test-agent",
llmProvider: mockLLM,
tools: [mockTool],
};
agent = new agent_1.Agent(config);
});
it("should execute tools based on LLM decisions", async () => {
mockLLM.complete.mockResolvedValueOnce({
content: JSON.stringify({
tool: "test-tool",
action: { test: true },
}),
});
mockTool.execute.mockResolvedValueOnce({ result: "success" });
const result = await agent.execute({ input: "test" });
expect(result.steps).toHaveLength(1);
expect(mockTool.execute).toHaveBeenCalledWith({ test: true });
expect(result.output).toEqual({ result: "success" });
});
it("should handle tool execution errors", async () => {
mockLLM.complete.mockResolvedValueOnce({
content: JSON.stringify({
tool: "test-tool",
action: { test: true },
}),
});
mockTool.execute.mockRejectedValueOnce(new Error("Tool error"));
await expect(agent.execute({ input: "test" })).rejects.toThrow("Tool error");
});
});
//# sourceMappingURL=agent.test.js.map