[WIP] Refactor extract functions in token-parsers file#5310
Conversation
There was a problem hiding this comment.
Pull request overview
Refactors token-usage extraction logic in the API proxy parser to reduce complexity and improve maintainability, while extending cache-read token parsing to handle deeper/nested token-entry structures.
Changes:
- Refactored cache-read token extraction by introducing recursive helpers to sum
token_type: "cache_read"across nesteddetailsarrays. - Refactored JSON/SSE usage parsing into small “builder” helpers plus a shared Copilot-breakdown merge step.
- Added a focused test covering nested
cache_readtoken entries in OpenAI Responsesusage.*_tokens_details.details.
Show a summary per file
| File | Description |
|---|---|
| containers/api-proxy/token-parsers.js | Extracted helper functions for cache-read summing and usage object construction/merging to simplify extractUsageFromJson/extractUsageFromSseLine. |
| containers/api-proxy/token-tracker.parsing.test.js | Added coverage for nested cache_read token entries to validate the new recursive extraction behavior. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 0
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (1 files)
Coverage comparison generated by |
|
@copilot address the review feedback and fix the pr title and summary |
|
@copilot address the review feedback and fix the pr title and summary |
|
📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤 |
|
✅ Smoke Gemini completed. All facets verified. 💎 Testing safeoutputs |
|
📡 Smoke OTel Tracing completed. All tracing scenarios validated. ✅ |
|
❌ Security Guard failed. Please review the logs for details. |
|
✅ Build Test Suite completed successfully! |
|
✅ Contribution Check completed successfully! |
|
Chroot tests passed! Smoke Chroot - All security and functionality tests succeeded. |
|
✅ Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓 |
|
✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟 |
|
🔑 Smoke Copilot PAT PAT auth validated. All systems operational. ✅ |
|
❌ Smoke Copilot BYOK AOAI (Entra) reports failed. AOAI BYOK (Entra) mode investigation needed... |
|
🔌 Smoke Services — All services reachable! ✅ |
|
✅ Smoke Copilot BYOK AOAI (api-key) completed. Copilot AOAI BYOK (api-key) mode operational. 🔓 |
|
❌ Smoke Claude failed |
Smoke Test: Copilot BYOK (Direct Mode) ✅✅ GitHub MCP connectivity (tested) Status: PASS cc/
|
🔬 Smoke Test ResultsPR: [WIP] Refactor extract functions in token-parsers file
Overall: PASS
|
🔬 Smoke Test: Copilot PAT Auth — Results
Overall: FAIL — Pre-step outputs ( Auth mode: PAT (COPILOT_GITHUB_TOKEN)
|
Gemini Engine Smoke Test Results
Overall Status: FAIL Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "localhost"See Network Configuration for more information.
|
|
[WIP] Refactor extract functions in token-parsers file Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "registry.npmjs.org"See Network Configuration for more information.
|
🔬 Smoke Test: API Proxy OpenTelemetry Tracing
All scenarios pass. Parent context propagation reads
|
Chroot Version Comparison Results
Overall: ❌ Not all tests passed — Python and Node.js versions differ between host and chroot environments.
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
Smoke Test: GitHub Actions Services Connectivity
Overall: FAIL
|
|
PASS: Running in direct BYOK mode (COPILOT_PROVIDER_API_KEY + COPILOT_PROVIDER_BASE_URL) via api-proxy → Azure OpenAI (Foundry)
|
extractCacheReadTokenswith helper extractionextractUsageFromJsoninto a small orchestratorextractUsageFromSseLineto reduce complexity