From 91793baa3ea210710eaff69d286254561478d59c Mon Sep 17 00:00:00 2001 From: Resham Joshi <65915470+iamtoruk@users.noreply.github.com> Date: Thu, 15 Oct 2026 04:53:24 -0700 Subject: [PATCH] optimize: stop counting new-file writes in the read/edit ratio Writing a new file has nothing to read first, so teams whose subagents write report and evidence files got a false 'edits more than it reads' finding. The detector now counts only Edit-type calls. EDIT_TOOL_NAMES stays as is because act report baselines were recorded with it. --- src/optimize.ts | 5 ++++- tests/optimize.test.ts | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/optimize.ts b/src/optimize.ts index dbbee71c0..78813a2eb 100644 --- a/src/optimize.ts +++ b/src/optimize.ts @@ -3084,6 +3084,9 @@ export function detectBloatedClaudeMd(projectCwds: Set): WasteFinding | export const READ_TOOL_NAMES = new Set(['Read', 'Grep', 'Glob', 'FileReadTool', 'GrepTool', 'GlobTool']) export const EDIT_TOOL_NAMES = new Set(['Edit', 'Write', 'FileEditTool', 'FileWriteTool', 'NotebookEdit']) export const BASH_TOOL_NAMES = new Set(['Bash', 'BashTool', 'PowerShellTool']) +// Writing a new file has nothing to read first; counting Write flagged subagents +// that produce reports as editing blind. Not EDIT_TOOL_NAMES: act report baselines use that. +const RATIO_EDIT_TOOL_NAMES = new Set(['Edit', 'FileEditTool', 'NotebookEdit']) export function detectLowReadEditRatio(calls: ToolCall[]): WasteFinding | null { let reads = 0 @@ -3100,7 +3103,7 @@ export function detectLowReadEditRatio(calls: ToolCall[]): WasteFinding | null { // reckless editors (90%+ of real reads were invisible to this ratio). reads++ if (call.recent) recentReads++ - } else if (EDIT_TOOL_NAMES.has(call.name)) { + } else if (RATIO_EDIT_TOOL_NAMES.has(call.name)) { edits++ if (call.recent) recentEdits++ } diff --git a/tests/optimize.test.ts b/tests/optimize.test.ts index e6c1cb2e8..c12127599 100644 --- a/tests/optimize.test.ts +++ b/tests/optimize.test.ts @@ -307,13 +307,16 @@ describe('detectLowReadEditRatio', () => { expect(detectLowReadEditRatio(calls)).toBeNull() }) - it('counts Write as edit', () => { + it('does not count Write as edit', () => { + // Subagents writing new report files have nothing to read first. const calls = [ ...Array.from({ length: 15 }, () => call('Read', {})), - ...Array.from({ length: 10 }, () => call('Write', {})), + ...Array.from({ length: 10 }, () => call('Edit', {})), + ...Array.from({ length: 30 }, () => call('Write', {})), ] const finding = detectLowReadEditRatio(calls) expect(finding).not.toBeNull() + expect(finding!.explanation).toContain('15 reads and 10 edits') }) })