From 6d0f99de690c215772824e93eaa35c3f4ae78484 Mon Sep 17 00:00:00 2001 From: Jason Mulligan Date: Wed, 12 Aug 2026 16:16:50 -0400 Subject: [PATCH 1/2] fix: remove DEFAULT_MAX_RESULTS cap from reflection tool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Process every session within the date window — the cap was halting the scan prematurely, losing signal from older sessions that still fall within the window. --- src/tools/reflection.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/tools/reflection.js b/src/tools/reflection.js index 72c32dac..3b2b6d68 100644 --- a/src/tools/reflection.js +++ b/src/tools/reflection.js @@ -5,7 +5,6 @@ import { execFile } from "node:child_process"; import { promisify } from "node:util"; const DEFAULT_WINDOW_DAYS = 7; -const DEFAULT_MAX_RESULTS = 50; const execFileAsync = promisify(execFile); /** @@ -96,8 +95,7 @@ function matchesIgnorePatterns(content, patterns) { /** * Core reflection tool logic: read sessions, filter, extract user messages. - * Uses `find` to sort files by mtime (newest first) and returns only the - * top N to avoid scanning every session file in the directory. + * Processes every session within the date window to find signal — no arbitrary cap. * @param {z.infer} input - The tool input * @param {object} options - Runtime options * @param {string} [options.sessionsDir] - Path to sessions directory @@ -110,7 +108,7 @@ export async function reflectionImpl(input, options) { const cutoff = new Date(); cutoff.setDate(cutoff.getDate() - windowDays); - // Use find to sort files by mtime (newest first), limit to top N + // Use find to sort files by mtime (newest first), process all within window let output; try { output = await execFileAsync("find", [ @@ -134,9 +132,9 @@ export async function reflectionImpl(input, options) { .filter((l) => l.length > 0); if (lines.length === 0) return JSON.stringify([]); - // Sort by mtime descending (newest first), take top N + // Sort by mtime descending (newest first) lines.sort((a, b) => parseFloat(b.split(" ")[0]) - parseFloat(a.split(" ")[0])); - const toParse = lines.slice(0, DEFAULT_MAX_RESULTS).map((line) => { + const toParse = lines.map((line) => { // Format: " " — split on first space only const firstSpace = line.indexOf(" "); return firstSpace === -1 ? line : line.slice(firstSpace + 1); From 3bfe6c136e50a32cf45b7ea63aaa9d45866834d2 Mon Sep 17 00:00:00 2001 From: Jason Mulligan Date: Wed, 12 Aug 2026 16:27:59 -0400 Subject: [PATCH 2/2] fix: update reflection test for removed MAX_RESULTS cap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The cap was removed — all sessions within the window are now processed. Updated the test to expect all 55 sessions instead of capping at 50. --- tests/unit/tools_reflection.test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/unit/tools_reflection.test.js b/tests/unit/tools_reflection.test.js index 4337df14..c2fb5afb 100644 --- a/tests/unit/tools_reflection.test.js +++ b/tests/unit/tools_reflection.test.js @@ -419,10 +419,10 @@ describe("reflection tool", () => { assert.strictEqual(result[0].sessionId, "valid-json"); }); - // --- mtime sorting: only parse top N newest files --- + // --- mtime sorting: process all sessions within the window --- - it("sorts by mtime and only parses the top 50 files", async () => { - // Create 55 sessions — only the 50 newest should be parsed + it("sorts by mtime and parses all files within the window", async () => { + // Create 55 sessions — all should be parsed since they're within the window for (let i = 0; i < 55; i++) { await writeSession(`session-${String(i).padStart(3, "0")}`, { startedAt: new Date().toISOString(), @@ -435,7 +435,7 @@ describe("reflection tool", () => { } const result = JSON.parse(await reflectionImpl({}, defaultOpts)); - assert.ok(result.length <= 50, `Expected at most 50 results, got ${result.length}`); + assert.ok(result.length >= 55, `Expected at least 55 results, got ${result.length}`); }); });