workflow-stop-design

Set Redis-based stop flags to pause per-app per-chat workflows.

29.3k|7.3k|Updated Feb 23, 2023
One-click install
npx skills add https://github.com/labring/FastGPT --skill workflow-stop-design
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: workflow-stop-design
Source: https://github.com/labring/FastGPT/tree/main/.claude/skills/core/app/workflow/stop
Command: npx skills add https://github.com/labring/FastGPT --skill workflow-stop-design

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

此技能提供一种简单、鲁棒的方式,通过 Redis 的键存在性来控制工作流暂停,从而避免正在运行的任务造成资源浪费与状态不一致。通过设置一个 TTL 为 60 秒的停止标志键,确保键不会因为异常而长期存在;工作流完成后会主动清除该键以释放资源。

Core Features & Use Cases

  • 设置停止标志: 使用 setAgentRuntimeStop 为指定 appId 与 chatId 设置停止信号,TTL 60 秒。
  • 检查是否应该暂停: 使用 shouldWorkflowStop 根据 Redis 键是否存在判断工作流是否应当暂停。
  • 清除停止信号: 使用 delAgentRuntimeStopSign 当工作流完成后清除信号,确保后续可继续运行。
  • 等待完成: 使用 waitForWorkflowComplete 轮询检查停止标志是否被删除,在超时前等待信号解除。
  • 鲁棒性设计: Redis 操作失败时降级为继续执行,避免阻塞工作流。

Quick Start

  1. 将暂停信号应用于指定 appId 与 chatId:调用 setAgentRuntimeStop({ appId: 'your_app_id', chatId: 'your_chat_id' })。
  2. 让工作流进入暂停状态:重复调用 waitForWorkflowComplete({ appId: 'your_app_id', chatId: 'your_chat_id' }),直到停止标志被删除。
  3. 工作流完成后清除停止信号:调用 delAgentRuntimeStopSign({ appId: 'your_app_id', chatId: 'your_chat_id' })。

Frequently Asked Questions about workflow-stop-design

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I pause a running workflow using Redis?

Pause workflows by setting a Redis-backed stop flag with setAgentRuntimeStop, specifying your appId and chatId. The flag persists for 60 seconds with automatic TTL cleanup, enabling immediate stop signaling across distributed workflow instances.

Can I stop a workflow without blocking execution if Redis fails?

Yes. This Skill degrades gracefully—if Redis operations fail, the workflow continues executing rather than blocking. This robust design prevents Redis errors from halting your automation pipeline.

How do I check whether a workflow should pause?

Use shouldWorkflowStop to poll Redis and determine if a stop flag exists for your workflow instance. The function checks key existence, making pause decisions immediate and deterministic.

What happens after a workflow completes—do I need to clean up the stop signal?

Yes. Call delAgentRuntimeStopSign after completion to remove the stop flag and release resources. This prevents orphaned signals and ensures subsequent workflow runs start in a clean state.

How do I wait for a workflow to finish pausing?

Use waitForWorkflowComplete with your appId and chatId to poll until the stop flag is deleted. This polling-based mechanism waits up to a timeout before returning, supporting synchronous workflow completion checks.

Does this pause mechanism work for per-app, per-chat workflow isolation?

Yes. The Skill applies stop signals to individual appId and chatId pairs, enabling isolated pause control across multiple concurrent workflows without cross-contamination.