> Discover all available pages from the documentation index: https://mastra.zisheng.pro/zh-TW/llms.txt # Run.restart() `.restart()` 方法會重新啟動與伺服器失去連線的作用中 Workflow run,讓你從失去連線的時間點(最後一個作用中步驟)繼續執行。 ## 使用範例 ```typescript const run = await workflow.createRun() const result = await run.start({ inputData: { value: 'initial data' } }) const restartedResult = await run.restart() ``` ## 參數 **requestContext** (`RequestContext`): 繼續執行時要使用的 Request Context 資料 **tracingContext** (`TracingContext`): 用來建立子 span 及新增中繼資料的 Tracing context。使用 Mastra 的 tracing 系統時會自動注入。 **tracingContext.currentSpan** (`Span`): 用來建立子 span 及新增中繼資料的目前 span。執行期間可用它建立自訂子 span 或更新 span 屬性。 **tracingOptions** (`TracingOptions`): Tracing 設定選項。 **tracingOptions.metadata** (`Record`): 要新增至根 Trace span 的中繼資料。適合新增使用者 ID、工作階段 ID 或功能旗標等自訂屬性。 **tracingOptions.requestContextKeys** (`string[]`): 要擷取為此 Trace 中繼資料的其他 RequestContext key。支援以點號標記法表示巢狀值(例如 'user.id')。 **tracingOptions.traceId** (`string`): 此執行要使用的 Trace ID(1 至 32 個十六進位字元)。若有提供,此 Trace 會成為指定 Trace 的一部分。 **tracingOptions.parentSpanId** (`string`): 此執行要使用的父 span ID(1 至 16 個十六進位字元)。若有提供,根 span 會建立為此 span 的子 span。 **tracingOptions.tags** (`string[]`): 要套用至此 Trace 的標籤。這些字串標籤可用來分類及篩選 Trace。 ## 回傳值 **result** (`Promise>`): 會解析為 Workflow 執行結果的 promise;結果包含步驟輸出與狀態 **traceId** (`string`): 啟用 Tracing 時,與此執行相關聯的 Trace ID。可用來關聯記錄及偵錯執行流程。 **spanId** (`string`): 啟用 Tracing 時,與此執行相關聯的根 span ID。可用於 span 層級的查找與關聯。 ## 相關內容 - [Workflows 概觀](https://mastra.zisheng.pro/zh-TW/docs/workflows/overview) - [重新啟動 Workflow](https://mastra.zisheng.pro/zh-TW/docs/workflows/overview) - [Workflow.createRun()](https://mastra.zisheng.pro/zh-TW/reference/workflows/workflow-methods/create-run)