Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/optimize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3084,6 +3084,9 @@ export function detectBloatedClaudeMd(projectCwds: Set<string>): 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
Expand All @@ -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++
}
Expand Down
7 changes: 5 additions & 2 deletions tests/optimize.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})
})

Expand Down
Loading