Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions apps/docs/content/docs/en/blocks/human-in-the-loop.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -126,26 +126,38 @@ Access resume data in downstream blocks using `<blockId.fieldName>`.

- **Stream mode** (`stream: true` on the original execute call) — The resume response streams SSE events with `selectedOutputs` chunks, just like the initial execution.

- **Async mode** (`X-Execution-Mode: async` on the original execute call) — The resume dispatches execution to a background worker and returns immediately with `202`:
- **Async mode** (`X-Execution-Mode: async` on the original execute call) — The resume dispatches execution to a background worker and returns immediately with `202`, including a `jobId` and `statusUrl` for polling:

```json
{
"status": "started",
"success": true,
"async": true,
"jobId": "<jobId>",
"executionId": "<resumeExecutionId>",
"message": "Resume execution started asynchronously."
"message": "Resume execution queued",
"statusUrl": "/api/jobs/<jobId>"
}
```

#### Polling execution status

To check on a paused execution or poll for completion after an async resume:
Poll the `statusUrl` from the async response to check when the resume completes:

```bash
GET /api/jobs/{jobId}
X-API-Key: your-api-key
```

Returns job status and, when completed, the full workflow output.

To check on a paused execution's pause points and resume links:

```bash
GET /api/resume/{workflowId}/{executionId}
X-API-Key: your-api-key
```

Returns the full paused execution detail with all pause points, their statuses, and resume links. Returns `404` when the execution has completed and is no longer paused.
Returns the paused execution detail with all pause points, their statuses, and resume links. Returns `404` when the execution has completed and is no longer paused.
</Tab>
<Tab>
### Webhook
Expand Down
25 changes: 2 additions & 23 deletions apps/sim/app/api/form/[identifier]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,31 +246,10 @@ export async function POST(
),
})

// For forms, we don't stream back - we wait for completion and return success
// Consume the stream to wait for completion
const reader = stream.getReader()
let lastOutput: any = null

try {
while (true) {
const { done, value } = await reader.read()
if (done) break

// Parse SSE data if present
const text = new TextDecoder().decode(value)
const lines = text.split('\n')
for (const line of lines) {
if (line.startsWith('data: ')) {
try {
const data = JSON.parse(line.slice(6))
if (data.type === 'complete' || data.output) {
lastOutput = data.output || data
}
} catch {
// Ignore parse errors
}
}
}
while (!(await reader.read()).done) {
/* drain to let the workflow run to completion */
}
} finally {
reader.releaseLock()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export async function POST(
})
}

if (isApiCaller && executionMode !== 'async') {
if (isApiCaller && executionMode === 'sync') {
const result = await PauseResumeManager.startResumeExecution(resumeArgs)

return NextResponse.json({
Expand Down
Loading