Skip to content

Commit 938010b

Browse files
authored
Merge pull request #40 from asynkron/codex/fix-history-compaction-bug
Fix history compactor log metrics
2 parents 94d8fd3 + d1ce2d4 commit 938010b

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/agent/historyCompactor.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,12 @@ export class HistoryCompactor {
123123
content: `${DEFAULT_SUMMARY_PREFIX}\n${summarizedText}`.trim(),
124124
};
125125

126+
const originalHistoryLength = history.length;
126127
history.splice(firstContentIndex, entriesToCompactCount, compactedEntry);
128+
// Log the before/after lengths explicitly so the compaction impact is clear.
127129
this._log('log', '[history-compactor] Compacted history entries.', {
128-
originalEntries: entriesToCompactCount,
130+
entriesCompacted: entriesToCompactCount,
131+
originalHistoryLength,
129132
resultingHistoryLength: history.length,
130133
});
131134

tests/unit/historyCompactor.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ describe('HistoryCompactor', () => {
5656
expect(logger.log).toHaveBeenCalledWith(
5757
'[history-compactor] Compacted summary:\nCondensed summary.',
5858
);
59+
expect(logger.log).toHaveBeenCalledWith(
60+
'[history-compactor] Compacted history entries.',
61+
{
62+
entriesCompacted: 2,
63+
originalHistoryLength: 5,
64+
resultingHistoryLength: 4,
65+
},
66+
);
5967

6068
const [payload, options] = responsesCreate.mock.calls[0];
6169
expect(payload.model).toBe('test-model');

0 commit comments

Comments
 (0)