Skip to content

Feature - Code execution Middle ware output streaming to UI - #81

Draft
saharannaveen wants to merge 6 commits into
redhat-data-and-ai:deep-agentfrom
saharannaveen:feat/codexecmiddleware
Draft

Feature - Code execution Middle ware output streaming to UI#81
saharannaveen wants to merge 6 commits into
redhat-data-and-ai:deep-agentfrom
saharannaveen:feat/codexecmiddleware

Conversation

@saharannaveen

Copy link
Copy Markdown

Description

What does this MR do and why?

Adds SSE streaming support for real-time code execution output from the template-agent's CodeExecutionMiddleware. When the agent runs code in an ephemeral K8s pod, stdout chunks now stream through Aegra → BFF → UI in real-time instead of appearing all at once after completion.

Changes

  • proxy.router.ts: Added 'custom' to stream_mode array for LangGraph Platform SSE. Added handler for custom events — emits
    code_output chunks to UI, skips all other custom events with continue to prevent partial text state corruption.
  • SSEProcessor.ts: Added code_output to SSEChunk type union and parser.
  • StreamingManager.ts: Added onCodeOutput callback to StreamCallback interface and dispatch logic.
  • useStreamingAPI.ts: Wired onCodeOutput callback with console logging in both submit and resume paths.

AI Disclosure

AI used: Yes |
Tool(s): None
Scope: BFF proxy handler, SSE processor, streaming manager, hook wiring |
Human verification: Tested with template-agent on Kind cluster — code output events visible in browser console during
execution.

Checklist

  • I have reviewed my own diff
  • AI output verified for correctness

Deployment & Security Impact

Deployment: No new env vars. Adding 'custom' to stream_mode is backward-compatible — Aegra ignores unknown modes gracefully.
The BFF continue guard ensures unknown custom events are silently skipped.

Security: No auth changes. Code output content is the same stdout/stderr already visible in the ToolMessage — streaming just
makes it real-time.

Reviewer Notes

  1. proxy.router.ts line 494 — the continue guard is load-bearing. All custom events must skip translateMessageEvent() at
    line 511 — not just code_output. That function maintains a prevPartial text accumulator for token streaming. A custom event
    has a different JSON shape, would return [null, ''], and reset prevPartial to empty — causing duplicate or missing text in
    the chat.
  2. proxy.router.ts line 342 — adding 'custom' to stream_mode is safe. When no StreamWriter is called (normal chat, HITL, MCP tools), Aegra never emits custom events. The BFF change is inert — zero impact on existing flows. Safe to deploy UI before or after agent.
  3. StreamingManager.ts line 50 — onCodeOutput is optional. Uses callbacks.onCodeOutput?.(...) safe call. Existing consumers that don't provide it are unaffected. Currently wired to console.log only — no Redux state changes, no new re-renders.

nsaharan and others added 6 commits July 3, 2026 15:23
- InterruptBanner: parse structured tool_approval payloads, show subagent
  name and tool name in approval prompt
- SubAgentIndicator: show "Tool Approval Required" with tool name and args
  when per-subagent tool_approval interrupt fires
- Add 'custom' to stream_mode for LangGraph Platform SSE
- Handle code_output custom events in BFF proxy (skip all other custom
  events to prevent partial text state corruption)
- Add code_output chunk type to SSEProcessor
- Add onCodeOutput callback to StreamingManager
- Wire console logging in useStreamingAPI for code execution output
Took deep-agent's InterruptBanner and SubAgentIndicator. Merged
proxy.router.ts: kept code_output custom event handler, adopted
uiChunks variable rename from deep-agent.
@saharannaveen
saharannaveen marked this pull request as draft July 20, 2026 13:53
branches:
- main
- deep-agent
- feat/rhitaif-221

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.

Why is this branch included in the yml?

setTraceId(data.trace_id);
},
onCodeOutput(content) {
console.log('[code_execution_output]', content);

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.

What is the purpose behind logging in console?

@NP-compete NP-compete added the deep-agent PRs targeting the deep-agent branch label Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deep-agent PRs targeting the deep-agent branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants