Skip to content

Python: Improve DevUI, add Context Inspector view as new tab under traces - #2742

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 13 commits into
mainfrom
devui_context_inspector
Jan 7, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 13 commits into
mainfrom
devui_context_inspector

Conversation

@victordibia

@victordibia Victor Dibia (victordibia) commented Dec 10, 2025 •

Copy link
Copy Markdown
Contributor

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.

Other Changes

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 Mark Wallace (markwallace-microsoft) added documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python labels Dec 10, 2025
@markwallace-microsoft

Mark Wallace (markwallace-microsoft) commented Dec 10, 2025 •

Copy link
Copy Markdown
Contributor

Python Test Coverage

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

Python Unit Test Overview

Tests Skipped Failures Errors Time
2567 149 💤 0 ❌ 0 🔥 59.022s ⏱️

MCP tools can become stale when HTTP streaming responses end - the underlying
stdio streams close but `is_connected` remains True. This causes subsequent
requests to fail with `ClosedResourceError`.

Add `_ensure_mcp_connections()` to detect and reconnect stale MCP tools before
agent execution. This is a workaround for an upstream Agent Framework issue
where connection state isn't properly tracked.

Fixes MCP tools failing on second HTTP request in DevUI.

fixes  #1476 #1515 #2865
…non streaming mode in devui . Fixes .NET: [Python] DevUI tool call rendering in non-streaming mode?
… timelien, also ensure magentic final output shows correctly
@victordibia
Victor Dibia (victordibia) marked this pull request as ready for review December 16, 2025 21:59
Copilot AI review requested due to automatic review settings December 16, 2025 21:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jan 7, 2026
Merged via the queue into main with commit 2e1189c Jan 7, 2026
31 checks passed
@victordibia
Victor Dibia (victordibia) deleted the devui_context_inspector branch January 7, 2026 17:17