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"},
],
})¿Qué se comprueba antes de guardarlo?
- Cada paso es único y bien formado; hay como máximo 30.
- Cada tipo de paso existe, y su propia configuración requerida está presente.
- Cada
{{steps.…}}referencia nombra un paso que existe y es aguas arriba. - El gráfico tiene exactamente un borde del gatillo, sin ciclo, y sin paso inalcanzable.
- Una condición tiene un
truey afalseborde; un interruptor tiene uno por caso másdefault; una fusión tiene al menos dos entradas. - Cualquier cosa que actúe fuera de la cuenta tiene un
humanpaso río arriba. - Un
agent.runnombres sólo herramientas que existen.
{{steps.draft.output.text• En un paso que se ejecuta antes de que el draft se atrape aquí en lugar de producir una cadena vacía en el tiempo de ejecución. La validación es estricta porque un flujo de trabajo falla donde nadie está mirando.
Las herramientas de agente se serializan para usted
{ 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"],
}}Escrito como objeto se convierte en el array de la plataforma almacena. Escrito como array ya, se envía tal cual es — y un nombre de herramienta desconocido se rechaza con la lista de los que existen.
Errores
Todo lo de arriba vuelve como invalid_workflow (400), con un mensaje que nombra el paso y el problema. Hay un código porque hay una respuesta: fijar la definición.