Python: Fix DevUI streaming memory growth and add cross-platform regression coverage#5221
Merged
eavanvalkenburg merged 3 commits intomicrosoft:mainfrom Apr 14, 2026
Merged
Conversation
Contributor
Contributor
There was a problem hiding this comment.
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);
}
}
moonbox3
approved these changes
Apr 14, 2026
SergeyMenshykh
approved these changes
Apr 14, 2026
745f455 to
b218a91
Compare
SergeyMenshykh
approved these changes
Apr 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Contribution Checklist