
Intermediate
十二个脆弱的场景、三个工具,没人记得哪个才是发发票的那个。把它们收进一个应用,每次运行都看得见,每次失败都有名字。
确定性的步骤保持确定性。模型只用在一个决定需要判断的地方:给这个分类、选收件人、决定它能不能等。别的一切都是排程上的普通代码,那正是让整件事既便宜、又以最好的方式无聊的原因。
零件
- 表:workflows、steps、runs、run_steps、errors
- 定时触发加一个手动运行按钮
- 只用于分类和路由的模型步骤
- 带退避的重试和一张死信表
- 带每一步输入和输出的运行时间线
怎么赚钱
收一笔迁移费,再按月收钱把这些运行保持在绿灯。小公司愿意付钱,就为了不用再猜发票为什么没发出去。
搭建耗时
一个周末
一步步
- 列出你当前的场景,把每一步标成规则还是判断。大多数步骤是规则。
- 把工作流建模成行:一个工作流有有序的步骤,一次运行每执行一步就有一行。
- 把规则步骤实现成普通函数。抓取、转换、写入、发送。
- 在需要判断的地方加唯一一个模型步骤,并强制它从一个固定清单里返回一个值。
- 把每一步都裹进 try 和 catch,存下错误文本,用逐渐增长的延迟重试三次。
- 在你迁移第二个场景之前,先做出运行时间线界面。可见性就是全部意义。
- 一次迁移一个场景,并让旧的那个并行跑一周。
Build a workflow runner app where an AI step is used only for judgement. Data: workflows (name, schedule, active), steps (workflow_id, position, kind rule or model, config), runs (workflow_id, started_at, status), run_steps (run_id, step_id, input, output, duration_ms, error), dead_letters (run_id, payload, reason). Execution: run steps in order, store input and output of every step, retry a failed step three times with growing delay, then write it to dead_letters and stop the run. Model steps: must return exactly one value from a fixed list defined in the step config, with a one sentence reason stored alongside. UI: workflow list with last run status, a run timeline showing each step with duration and output, a manual run button, and a dead letter screen with a retry action. Keep secrets in server functions only and protect every table with row level security.
#automation#workflow#ops#internal