Skip to content

Python: Fix DevUI streaming memory growth and add cross-platform regression coverage#5221

Merged
eavanvalkenburg merged 3 commits intomicrosoft:mainfrom
eavanvalkenburg:fix_devui_memory
Apr 14, 2026
Merged

Python: Fix DevUI streaming memory growth and add cross-platform regression coverage#5221
eavanvalkenburg merged 3 commits intomicrosoft:mainfrom
eavanvalkenburg:fix_devui_memory

Conversation

@eavanvalkenburg
Copy link
Copy Markdown
Member

@eavanvalkenburg eavanvalkenburg commented Apr 13, 2026

Motivation and Context

Streaming responses in DevUI could cause browser memory usage to grow until the page became unresponsive or was killed. This change bounds the frontend memory footprint during long streaming responses and keeps that scenario covered with a portable regression test.

Description

  • reduce per-token streaming state churn by persisting only minimal resumable state instead of full event history snapshots
  • throttle assistant text updates and buffer debug text deltas so DevUI no longer rerenders the full chat/debug pipeline on every token
  • add a browser-based DevUI memory regression test and make its browser process inspection portable across macOS, Linux, and Windows
  • regenerate the shipped DevUI frontend bundle with the updated behavior

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.

Copilot AI review requested due to automatic review settings April 13, 2026 07:52
@github-actions github-actions bot changed the title Fix DevUI streaming memory growth and add cross-platform regression coverage Python: Fix DevUI streaming memory growth and add cross-platform regression coverage Apr 13, 2026
@moonbox3
Copy link
Copy Markdown
Contributor

moonbox3 commented Apr 13, 2026

Python Test Coverage

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

Python Unit Test Overview

Tests Skipped Failures Errors Time
5486 20 💤 0 ❌ 0 🔥 1m 23s ⏱️

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses DevUI browser memory growth during long streaming responses by reducing per-token state churn in the frontend and adding a browser-based regression test to catch future regressions across platforms.

Changes:

  • Refactors streaming state persistence to store minimal resumable state (sequence/message IDs + accumulated text), with throttled saves.
  • Throttles assistant message text rendering and buffers debug text deltas to reduce per-token rerenders.
  • Adds a cross-platform, browser-driven memory regression test for streaming scenarios.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
python/packages/devui/tests/devui/test_ui_memory_regression.py New browser/OS RSS-based regression test to detect unbounded renderer memory growth during streaming.
python/packages/devui/frontend/src/services/streaming-state.ts Removes event-history persistence; adds minimal state helpers for resumable streaming.
python/packages/devui/frontend/src/services/api.ts Updates streaming/resume logic to record minimal state and throttle localStorage writes.
python/packages/devui/frontend/src/components/features/agent/agent-view.tsx Throttles assistant text updates during streaming to avoid rerendering on every token.
python/packages/devui/frontend/src/App.tsx Buffers debug text delta events and flushes periodically to reduce debug panel churn.
Comments suppressed due to low confidence (1)

python/packages/devui/frontend/src/services/streaming-state.ts:173

  • markStreamingCompleted() is now unused (no call sites in the frontend), and the streaming flow clears state instead. Consider removing this export (or reusing it consistently) to avoid dead code and confusion about whether completed states should be persisted or deleted.
export function markStreamingCompleted(conversationId: string): void {
  try {
    const existing = readStreamingState(conversationId);
    if (existing) {
      existing.completed = true;
      existing.timestamp = Date.now();
      saveStreamingState(existing);
    }
  } catch (error) {
    console.error("Failed to mark streaming as completed:", error);
  }
}

@eavanvalkenburg eavanvalkenburg added this pull request to the merge queue Apr 14, 2026
Merged via the queue into microsoft:main with commit 98e1776 Apr 14, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants