Skip to content

Commit babda00

Browse files
wonderwhy-erclaude
andauthored
Remove verbose console logging from ToolHistory (#258)
Removed all console.error statements from the ToolHistory class that were printing diagnostic messages to stderr, which mixed with agent output. Fixes issue where "[ToolHistory]: Loaded XXX entries from disk" and similar messages appeared in the console during normal operation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <[email protected]>
1 parent fafe30c commit babda00

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

src/utils/toolHistory.ts

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,33 +62,31 @@ class ToolHistory {
6262
private loadFromDisk(): void {
6363
try {
6464
if (!fs.existsSync(this.historyFile)) {
65-
console.error('[ToolHistory] No history file found, starting fresh');
6665
return;
6766
}
6867

6968
const content = fs.readFileSync(this.historyFile, 'utf-8');
7069
const lines = content.trim().split('\n').filter(line => line.trim());
71-
70+
7271
// Parse each line as JSON
7372
const records: ToolCallRecord[] = [];
7473
for (const line of lines) {
7574
try {
7675
records.push(JSON.parse(line));
7776
} catch (e) {
78-
console.error('[ToolHistory] Failed to parse line:', line);
77+
// Silently skip invalid lines
7978
}
8079
}
81-
80+
8281
// Keep only last 1000 entries
8382
this.history = records.slice(-this.MAX_ENTRIES);
84-
console.error(`[ToolHistory] Loaded ${this.history.length} entries from disk`);
85-
83+
8684
// If file is getting too large, trim it
8785
if (lines.length > this.MAX_ENTRIES * 2) {
8886
this.trimHistoryFile();
8987
}
9088
} catch (error) {
91-
console.error('[ToolHistory] Failed to load history:', error);
89+
// Silently fail
9290
}
9391
}
9492

@@ -97,18 +95,14 @@ class ToolHistory {
9795
*/
9896
private trimHistoryFile(): void {
9997
try {
100-
console.error('[ToolHistory] Trimming history file...');
101-
10298
// Keep last 1000 entries in memory
10399
const keepEntries = this.history.slice(-this.MAX_ENTRIES);
104-
100+
105101
// Write them back
106102
const lines = keepEntries.map(entry => JSON.stringify(entry)).join('\n') + '\n';
107103
fs.writeFileSync(this.historyFile, lines, 'utf-8');
108-
109-
console.error(`[ToolHistory] Trimmed to ${keepEntries.length} entries`);
110104
} catch (error) {
111-
console.error('[ToolHistory] Failed to trim history file:', error);
105+
// Silently fail
112106
}
113107
}
114108

@@ -141,7 +135,6 @@ class ToolHistory {
141135
const lines = toWrite.map(entry => JSON.stringify(entry)).join('\n') + '\n';
142136
fs.appendFileSync(this.historyFile, lines, 'utf-8');
143137
} catch (error) {
144-
console.error('[ToolHistory] Failed to write to disk:', error);
145138
// Put back in queue on failure
146139
this.writeQueue.unshift(...toWrite);
147140
} finally {

0 commit comments

Comments
 (0)