Skip to content

fix(streaming-api): fix streaming execution - #1845

Merged
Sg312 merged 22 commits into
stagingfrom
fix/streaming-api
Nov 7, 2025
Merged

fix(streaming-api): fix streaming execution#1845
Sg312 merged 22 commits into
stagingfrom
fix/streaming-api

Conversation

@Sg312

@Sg312Sg312 commented Nov 7, 2025

Copy link
Copy Markdown
Collaborator

Summary

Fix streaming execution

Type of Change

  • Bug fix

Testing

Manual

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

waleedlatif1and others added 19 commits October 11, 2025 22:23
* improvement(performance): remove unused source/target indices, add index on snapshot id (#1603)
* fix(blog): rename building to blogs with redirect (#1604)
* improvement(privacy-policy): updated privacy policy for google (#1602)
* updated privacy policy for google
* update terms, privacy, and emails to incl address and update verbiage
* feat(guardrails): added guardrails block/tools and docs (#1605)
* Adding guardrails block
* ack PR comments
* cleanup checkbox in dark mode
* cleanup
* fix supabase tools
* fix(inference-billing): fix inference billing when stream is true via API, add drag-and-drop functionality to deployed chat (#1606)
* fix(inference): fix inference billing when stream is true via API
* add drag-and-drop to deployed chat
* feat(mistal): added mistral as a provider, updated model prices (#1607)
* feat(mistal): added mistral as a provider, updated model prices
* remove the ability for a block to reference its own outluts
* fixed order of responses for guardrails block
* feat(versions): added the ability to rename deployment versions (#1610)
* fix(vulns): fix various vulnerabilities and enhanced code security (#1611)
* fix(vulns): fix SSRF vulnerabilities
* cleanup
* cleanup
* regen docs
* remove unused deps
* fix failing tests
* cleanup
* update deps
* regen bun lock
* fix(debug-mode): remove duplicate debug mode flag (#1714)
* feat(i18n): update translations (#1709)
* improvement(condition): added variable and envvar highlighting for condition input (#1718)
* fix(dashboard): add additional context for paginated logs in dashboard, add empty state when selected cell has no data (#1719)
* fix(dashboard): add additional context for paginated logs in dashboard, add empty state when selected cell has no data
* apps/sim
* renaming
* remove relative import
* feat(tools): added webflow OAuth + tools (#1720)
* feat(tools): added webflow OAuth + tools
* remove itemId from delete item
* remove siteId
* added webhook triggers + oauth scopes + site/collection selector
* update sample payload for webflow triggers
* cleanup
* fix discord color
* feat(i18n): update translations (#1721)
* improvement(schedule): fix UI bug with schedule modal (#1722)
* fix(already-cancelled-sub): UI should allow restoring subscription
* restore functionality fixed
* fix
@vercel

vercelBot commented Nov 7, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentPreviewCommentsUpdated (UTC)
docsReadyReadyPreviewCommentNov 7, 2025 10:24pm

@Sg312Sg312 changed the title Fix/streaming apifix(streaming-api): fix streaming executionNov 7, 2025

@greptile-appsgreptile-appsBot 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.

Greptile Overview

Greptile Summary

This PR fixes the streaming API execution path by introducing proper output ID resolution and delegating to a centralized streaming implementation.

Key Changes

  • Added resolveOutputIds function to convert human-readable block names (e.g. BlockName.path) to UUID-based IDs (e.g. uuid_path)
  • Split SSE streaming into two paths:
    • Draft state mode: Uses existing manual SSE implementation for console log streaming
    • Deployed state mode: Uses new createStreamingResponse helper for filtered API responses
  • Imported uuidValidate for proper UUID detection (replacing regex-based validation)

How it works

When executing deployed workflows with streaming enabled and selectedOutputs specified, the code now:

  1. Loads the deployed workflow state to access block metadata
  2. Resolves output IDs by matching block names to their UUIDs
  3. Delegates to createStreamingResponse which handles streaming execution with proper output filtering and tokenization

This consolidates streaming logic and ensures consistent behavior across API and chat execution paths.

Confidence Score: 4/5

  • This PR is safe to merge with minimal risk after thorough testing
  • The changes consolidate streaming logic and add proper output ID resolution. The implementation is sound with defensive checks (undefined handling, logging warnings for invalid IDs). Score is 4 instead of 5 due to: (1) lack of tests in the PR, (2) the resolveOutputIds function has edge cases that should be verified with real-world data, and (3) this changes critical execution paths for deployed workflows
  • Verify apps/sim/app/api/workflows/[id]/execute/route.ts with integration tests covering edge cases in output ID resolution (UUIDs with underscores, block names with special characters)

Important Files Changed

File Analysis

FilenameScoreOverview
apps/sim/app/api/workflows/[id]/execute/route.ts4/5Added streaming API response path with output ID resolution to convert block names to UUIDs; refactored SSE streaming to use createStreamingResponse for deployed workflows

Sequence Diagram

sequenceDiagram
participant Client
participant POST_Handler as POST /api/workflows/[id]/execute
participant resolveOutputIds
participant createStreamingResponse
participant executeWorkflow
participant executeWorkflowCore
Client->>POST_Handler: POST request with selectedOutputs
POST_Handler->>POST_Handler: Check auth & validate workflow
POST_Handler->>POST_Handler: Process input files
alt enableSSE = false
POST_Handler->>executeWorkflowCore: Execute with callbacks={}
executeWorkflowCore-->>POST_Handler: Return result
POST_Handler-->>Client: JSON response
else enableSSE = true && shouldUseDraftState
Note over POST_Handler: Manual SSE console log streaming path
POST_Handler->>POST_Handler: Create ReadableStream with callbacks
POST_Handler->>executeWorkflowCore: Execute with onBlockStart/onBlockComplete/onStream
executeWorkflowCore-->>POST_Handler: Stream events
POST_Handler-->>Client: SSE stream with execution events
else enableSSE = true && !shouldUseDraftState
Note over POST_Handler: NEW: Streaming API response path
POST_Handler->>POST_Handler: Load deployed workflow state
POST_Handler->>resolveOutputIds: Convert block names to UUIDs
resolveOutputIds-->>POST_Handler: Resolved output IDs
POST_Handler->>createStreamingResponse: Create streaming response
createStreamingResponse->>executeWorkflow: Execute with streaming callbacks
executeWorkflow->>executeWorkflowCore: Execute with callbacks
executeWorkflowCore-->>executeWorkflow: Return result with logs
executeWorkflow-->>createStreamingResponse: Process streaming outputs
createStreamingResponse-->>POST_Handler: ReadableStream
POST_Handler-->>Client: SSE stream with filtered outputs
end
Loading

1 file reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Comment threadapps/sim/app/api/workflows/[id]/execute/route.ts
Comment threadapps/sim/app/api/workflows/[id]/execute/route.ts
@Sg312
Sg312 merged commit 321c446 into stagingNov 7, 2025
3 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@Sg312@waleedlatif1@icecrasher321