From 13c772838beb6073a6c4da7c2054b93615fd92c8 Mon Sep 17 00:00:00 2001 From: Ken'ichiro Oyama Date: Thu, 2 Jul 2026 09:37:17 +0900 Subject: [PATCH 1/4] docs(workflow): document tailor.workflow.resumeWorkflow The SDK now exposes `tailor.workflow.resumeWorkflow(executionId)` so user code can resume a failed or pending-retry execution directly (tailor-platform/sdk#1608). The workflow guides only covered the `tailor-sdk workflow resume` CLI command, leaving self-healing flows (functions, executors, pipeline resolvers) with no in-code path to point readers at. Add a "Resuming from Code" subsection to the monitoring guide covering the API, its return value, and the error it rejects with. --- docs/guides/workflow/monitoring-executions.md | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/docs/guides/workflow/monitoring-executions.md b/docs/guides/workflow/monitoring-executions.md index 0ada154..496bf67 100644 --- a/docs/guides/workflow/monitoring-executions.md +++ b/docs/guides/workflow/monitoring-executions.md @@ -204,6 +204,36 @@ processData → Skipped (cached) saveToDb → Executed again ``` +### Resuming from Code + +You can also resume a failed execution from your own code — for example, from a workflow job function, an executor, or a pipeline resolver — using `tailor.workflow.resumeWorkflow()`. This lets you build self-healing flows that recover from transient failures automatically, without an operator running `tailor-sdk workflow resume` or using the Tailor Console. + +**Example:** + +```javascript +export async function main(args) { + try { + const resumedId = await tailor.workflow.resumeWorkflow(args.failedExecutionId); + console.log("Resumed execution:", resumedId); + return { success: true, resumedExecutionId: resumedId }; + } catch (e) { + // e.message: "resumeWorkflow failed: ..." + console.error(e.message); + return { success: false }; + } +} +``` + +**API Reference:** + +- **First argument**: Execution ID of a failed or pending-retry execution (string) + +**Return value:** + +- Execution ID of the resumed execution (string) + +`resumeWorkflow()` resumes from the point of failure with the same cached-result behavior as the `resume` command: successful job functions are skipped and their cached results are reused. It rejects with an error (message prefixed with `resumeWorkflow failed:`) when the execution cannot be resumed, so wrap the call in `try`/`catch` when you need to handle that case. + ### When to Use Resume Resume is useful when: From dd6ba23b500d4b90065ac421392562985602bb32 Mon Sep 17 00:00:00 2001 From: Ken'ichiro Oyama Date: Thu, 2 Jul 2026 10:15:37 +0900 Subject: [PATCH 2/4] docs(workflow): return results directly in workflow samples Review the workflow guide samples for the same result-object smell fixed in the IdP guide. The `tailor.workflow.*` runtime calls reject on failure, so wrapping their results in `{ success: true }` (and, in the resumeWorkflow example, catching to return `{ success: false }`) made the samples read as if they presuppose try/catch-based error handling. Drop the redundant `success` field from the triggerWorkflow, multi-step, and error-handling samples, and rewrite the resumeWorkflow example to let the error propagate. Keep the one try/catch that re-throws a wrapped message, since controlling the error message is the case where catching is warranted. --- docs/guides/workflow/creating-workflows.md | 3 +-- docs/guides/workflow/monitoring-executions.md | 16 +++++----------- docs/guides/workflow/triggering-workflow.md | 1 - 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/docs/guides/workflow/creating-workflows.md b/docs/guides/workflow/creating-workflows.md index b1a01c1..ab1a3db 100644 --- a/docs/guides/workflow/creating-workflows.md +++ b/docs/guides/workflow/creating-workflows.md @@ -189,7 +189,6 @@ export function main(args) { }); return { - success: true, orderId: validated.id, paymentId: payment.id, }; @@ -239,7 +238,7 @@ export function main(args) { try { // Risky operation const result = performOperation(); - return { success: true, result }; + return { result }; } catch (error) { throw new Error(`Operation failed: ${error.message}`); } diff --git a/docs/guides/workflow/monitoring-executions.md b/docs/guides/workflow/monitoring-executions.md index 496bf67..dc8e2f5 100644 --- a/docs/guides/workflow/monitoring-executions.md +++ b/docs/guides/workflow/monitoring-executions.md @@ -206,21 +206,15 @@ saveToDb → Executed again ### Resuming from Code -You can also resume a failed execution from your own code — for example, from a workflow job function, an executor, or a pipeline resolver — using `tailor.workflow.resumeWorkflow()`. This lets you build self-healing flows that recover from transient failures automatically, without an operator running `tailor-sdk workflow resume` or using the Tailor Console. +You can also resume a failed execution from your own code (a workflow job function, an executor, or a pipeline resolver) using `tailor.workflow.resumeWorkflow()`. This lets you build self-healing flows that recover from transient failures automatically, without an operator running `tailor-sdk workflow resume` or using the Tailor Console. **Example:** ```javascript export async function main(args) { - try { - const resumedId = await tailor.workflow.resumeWorkflow(args.failedExecutionId); - console.log("Resumed execution:", resumedId); - return { success: true, resumedExecutionId: resumedId }; - } catch (e) { - // e.message: "resumeWorkflow failed: ..." - console.error(e.message); - return { success: false }; - } + const resumedId = await tailor.workflow.resumeWorkflow(args.failedExecutionId); + console.log("Resumed execution:", resumedId); + return { resumedExecutionId: resumedId }; } ``` @@ -232,7 +226,7 @@ export async function main(args) { - Execution ID of the resumed execution (string) -`resumeWorkflow()` resumes from the point of failure with the same cached-result behavior as the `resume` command: successful job functions are skipped and their cached results are reused. It rejects with an error (message prefixed with `resumeWorkflow failed:`) when the execution cannot be resumed, so wrap the call in `try`/`catch` when you need to handle that case. +`resumeWorkflow()` resumes from the point of failure with the same cached-result behavior as the `resume` command, so successful job functions are skipped and their cached results are reused. It rejects with an error whose message is prefixed with `resumeWorkflow failed:` when the execution cannot be resumed. Let that error propagate to fail the calling execution, and add a `try`/`catch` only when you need to control the error or its message. ### When to Use Resume diff --git a/docs/guides/workflow/triggering-workflow.md b/docs/guides/workflow/triggering-workflow.md index 885d8bc..cab816c 100644 --- a/docs/guides/workflow/triggering-workflow.md +++ b/docs/guides/workflow/triggering-workflow.md @@ -32,7 +32,6 @@ export async function main(args) { console.log("Notification workflow started:", executionId); return { - success: true, notificationExecutionId: executionId, }; } From 0dc5c179552a83e83f5a7a0ce2d045907b0140b8 Mon Sep 17 00:00:00 2001 From: Ken'ichiro Oyama Date: Thu, 2 Jul 2026 10:53:15 +0900 Subject: [PATCH 3/4] docs(workflow): clarify resumeWorkflow example and resume semantics Apply Copilot review feedback on the Resuming from Code section. - Use `args.executionId` in the example so it matches the `resumeWorkflow(executionId)` signature and the `executionId` term used elsewhere in the guide. - Reword the behavior paragraph to match the "restart from main, reuse cached results" mechanics described earlier in the section, rather than the looser "resumes from the point of failure" phrasing. --- docs/guides/workflow/monitoring-executions.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/guides/workflow/monitoring-executions.md b/docs/guides/workflow/monitoring-executions.md index dc8e2f5..9441fdb 100644 --- a/docs/guides/workflow/monitoring-executions.md +++ b/docs/guides/workflow/monitoring-executions.md @@ -212,7 +212,7 @@ You can also resume a failed execution from your own code (a workflow job functi ```javascript export async function main(args) { - const resumedId = await tailor.workflow.resumeWorkflow(args.failedExecutionId); + const resumedId = await tailor.workflow.resumeWorkflow(args.executionId); console.log("Resumed execution:", resumedId); return { resumedExecutionId: resumedId }; } @@ -226,7 +226,7 @@ export async function main(args) { - Execution ID of the resumed execution (string) -`resumeWorkflow()` resumes from the point of failure with the same cached-result behavior as the `resume` command, so successful job functions are skipped and their cached results are reused. It rejects with an error whose message is prefixed with `resumeWorkflow failed:` when the execution cannot be resumed. Let that error propagate to fail the calling execution, and add a `try`/`catch` only when you need to control the error or its message. +`resumeWorkflow()` behaves like the `resume` command described above. The workflow restarts from the main function and reuses the cached results of successful job functions, so only failed or not-yet-executed jobs run again. It rejects with an error whose message is prefixed with `resumeWorkflow failed:` when the execution cannot be resumed. Let that error propagate to fail the calling execution, and add a `try`/`catch` only when you need to control the error or its message. ### When to Use Resume From 6f33815c95bd682c35836576176db46c3b8417cc Mon Sep 17 00:00:00 2001 From: Ken'ichiro Oyama Date: Thu, 2 Jul 2026 13:28:03 +0900 Subject: [PATCH 4/4] docs(workflow): mention pending-retry in Resuming from Code intro Apply Copilot review feedback. The intro said "a failed execution" while the API reference below and the SDK changeset both cover "failed or pending-retry" executions, so widen the intro to match and avoid implying resumeWorkflow cannot resume pending-retry executions. --- docs/guides/workflow/monitoring-executions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guides/workflow/monitoring-executions.md b/docs/guides/workflow/monitoring-executions.md index 9441fdb..a0ad561 100644 --- a/docs/guides/workflow/monitoring-executions.md +++ b/docs/guides/workflow/monitoring-executions.md @@ -206,7 +206,7 @@ saveToDb → Executed again ### Resuming from Code -You can also resume a failed execution from your own code (a workflow job function, an executor, or a pipeline resolver) using `tailor.workflow.resumeWorkflow()`. This lets you build self-healing flows that recover from transient failures automatically, without an operator running `tailor-sdk workflow resume` or using the Tailor Console. +You can also resume a failed or pending-retry execution from your own code (a workflow job function, an executor, or a pipeline resolver) using `tailor.workflow.resumeWorkflow()`. This lets you build self-healing flows that recover from transient failures automatically, without an operator running `tailor-sdk workflow resume` or using the Tailor Console. **Example:**