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:
1import { Planner } from '@mozaik-ai/core'23const planner = new Planner({4 model: 'gpt-5',5 goal: 'Implement user authentication with email and password'6})78// Planner analyzes the goal and generates a workflow9const workflow = await planner.plan()1011// Execute the generated workflow12await workflow.execute()
How It Works
When you call planner.plan(), the AI:
- 1Analyzes your goal to understand requirements
- 2Breaks it down into discrete, actionable tasks
- 3Assigns the best model for each task based on complexity
- 4Optimizes execution order (parallel where possible)
- 5Returns a ready-to-execute Workflow
Example Generated Workflow
For the goal "Implement login functionality", the planner might generate:
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
Autonomy Slider
Control how much freedom the AI planner has. Combine manual workflows with AI planning for the perfect balance:
Slide between defining every task yourself and letting AI handle everything
1import { Planner, Workflow, Task } from '@mozaik-ai/core'23// Hybrid approach: define structure, let AI fill in details4const workflow = new Workflow("sequential", [5 // Manual: you know this needs to happen first6 new Task("Load user requirements from database", "gpt-5-mini"),78 // Autonomous: let AI figure out the implementation details9 await new Planner({10 model: 'gpt-5',11 goal: 'Implement the main feature based on requirements'12 }).plan(),1314 // Manual: you want specific control over deployment15 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.