Skip to content

Python: Fix DevUI streaming memory growth regression#6038

Merged
eavanvalkenburg merged 3 commits into
microsoft:mainfrom
eavanvalkenburg:fix/devui-streaming-memory-regression-5877
May 27, 2026
Merged

Python: Fix DevUI streaming memory growth regression#6038
eavanvalkenburg merged 3 commits into
microsoft:mainfrom
eavanvalkenburg:fix/devui-streaming-memory-regression-5877

Conversation

@eavanvalkenburg
Copy link
Copy Markdown
Member

Motivation and Context

Fixes #5877.

DevUI streaming can retain too much browser-side state during long streamed answers, causing renderer memory growth. This change bounds the main retained state paths while preserving streaming and refresh-resume behavior with a capped preview.

Description

  • Bound persisted streaming resume text to a capped preview instead of storing the full accumulated response in localStorage.
  • Cap retained debug events and truncate oversized text deltas before storing them in the debug panel state.
  • Share memoized processed debug events between debug tabs/counts to avoid repeated full-history processing during streaming.
  • Strengthen the browser memory regression test with probes for streaming-state storage size and retained debug DOM event count.
  • Regenerate the shipped DevUI frontend bundle.

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.

Bounds retained streaming/debug state in DevUI and strengthens browser regression coverage for long streamed responses.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 22, 2026 15:27
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 a DevUI browser-side memory growth regression during long streaming responses by bounding persisted streaming-resume state, limiting retained debug history, reducing repeated processing work in the debug panel, and strengthening the browser-based regression test to detect these issues.

Changes:

  • Cap persisted streaming resume text to a bounded tail preview (with an explicit “preview” marker) instead of storing the full accumulated response.
  • Limit retained debug events and truncate large text deltas before they enter the debug panel state; memoize processed debug events to avoid repeated full-history processing during streaming.
  • Expand the DevUI streaming memory regression test to probe localStorage streaming-state footprint and retained debug DOM node counts.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
python/packages/devui/tests/devui/test_ui_memory_regression.py Adds browser probes for localStorage streaming-state size and debug event DOM retention, and asserts new caps during streaming.
python/packages/devui/frontend/src/stores/devuiStore.ts Caps retained debug events and truncates oversized text deltas before storing debug events.
python/packages/devui/frontend/src/services/streaming-state.ts Introduces bounded accumulatedText preview behavior and records whether the stored text is a preview.
python/packages/devui/frontend/src/services/api.ts Preserves the new accumulatedText preview flag when resuming streaming state.
python/packages/devui/frontend/src/components/layout/debug-panel.tsx Adds DOM markers for debug event items and shares memoized processed events across tabs/counts to reduce reprocessing.
python/packages/devui/frontend/src/components/features/workflow/workflow-view.tsx Refactors workflow event timestamp extraction into a shared helper.
python/packages/devui/frontend/src/components/features/agent/agent-view.tsx Restores streaming text with a prefix when only a preview tail is available after refresh.

Comment thread python/packages/devui/tests/devui/test_ui_memory_regression.py
Comment thread python/packages/devui/frontend/src/services/streaming-state.ts
@moonbox3
Copy link
Copy Markdown
Contributor

moonbox3 commented May 22, 2026

Python Test Coverage

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

Python Unit Test Overview

Tests Skipped Failures Errors Time
7244 34 💤 0 ❌ 0 🔥 1m 59s ⏱️

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Automated Code Review

Reviewers: 4 | Confidence: 88%

✓ Correctness

No actionable issues found in this dimension.

✓ Security Reliability

No actionable issues found in this dimension.

✓ Test Coverage

The PR adds browser-level memory probes to the existing E2E regression test, validating that streaming state storage and debug event DOM count stay within bounds. The assertions are structurally sound (debug panel renders without virtualization and is open by default). However, the new assertions only check upper bounds and could pass vacuously if the features under test fail to render or persist data at all. A lower-bound assertion would strengthen confidence that the caps are actually being exercised. No frontend unit test infrastructure exists in the project, so the absence of unit tests for prepareDebugEvent, the streaming text cap logic, and getWorkflowEventTimestamp is a pre-existing gap rather than a regression introduced by this PR.

✗ Design Approach

That silently presents truncated preview text as if it were the full streamed answer in that UI flow. The capped preview approach fixes the storage growth, but it also introduces one functional regression in the refresh-resume path: after the preview limit is hit, a page refresh resumes from only the stored tail, so the final in-progress assistant message silently loses the earlier prefix of the response.


Automated review by eavanvalkenburg's agents

Comment thread python/packages/devui/tests/devui/test_ui_memory_regression.py
eavanvalkenburg and others added 2 commits May 26, 2026 14:59
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@eavanvalkenburg eavanvalkenburg added this pull request to the merge queue May 27, 2026
Merged via the queue into microsoft:main with commit 3242d8a May 27, 2026
42 of 47 checks passed
@eavanvalkenburg eavanvalkenburg deleted the fix/devui-streaming-memory-regression-5877 branch May 27, 2026 14:03
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.

Python: [Bug]: Regression on DevUI streaming memory growth issue

4 participants