Workflows
How you tell an agent to do a specific job a specific way.
A procedure, in plain text
A workflow is how you tell an agent to do a specific job a specific way. Write it the way you would write it for a new hire.
await ws.agents.create({
name: 'Refund checker',
instructions: '...',
workflows: [
{
name: 'Late delivery refund',
when: 'A customer reports a delivery arrived late or damaged.',
content: `
1. Pull the order with order_lookup.
2. Compare the delivered date against the promised date.
3. Nine days or more late: approve without asking.
4. Under nine days: summarise and ask me.
`.trim(),
},
],
});What when should say
It is the one sentence the agent reads to decide whether this procedure applies to what is in front of it right now. Nothing else is consulted.
when | |
|---|---|
| Good | "A customer reports a delivery arrived late or damaged." |
| Useless | "Refund handling." |
The agent does not carry every workflow at once. It holds the names and conditions, and reads
a procedure in full when one matches. An agent with thirty workflows pays for thirty
lines, not thirty procedures, and a vague when makes a good workflow
invisible.
Changing one
Without resending the other nineteen:
await agent.setWorkflow({ name, when, content });
await agent.removeWorkflow('Suspected fraud');Both publish a version, so a workflow edit is versioned like any other change.
From your repo
If your procedures live as markdown files, load them:
import { loadWorkflows } from '@cerebro-labs/agentnava-sdk';
workflows: loadWorkflows('./workflows'), // one workflow per .md fileA workflow is the same shape as a SKILL.md: a name, a condition and a body.
Point loadWorkflows at a skills directory and it reads each file's
description frontmatter into when. Nothing you already wrote needs
editing.