Skip to content

Commit fa94ee6

Browse files
authored
Terminal output compaction code (#325937)
* logging compaction hint * splitting and checking against split tokens * adding compaction experimentation code * removed the other telemetry lines * removing useless code
1 parent 793c02d commit fa94ee6

5 files changed

Lines changed: 5926 additions & 2 deletions

File tree

src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/runInTerminalToolTelemetry.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { ITelemetryService } from '../../../../../platform/telemetry/common/tele
88
import { TelemetryTrustedValue } from '../../../../../platform/telemetry/common/telemetryUtils.js';
99
import { ChatConfiguration } from '../../../chat/common/constants.js';
1010
import type { ITerminalInstance } from '../../../terminal/browser/terminal.js';
11+
import type { Report } from './tools/consoleCompactor/consoleCompactor.js';
1112
import { ShellIntegrationQuality } from './toolTerminalCreator.js';
1213

1314
export class RunInTerminalToolTelemetry {
@@ -214,6 +215,41 @@ export class RunInTerminalToolTelemetry {
214215
compressOutputEnabled: this._configurationService.getValue<boolean>(ChatConfiguration.CompressOutputEnabled) === true,
215216
});
216217
}
218+
219+
/**
220+
* Reports the measurements produced by the terminal output compaction
221+
* {@link Report}, so the effectiveness of compaction (how much output was
222+
* removed and whether it was lossless) can be evaluated across sessions.
223+
*/
224+
logCompaction(report: Report): void {
225+
type TelemetryEvent = {
226+
commandKinds: TelemetryTrustedValue<string>;
227+
originalChars: number;
228+
compactedChars: number;
229+
};
230+
type TelemetryClassification = {
231+
owner: 'aiday-mar';
232+
comment: 'Measures how effective terminal output compaction is for the runInTerminal tool';
233+
commandKinds: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The compactor tags that matched the command, encoded as a JSON array' };
234+
originalChars: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; isMeasurement: true; comment: 'The number of UTF-16 characters in the original output' };
235+
compactedChars: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; isMeasurement: true; comment: 'The number of UTF-16 characters in the compacted output' };
236+
};
237+
this._telemetryService.publicLog2<TelemetryEvent, TelemetryClassification>('toolUse.runInTerminal.compaction', {
238+
commandKinds: new TelemetryTrustedValue(JSON.stringify(report.commandKinds)),
239+
originalChars: report.original.chars,
240+
compactedChars: report.compacted.chars
241+
});
242+
}
243+
244+
logCompactionFailed(): void {
245+
type TelemetryEvent = Record<never, never>;
246+
type TelemetryClassification = {
247+
owner: 'aiday-mar';
248+
comment: 'Tracks failures when terminal output compaction throws before producing a report';
249+
};
250+
251+
this._telemetryService.publicLog2<TelemetryEvent, TelemetryClassification>('toolUse.runInTerminal.compactionFailed', {});
252+
}
217253
}
218254

219255

0 commit comments

Comments
 (0)