> Discover all available pages from the documentation index: https://mastra.zisheng.pro/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 和添加 metadata 的 Tracing 上下文。使用 Mastra 的 tracing 系统时会自动注入。 **tracingContext.currentSpan** (`Span`): 用于创建子 span 和添加 metadata 的当前 span。可在执行期间用它创建自定义子 span 或更新 span 属性。 **tracingOptions** (`TracingOptions`): Tracing 配置选项。 **tracingOptions.metadata** (`Record`): 要添加到根 trace span 的 metadata。可用于添加用户 ID、会话 ID 或 feature flag 等自定义属性。 **tracingOptions.requestContextKeys** (`string[]`): 要提取为此 trace 的 metadata 的其他 RequestContext 键。支持使用点表示法访问嵌套值(例如 '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/docs/workflows/overview) - [重新启动 workflows](https://mastra.zisheng.pro/docs/workflows/overview) - [Workflow.createRun()](https://mastra.zisheng.pro/reference/workflows/workflow-methods/create-run)