A lightweight, functional, and composable framework for building AI agents that work together to solve complex tasks.
Built with TypeScript and designed to be serverless-ready.
It is very easy to get started. All you have to do is to create a file with your agents and workflow, then run it.
Use our creator tool to quickly create a new AI agent project.
$ npx create-fabrice-ai
You can choose from a few templates. You can see a full list of them here.
$ npm install fabrice-ai
Here is a simple example of a workflow that researches and plans a trip to Wrocław, Poland:
import { agent } from 'fabrice-ai/agent'
import { teamwork } from 'fabrice-ai/teamwork'
import { solution, workflow } from 'fabrice-ai/workflow'
import { lookupWikipedia } from './tools/wikipedia.js'
const activityPlanner = agent({
description: `You are skilled at creating personalized itineraries...`,
})
const landmarkScout = agent({
description: `You research interesting landmarks...`,
tools: { lookupWikipedia },
})
const workflow = workflow({
team: { activityPlanner, landmarkScout },
description: `Plan a trip to Wrocław, Poland...`,
})
const result = await teamwork(workflow)
console.log(solution(result))
Finally, you can run the example by simply executing the file.
Using bun
$ bun your_file.ts
Using node
$ node --import=tsx your_file.ts
Most existing AI agent frameworks are either too complex, heavily object-oriented, or tightly coupled to specific infrastructure.
We wanted something different - a framework that embraces functional programming principles, remains stateless, and stays laser-focused on composability.
Now, English + Typescript is your tech stack.
The framework is designed around the idea that AI agents should be:
- Easy to create and compose
- Infrastructure-agnostic
- Stateless by default
- Minimal in dependencies
- Focused on team collaboration
Agents are specialized workers with specific roles and capabilities. Each agent has:
- A defined role
- A clear description of capabilities
- Optional tools they can use
- A configured language model provider
Tools extend agent capabilities by providing concrete actions they can perform. Tools are pure functions with:
- A description
- Typed parameters (using Zod)
- An execute function
Workflows define how agents collaborate to achieve a goal. They specify:
- Team members
- Task description
- Expected output
- Optional configuration
The framework provides two main ways to orchestrate agent collaboration:
The teamwork
function handles complete workflow execution from start to finish, managing the entire process automatically. It's perfect for simple use cases where you want to get results in a single call.
import { teamwork } from 'fabrice'
const state = await teamwork(workflow)
We provide a server-side version of teamwork
that is perfectly suited for long-running workflows that require external tool execution or manual intervention. It will not wait for the tool to be executed, but will return the state of the workflow.
You can then handle tool calls on your own, and call teamwork
again when ready.
import { teamwork } from 'fabrice-ai/teamwork'
// Setting third argumenet to `false` will stop waiting for the tool to be executed.
const nextState = await teamwork(workflow, prevState, false)
This pattern is especially useful for:
- Running workflows in serverless environments
- Handling long-running tool executions
- Implementing manual review steps
- Building interactive workflows
- Managing rate limits and quotas
The iterate
function provides a stateless, step-by-step execution model. Each call returns the new state without maintaining any internal state.
// Initialize, or get from storage
const initialState = workflowState(workflow)
// Iterate over the workflow
const newState = await iterate(workflow, initialState)
// Check status
console.log(newState.status)
This approach offers several benefits:
- Pausable Execution: Stop and resume workflow execution at any point
- State Persistence: Save the state between iterations to your preferred storage
- Progress Monitoring: Inspect the workflow state after each iteration
- Error Recovery: Handle failures gracefully by retrying from the last successful state
- Custom Control Flow: Implement your own execution patterns and recovery strategies
This functional approach makes the framework particularly well-suited for building long-running workflows that are distributed across multiple servers in the cloud.
Mike 💻 |
Piotr Karwatka 💻 |
Fabrice is an open source project and will always remain free to use. If you think it's cool, please star it 🌟. Callstack is a group of React and React Native geeks, contact us at [email protected] if you need any help with these or just want to say hi!
Like the project? ⚛️ Join the team who does amazing stuff for clients and drives React Native Open Source! 🔥