mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 07:51:26 +00:00
Tests: cover QMD scope, reads, and citation clamp
This commit is contained in:
committed by
Vignesh
parent
1861e76360
commit
3d1c3b78ec
@@ -1,5 +1,6 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
let backend: "builtin" | "qmd" = "builtin";
|
||||
const stubManager = {
|
||||
search: vi.fn(async () => [
|
||||
{
|
||||
@@ -13,7 +14,7 @@ const stubManager = {
|
||||
]),
|
||||
readFile: vi.fn(),
|
||||
status: () => ({
|
||||
backend: "builtin" as const,
|
||||
backend,
|
||||
files: 1,
|
||||
chunks: 1,
|
||||
dirty: false,
|
||||
@@ -44,6 +45,7 @@ beforeEach(() => {
|
||||
|
||||
describe("memory search citations", () => {
|
||||
it("appends source information when citations are enabled", async () => {
|
||||
backend = "builtin";
|
||||
const cfg = { memory: { citations: "on" }, agents: { list: [{ id: "main", default: true }] } };
|
||||
const tool = createMemorySearchTool({ config: cfg });
|
||||
if (!tool) throw new Error("tool missing");
|
||||
@@ -54,6 +56,7 @@ describe("memory search citations", () => {
|
||||
});
|
||||
|
||||
it("leaves snippet untouched when citations are off", async () => {
|
||||
backend = "builtin";
|
||||
const cfg = { memory: { citations: "off" }, agents: { list: [{ id: "main", default: true }] } };
|
||||
const tool = createMemorySearchTool({ config: cfg });
|
||||
if (!tool) throw new Error("tool missing");
|
||||
@@ -62,4 +65,17 @@ describe("memory search citations", () => {
|
||||
expect(details.results[0]?.snippet).not.toMatch(/Source:/);
|
||||
expect(details.results[0]?.citation).toBeUndefined();
|
||||
});
|
||||
|
||||
it("clamps decorated snippets to qmd injected budget", async () => {
|
||||
backend = "qmd";
|
||||
const cfg = {
|
||||
memory: { citations: "on", backend: "qmd", qmd: { limits: { maxInjectedChars: 20 } } },
|
||||
agents: { list: [{ id: "main", default: true }] },
|
||||
};
|
||||
const tool = createMemorySearchTool({ config: cfg });
|
||||
if (!tool) throw new Error("tool missing");
|
||||
const result = await tool.execute("call_citations_qmd", { query: "notes" });
|
||||
const details = result.details as { results: Array<{ snippet: string; citation?: string }> };
|
||||
expect(details.results[0]?.snippet.length).toBeLessThanOrEqual(20);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user