AI Autonomy

Create autonomous agents with an AI planner that breaks goals into tasks and coordinates execution through workflows.

Overview

AI Autonomy takes Mozaik to the next level. Instead of manually defining workflows, you provide a high-level goal and let an AI planner figure out the best approach. The planner decomposes goals into tasks, assigns appropriate models, and creates optimized workflows.

Using the Planner

The Planner class generates workflows from natural language goals:

planner-basic.ts
1import { Planner } from '@mozaik-ai/core'
2
3const planner = new Planner({
4 model: 'gpt-5',
5 goal: 'Implement user authentication with email and password'
6})
7
8// Planner analyzes the goal and generates a workflow
9const workflow = await planner.plan()
10
11// Execute the generated workflow
12await workflow.execute()

How It Works

When you call planner.plan(), the AI:

  1. 1Analyzes your goal to understand requirements
  2. 2Breaks it down into discrete, actionable tasks
  3. 3Assigns the best model for each task based on complexity
  4. 4Optimizes execution order (parallel where possible)
  5. 5Returns a ready-to-execute Workflow

Example Generated Workflow

For the goal "Implement login functionality", the planner might generate:

generated-workflow.ts
1// AI-generated workflow structure:
2Workflow("sequential", [
3 Task("Design login form UI", "gpt-5"),
4 Task("Implement authentication logic", "claude-sonnet-4.5"),
5 Workflow("parallel", [
6 Task("Add input validation", "gpt-5-mini"),
7 Task("Style login form", "gpt-5-nano")
8 ]),
9 Task("Write unit tests", "gpt-5")
10])

Note

The planner intelligently parallelizes independent tasks (like validation and styling) while keeping dependent tasks sequential.

Autonomy Slider

Control how much freedom the AI planner has. Combine manual workflows with AI planning for the perfect balance:

Full ManualFull Autonomous

Slide between defining every task yourself and letting AI handle everything

autonomy-hybrid.ts
1import { Planner, Workflow, Task } from '@mozaik-ai/core'
2
3// Hybrid approach: define structure, let AI fill in details
4const workflow = new Workflow("sequential", [
5 // Manual: you know this needs to happen first
6 new Task("Load user requirements from database", "gpt-5-mini"),
7
8 // Autonomous: let AI figure out the implementation details
9 await new Planner({
10 model: 'gpt-5',
11 goal: 'Implement the main feature based on requirements'
12 }).plan(),
13
14 // Manual: you want specific control over deployment
15 new Task("Deploy to staging environment", "gpt-5-mini")
16])

Best Practices

  • Be specific: Clear goals produce better workflows. "Add login" is vague; "Add email/password login with JWT tokens" is specific.
  • Start supervised: Review generated workflows before executing them in production.
  • Use constraints: Provide context about your stack, coding standards, or requirements.

Next Steps