Fix Copilot log parser: accumulate token usage and improve JSON block detection #2050
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
The Copilot JavaScript log parser had two issues with the new debug log format:
Changes
Token Usage Accumulation
Modified
parseDebugLogFormat()to accumulate token usage across all API responses:Also normalized OpenAI's field names (
prompt_tokens/completion_tokens) to the standard format (input_tokens/output_tokens) used by the renderer.JSON Block Detection Fix
Fixed bug where lines with timestamps weren't properly ending JSON blocks. The parser now distinguishes JSON continuation lines from log entry lines:
This ensures lines like
2025-10-21T01:00:02.000Z [DEBUG] response (Request-ID test-2):properly end the current JSON block, while lines like2025-10-21T01:00:00.500Z [DEBUG] {are correctly identified as JSON content.Impact
Testing
All 29 tests passing, including new test for token accumulation across multiple responses.
Note
Tool call response content parsing (showing ✅/❌ instead of ❓ for tool results) requires access to actual workflow run logs to understand the exact format. The infrastructure is ready to support this once we can examine real log samples from the new Copilot CLI version.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.