Skip to content

improvement(agent-streaming): add way to opt in for workflow executions#5956

Merged
icecrasher321 merged 1 commit into
stagingfrom
improvement/agent-streaming-opt-in
Jul 25, 2026
Merged

improvement(agent-streaming): add way to opt in for workflow executions#5956
icecrasher321 merged 1 commit into
stagingfrom
improvement/agent-streaming-opt-in

Conversation

@icecrasher321

Copy link
Copy Markdown
Collaborator

Summary

Add standard way to opt in to thinking and tool call events.

Type of Change

  • New feature

Testing

Tested manually

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

vercel Bot commented Jul 25, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Jul 25, 2026 2:54am

Request Review

@cursor

cursor Bot commented Jul 25, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes the public streaming execute contract and may alter behavior for legacy chat rows that implicitly enabled tool frames via thinking-only toggles; core paths are well-tested but the behavior shift is user-visible.

Overview
Streaming workflow execution can now request agent-event SSE (thinking / tool frames) via per-request includeThinking and includeToolCalls on POST /api/workflows/{id}/execute, wired through the executor with agentEvents and echoed X-Sim-Stream-Protocol on the response. Either flag without the agent-events-v1 header returns 400 instead of silently ignoring the request.

includeToolCalls is decoupled from includeThinking everywhere chat and resume read deployment metadata: null/missing tool policy is treated as off (no inheritance from thinking), including manage/update paths that previously “grandfathered” tool frames when only thinking was enabled.

Docs and product surfaces follow: expanded agent-events and API deployment guides (protocol vs policy, workflow API curl, reference client), FAQ entry, executeWorkflowBodySchema defaults, deploy-modal streaming samples that add the header and flags when the workflow has an Agent block, and tightened streaming/protocol tests.

Reviewed by Cursor Bugbot for commit ab181fc. Configure here.

@greptile-apps

greptile-apps Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds opt-in Agent thinking and tool lifecycle events to streaming workflow executions.

  • Introduces request-body policies and agent-events-v1 protocol negotiation for the workflow execute API.
  • Propagates event policies through streaming execution and HITL resume metadata.
  • Updates generated deployment examples and public streaming documentation.
  • Separates chat thinking and tool-call configuration while changing how nullable legacy tool policies are interpreted.

Confidence Score: 3/5

This PR should not merge until existing nullable chat tool policies are preserved or migrated, because otherwise deployed chats can silently lose tool lifecycle events.

The new workflow API negotiation is internally consistent, but the chat-side fallback changes the meaning of persisted nullable values and can both immediately suppress existing behavior and permanently store that suppression during unrelated updates.

Files Needing Attention: apps/sim/app/api/chat/[identifier]/route.ts, apps/sim/app/api/chat/manage/[id]/route.ts, packages/db/schema.ts

Important Files Changed

Filename Overview
apps/sim/app/api/workflows/[id]/execute/route.ts Negotiates the stream protocol and propagates per-request Agent event policies through the inline streaming execution path.
apps/sim/lib/workflows/streaming/agent-stream-protocol.ts Centralizes protocol capability detection and independent event-policy gating.
apps/sim/lib/workflows/streaming/streaming.ts Gates thinking and tool frames on both protocol negotiation and their respective policies.
apps/sim/app/api/resume/[workflowId]/[executionId]/[contextId]/route.ts Restores explicitly persisted thinking and tool policies for resumed streaming executions.
apps/sim/app/api/chat/[identifier]/route.ts Reinterprets nullable legacy tool-call policies as disabled, causing existing chat deployments to lose previously inherited tool events.
packages/db/schema.ts Rewrites the nullable-column contract without migrating existing rows whose null value previously preserved legacy behavior.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/deploy/components/deploy-modal/components/api/api.tsx Adds Agent event flags and the required protocol header to generated streaming API examples when the workflow contains an Agent block.
apps/docs/content/docs/en/workflows/deployment/agent-events.mdx Documents workflow API event opt-in, negotiation requirements, frame handling, and a reference SSE consumer.

Sequence Diagram

sequenceDiagram
  participant Client
  participant Execute as Workflow Execute API
  participant Stream as Streaming Response
  participant Executor
  Client->>Execute: "POST stream=true + event flags + protocol header"
  Execute->>Execute: Validate protocol negotiation
  Execute->>Stream: Configure thinking/tool policies
  Stream->>Executor: Execute with agentEvents enabled
  Executor-->>Stream: Answer, thinking, and tool events
  Stream-->>Client: SSE frames and terminal envelope
Loading

Reviews (1): Last reviewed commit: "improvement(agent-streaming): add way to..." | Re-trigger Greptile

Comment thread apps/sim/app/api/chat/[identifier]/route.ts
@icecrasher321
icecrasher321 changed the base branch from main to staging July 25, 2026 03:09
@icecrasher321
icecrasher321 merged commit 8a2ae25 into staging Jul 25, 2026
25 checks passed
@waleedlatif1
waleedlatif1 deleted the improvement/agent-streaming-opt-in branch July 25, 2026 04:01
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.

1 participant