Skip to content

Conversation

@yemohyleyemohyle
Copy link
Contributor

Add a telemetry event that would have a similar structure as engine.messages events but with content replaced by length of that content. This way the messages will be much shorter, not truncated, les likely to drop, and will allow to compute input cost of each tool - total number of characters contributed by a tool to all the conversation input messages it is included in.

export function sendEngineMessagesTelemetry(telemetryService: ITelemetryService, messages: CAPIChatMessage[], telemetryData: TelemetryData) {
export function sendEngineMessagesLengthTelemetry(telemetryService: ITelemetryService, messages: CAPIChatMessage[], telemetryData: TelemetryData, logService?: ILogService) {
// Determine if this is input or output based on message characteristics
const isOutput = messages.length === 1 && messages[0].role === 'assistant';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of trying to guess this from the input would it be easier to just pass a flag as a parameter or something?

@vs-code-engineering vs-code-engineering bot added this to the August 2025 milestone Aug 7, 2025
@roblourens roblourens enabled auto-merge August 7, 2025 02:40
@roblourens roblourens added this pull request to the merge queue Aug 7, 2025
Merged via the queue into microsoft:main with commit 7d71e4a Aug 7, 2025
6 checks passed
messages: messagesWithLength
};
logService?.info(`[TELEMETRY] engine.messages.length: ${JSON.stringify(logData, null, 2)}`);
logService?.debug(`[TELEMETRY] engine.messages.length: ${JSON.stringify(logData, null, 2)}`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is kind of noisy, why do you need to log it?

pierceboggan pushed a commit that referenced this pull request Aug 11, 2025
* add length telemetry event with log message

* convert function arguments to length

* add completionId

* remove tokens

* add modelCallId

* fix modelCallId

* fix modelCallId

* move modelCallId from inside messages

* add type guard for 'tool_calls'

* add curly brackets

* remove duplicate noChoice

* use isOutput instead of guessing input/output

* fix usage issue

* change logging to debug mode

---------

Co-authored-by: Yevhen Mohylevskyy <yevhenmohylevskyy@Yevhens-MacBook-Pro.local>
Co-authored-by: Yevhen Mohylevskyy <yevhenmohylevskyy@mac.lan>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

5 participants