Verified Solution

[microsoft/vscode] Copilot chat OTel includes system instruction in message JSON

Sponsored Content
### ROOT CAUSE The system instructions are being duplicated in the prompt construction and trace recording. The system instructions are being included in both the system instructions JSON and the input messages JSON, causing duplication in the OpenTelemetry traces. ### CODE FIX We need to ensure that the system instructions are included only once in the prompt and in the trace. This requires changes to the prompt building function and the tracing function. Specifically: 1. Modify the prompt building function to include the system instructions only once. 2. Modify the tracing function to record the system instructions only once. Here is a code example of how to fix it: ```typescript // In the function that builds the prompt: function buildPrompt(systemInstructions: string, conversationHistory: Array<{ role: string, content: string }>): string { // Build the prompt by combining system instructions and conversation history let prompt = systemInstructions; conversationHistory.forEach(msg => { prompt += `\n${msg.role}: ${msg.content}`; }); return prompt; } // In the function that records the prompt for tracing: function recordPrompt(prompt: string): void { // Remove system instructions from the prompt for cleaner logging const withoutSystem = prompt.replace(systemInstructions, ''); // Log the cleaned prompt logger.info(withoutSystem); } ``` This ensures that the system instructions are included only once in the prompt and not duplicated in the trace. The exact implementation may vary based on the existing code structure, but the key is to ensure the system instructions are not duplicated.
Deploy on DigitalOcean ($200 Credit)

Related Fixes

[StackOverflow/kubernetes] Setting environment variables in deployment from Vault secret
[tensorflow/tensorflow] tf.math.reciprocal_no_nan returns inconsistent results for identical complex inf+0j inputs
[microsoft/vscode] C/C++ DevTools gets installed with chat.disableAIFeatures