-
Notifications
You must be signed in to change notification settings - Fork 3.3k
feat(chat-streaming): added a stream option to workflow execute route, updated SDKs, updated docs
#1565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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)
-
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
...nents/deploy-modal/components/deployment-info/components/example-command/example-command.tsx
Outdated
Show resolved
Hide resolved
...]/w/[workflowId]/components/panel/components/chat/components/output-select/output-select.tsx
Show resolved
Hide resolved
...[workspaceId]/w/[workflowId]/components/control-bar/components/deploy-modal/deploy-modal.tsx
Outdated
Show resolved
Hide resolved
…back blocks as they complete
7881512 to
0ce6e4f
Compare
Summary
streamoption to workflow execute routeselectedOutputIdsto beselectedOutputsFixes #941
Type of Change
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