const workflow = await api.workflows.create({
name: "Triage",
trigger: { type: "manual" },
steps: [
{ id: "classify", type: "model.generate", config: { model: "gemini-3.5-flash",
prompt: "Is this urgent? {{input.text}}", schema: { type: "object", properties: { urgent: { type: "boolean" } } } } },
{ id: "check", type: "condition", config: { left: "{{steps.classify.output.urgent}}", operator: "eq", right: true } },
{ id: "approve", type: "human", config: { title: "Send the alert?" } },
{ id: "alert", type: "mail.send", config: { box: "ops@example.com", to: "team@example.com",
subject: "Urgent", text: "{{input.text}}" } },
{ id: "file", type: "storage.write", config: { storage: "…", action: "insert", collection: "tickets",
documents: [{ text: "{{input.text}}" }] } },
],
edges: [
{ from: "__trigger", to: "classify" },
{ from: "classify", to: "check" },
{ from: "check", to: "approve", branch: "true" },
{ from: "check", to: "file", branch: "false" },
{ from: "approve", to: "alert" },
],
});workflow = api.workflows.create({
"name": "Triage",
"trigger": {"type": "manual"},
"steps": [
{"id": "classify", "type": "model.generate", "config": {"model": "gemini-3.5-flash",
"prompt": "Is this urgent? {{input.text}}",
"schema": {"type": "object", "properties": {"urgent": {"type": "boolean"}}}}},
{"id": "check", "type": "condition", "config": {"left": "{{steps.classify.output.urgent}}", "operator": "eq", "right": True}},
{"id": "approve", "type": "human", "config": {"title": "Send the alert?"}},
{"id": "alert", "type": "mail.send", "config": {"box": "ops@example.com", "to": "team@example.com",
"subject": "Urgent", "text": "{{input.text}}"}},
{"id": "file", "type": "storage.write", "config": {"storage": "…", "action": "insert", "collection": "tickets",
"documents": [{"text": "{{input.text}}"}]}},
],
"edges": [
{"from": "__trigger", "to": "classify"},
{"from": "classify", "to": "check"},
{"from": "check", "to": "approve", "branch": "true"},
{"from": "check", "to": "file", "branch": "false"},
{"from": "approve", "to": "alert"},
],
})保存前检查了哪些内容
- 每一步ID都是独特的,结构完善;最多有30个。
- 每个步骤类型都存在,而且有其本身所需的配置。
- 每一
{{steps.…}}参考文献引用点指定一个现有步骤 上 上 层. - 图表有精确的边缘 与触发, 没有循环, 也没有无法到达的一步。
- 状况有
true和 a 和 afalse边缘; 开关每个大小写加一个default;合并至少有两个输入。 - 账户外的任何行为
human上上下一步 上下一步 - A 音 A
agent.run仅指定存在的工具 。
最常用的拒绝
{{steps.draft.output.text校对:Soup
代理工具已连序
{ id: "research", type: "agent.run", config: {
model: "gemini-3.5-flash",
tools: { search: api.tools.search, fetch: api.tools.fetch }, // the SDK serialises this
} }# In Python, an agent.run step names its built-in tools; the server runs them
{"id": "research", "type": "agent.run", "config": {
"model": "gemini-3.5-flash",
"tools": ["search", "fetch"],
}}以对象方式写入 。 以 数组方式写入 。 已经以数组方式写入 , 以 原样发送 , 未知的工具名则与 存在 工具 列表 拒绝 。
错误
上面的一切 都回到了 invalid_workflow (400) 带有一个标出步骤和问题的信息。有一个代码, 因为有一个答案: 固定定义 。