AI Agent Flow
Open-source workflow builder for AI agents.
npm install aiagentflowWhy We Built It
Every AI product we build — AIVisibility, ProfitLab, MyJob.fit — needed the same skeleton: call a model, branch on the result, call a tool, maybe loop, maybe hand off to a human. Each time we wrote it by hand, slightly differently, slightly worse.
So we extracted the pattern into a library, then built a visual editor on top, then open-sourced the whole thing. If we need it in every product, someone else does too.
What It Does
AI Agent Flow lets you define agent workflows as composable nodes:
- Model nodes — LLM calls with any provider
- Tool nodes — functions the agent can invoke
- Branch nodes — conditional routing on structured output
- Loop nodes — retry and refinement cycles
- Human nodes — pause for approval or input
Workflows are defined in code (type-safe) or visually (the builder exports the same definition). Run them locally, in a serverless function, or anywhere JavaScript runs.
Installation
npm install aiagentflow
Usage
import { workflow, model, branch } from 'aiagentflow';
const support = workflow()
.then(model('classify-intent'))
.then(branch({
billing: model('resolve-billing'),
bug: model('file-bug-report'),
}));
const result = await support.run({ message: 'My card was charged twice' });
Contributing
Issues and pull requests welcome at the repository. The project follows conventional commits and requires types and tests for new nodes.
Current State
Actively maintained, MIT-licensed, and used in our own AI products — the best motivation to keep it good.