Reference
Flue Workflow Cheatsheet
Workflow 最小骨架:有限运行、schema contract、结构化结果。
Minimal skeleton
import { defineAgent, defineWorkflow } from '@flue/runtime';
import * as v from 'valibot';
export default defineWorkflow({
agent: defineAgent(() => ({ model: 'anthropic/claude-haiku-4-5' })),
input: v.object({ text: v.string() }),
output: v.object({ summary: v.string() }),
async run({ harness, input }) {
const session = await harness.session();
const response = await session.prompt(input.text);
return { summary: response.text };
},
});Field map
| 字段 | 作用 | 记忆句 |
|---|---|---|
agent | 本 workflow 使用的 agent harness。 | 谁来完成这张工单? |
input | 调用参数 schema。 | 调用者必须交什么材料? |
output | 返回结果 schema。 | 验收时必须交什么成果? |
run | 有限运行逻辑。 | 怎么从材料变成果? |
CLI invocation
npx flue run summarize --input '{"text":"Flue workflows complete finite operations."}'官方文档说明:flue run 会验证传入 JSON,临时启动配置的 Node.js 或 Cloudflare application,通过现有 Flue mount 调用 workflow,并打印成功结果。
When to use Workflow
- 输入边界清楚。
- 结束条件清楚。
- 输出结构清楚。
- 希望记录 run、result、event history。
- 适合后台任务、文档转换、review、CI task。