Skip to content

Conversation

@victordibia
Copy link
Contributor

@victordibia victordibia commented Dec 10, 2025

Motivation and Context

This PR adds a new Context Inspector feature to DevUI for visualizing token usage and context composition, along with comprehensive TypeScript type safety improvements to address any type errors across the frontend codebase.

image

Context Inspector

A new tab in the Debug Panel that provides:

  • Token Usage Visualization: Stacked bar chart showing input/output tokens per turn
  • Context Composition View: Breakdown of what fills the context (system prompts, user messages, assistant responses, tool calls)
  • Per-turn vs Cumulative Modes: Toggle between viewing individual turn usage or accumulated context
  • Summary Statistics: Total tokens, average per turn, peak usage
  • Pure CSS Implementation: No external charting library dependencies

Tracing Improvements

  • Added NoOp exporters (NoOpSpanExporter, NoOpLogExporter, NoOpMetricExporter) to prevent console spam when tracing is enabled locally without an OTLP endpoint
  • Changed trace grouping from session_id to response_id for better per-turn organization
  • Added trace attributes type definitions for proper TypeScript support

Type Safety Improvements

Addressed 36 @typescript-eslint/no-explicit-any errors by adding proper types:
Fixed React Rules of Hooks violations in OpenAIContentRenderer.tsx by moving hooks before early returns.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

@markwallace-microsoft markwallace-microsoft added documentation Improvements or additions to documentation python labels Dec 10, 2025
@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Dec 10, 2025

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
TOTAL16283254684% 
report-only-changed-files is enabled. No files were changed during this commit :)

Python Unit Test Overview

Tests Skipped Failures Errors Time
2324 130 💤 0 ❌ 0 🔥 1m 2s ⏱️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants