Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

  • feat(chat-stream): updated workflow id execute route to support streaming via API
  • enable streaming via api
  • added only text stream option
  • cleanup deployed preview componnet
  • updated selectedOutputIds to selectedOutput
  • updated TS and Python SDKs with async, rate limits, usage, and streaming API routes
  • stream non-streaming blocks when streaming is specified
  • fix(chat-panel): add onBlockComplete handler to chat panel to stream back blocks as they complete

Summary

  • added a stream option to workflow execute route
    • updated deployed chat to call this route with stream as true
    • updated the selectedOutputIds to be selectedOutputs
  • updated SDKs, updated docs
    • TS and Python SDK's now supports async, rate limit, usage limit endpoints

Fixes #941

Type of Change

  • New feature

Testing

Tested deployed chat, selected outputs for blocks that stream & other blocks that don't stream. Adds all messages into a single response with newlines between blocks just like it did before. Chat panel also behaves the same. Also tested streaming in the API. Also tested selecting agent blocks that have response formats specified.

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)

@vercel
Copy link

vercel bot commented Oct 7, 2025

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

Project Deployment Preview Comments Updated (UTC)
sim Ready Ready Preview Comment Oct 7, 2025 10:11pm
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Oct 7, 2025 10:11pm

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Summary

This PR implements comprehensive streaming functionality across the Sim platform, enabling real-time workflow execution responses through Server-Sent Events (SSE). The changes add a `stream` parameter to the workflow execution API, allowing clients to receive partial results as workflows execute rather than waiting for completion.

The core implementation centers around a new streaming system that handles both streaming blocks (like AI agents) and non-streaming blocks (like Function blocks) in a unified response. The system uses onStream callbacks for real-time content and onBlockComplete callbacks to capture outputs from blocks that complete synchronously, ensuring all workflow outputs are included in the streamed response.

Key architectural changes include renaming selectedOutputIds to selectedOutputs throughout the codebase for better semantic clarity, implementing a centralized streaming utility (lib/workflows/streaming.ts) that coordinates between different block types, and refactoring the chat API to use the main workflow execution endpoint instead of maintaining separate chat-specific logic.

The implementation also includes significant SDK enhancements, adding async execution capabilities with job status polling, automatic retry logic with exponential backoff for rate limiting, usage monitoring, and comprehensive streaming support. Both TypeScript and Python SDKs now support the new streaming parameters and provide examples for various execution modes.

Environment variable naming has been standardized from SIMSTUDIO_* to SIM_* across all documentation and examples, reflecting a broader platform simplification effort. The changes maintain backward compatibility while providing a foundation for conversational AI applications that require real-time response streaming.

Important Files Changed

Changed Files
Filename Score Overview
apps/sim/lib/workflows/streaming.ts 4/5 New core streaming implementation that coordinates between streaming and non-streaming blocks using SSE
apps/sim/app/api/workflows/[id]/execute/route.ts 4/5 Major update adding streaming support to workflow execution with output resolution and secure filtering
apps/sim/app/api/chat/[identifier]/route.ts 4/5 Refactored to use new streaming system instead of legacy executeWorkflowForChat function
packages/ts-sdk/src/index.ts 3/5 Significant SDK enhancement adding streaming, async execution, and rate limiting but has potential type safety issues
packages/python-sdk/simstudio/__init__.py 4/5 Comprehensive Python SDK update with streaming support and retry logic
apps/sim/executor/index.ts 4/5 Core executor changes to support streaming with onBlockComplete callbacks
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-workflow-execution.ts 4/5 Updated execution hooks to support streaming with proper SSE handling
apps/docs/content/docs/en/sdks/python.mdx 2/5 Major documentation update but contains multiple syntax errors with incomplete string literals
apps/sim/app/api/chat/utils.ts 3/5 Large refactoring removing executeWorkflowForChat function, consolidating logic in workflow execute route
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/control-bar/components/deploy-modal/deploy-modal.tsx 4/5 Enhanced deploy modal with streaming output selection and improved tab organization
apps/sim/executor/types.ts 4/5 Updated execution context types to support streaming with selectedOutputs and onBlockComplete
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/chat/chat.tsx 4/5 Refactored chat component to use single message accumulation instead of per-block messages
apps/docs/content/docs/en/sdks/typescript.mdx 5/5 Comprehensive documentation update covering all new SDK features with extensive examples
apps/sim/lib/utils.ts 5/5 Added SSE utility functions with proper encoding and standard headers
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/chat/components/output-select/output-select.tsx 4/5 Complex refactor using React portals to fix positioning issues but adds significant complexity
apps/docs/content/docs/en/triggers/api.mdx 5/5 Added comprehensive streaming documentation with clear examples and SSE format explanations
packages/ts-sdk/src/index.test.ts 4/5 Comprehensive test coverage for new SDK features including streaming and rate limiting
packages/python-sdk/tests/test_client.py 4/5 Added extensive test coverage for new Python SDK streaming and async capabilities
apps/sim/app/api/workflows/middleware.ts 4/5 Added internal secret authentication bypass for chat deployments
Multiple documentation files 5/5 Environment variable naming standardization from SIMSTUDIO_* to SIM_* across all languages

Confidence score: 4/5

  • This PR introduces significant new functionality with comprehensive streaming support but has some areas requiring attention
  • Score reflects well-structured implementation with proper testing, but documentation errors and type safety concerns need addressing
  • Pay close attention to the Python SDK documentation file which contains syntax errors that would prevent users from following examples correctly

Additional Comments (1)

  1. packages/ts-sdk/src/index.ts, line 229-230 (link)

    logic: This breaks the contract - if options.async is true, executeWorkflow returns AsyncExecutionResult, not WorkflowExecutionResult

52 files reviewed, 20 comments

Edit Code Review Agent Settings | Greptile

@vercel vercel bot temporarily deployed to Preview – docs October 7, 2025 22:07 Inactive
@waleedlatif1 waleedlatif1 merged commit 872e034 into staging Oct 7, 2025
9 of 10 checks passed
@waleedlatif1 waleedlatif1 deleted the feat/chat-streaming branch October 7, 2025 22:10
@waleedlatif1 waleedlatif1 mentioned this pull request Oct 7, 2025
10 tasks
Sign up for free to 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.

2 participants