test(coding-agent): cover learned-lesson injection budget exhaustion
Grill test-gap finding: the learned-lesson read-back had no coverage for the budget clamp when a memory summary already fills `summaryInjectionTokenLimit`. Add a case with an oversized summary asserting the lesson is dropped and the combined block stays bounded.
This commit is contained in:
@@ -197,6 +197,22 @@ describe("learned-lesson read-back", () => {
|
||||
expect(out).not.toContain(token);
|
||||
expect(out).toContain("[REDACTED]");
|
||||
});
|
||||
|
||||
it("drops learned lessons when the summary already fills the injection budget", async () => {
|
||||
const settings = Settings.isolated({ "memory.backend": "local" });
|
||||
const root = getMemoryRoot(agentDir, settings.getCwd());
|
||||
// A summary far larger than any injection budget: after truncation it
|
||||
// consumes the whole token budget, leaving no room for lessons.
|
||||
const hugeSummary = `${"summary ".repeat(50_000)}\n`;
|
||||
await Bun.write(path.join(root, "memory_summary.md"), hugeSummary);
|
||||
await saveLearnedLesson(agentDir, settings.getCwd(), { content: "UNIQUE_LESSON_MARKER" });
|
||||
const out = await buildMemoryToolDeveloperInstructions(agentDir, settings);
|
||||
expect(out).toBeDefined();
|
||||
expect(out).toContain("summary"); // summary is still injected (truncated)
|
||||
expect(out).not.toContain("UNIQUE_LESSON_MARKER"); // lesson dropped: budget exhausted
|
||||
// The combined block stays bounded — it never grows to the raw summary size.
|
||||
expect((out ?? "").length).toBeLessThan(hugeSummary.length);
|
||||
});
|
||||
});
|
||||
|
||||
describe("learn tool (local backend)", () => {
|
||||
|
||||
Reference in New Issue
Block a user