Tutorial: AI Task Manager
In this tutorial, you’ll build a task manager where an AI assistant helps users break down projects into tasks, prioritize work, and track progress. Along the way, you’ll learn:- Multiple systems in one project
- Human-in-the-loop approval flows
- Streaming with artifacts
- Connecting from a React frontend
Project that holds tasks and state, and a Planner agent that helps decompose work.
Setup
If you haven’t already, create a new project:.dev.vars:
Part 1: The Project System
A Project holds a list of tasks and provides methods to manipulate them. Createidyllic/project.ts:
System. No AI yet — just state and methods. Start the dev server:
Part 2: The Planner Agent
Now add AI. Createidyllic/planner.ts — an agent that helps break down goals into tasks:
Part 3: Human-in-the-Loop
Now combine them. Add a method to Project that uses the Planner but asks for human approval before adding tasks:this.confirm() call pauses execution. The runtime hibernates the Durable Object, persists state, and waits. When the user responds, execution resumes exactly where it left off.
Test it:
Part 4: React Frontend
Now build a UI. The@idyllic/react package provides hooks that handle WebSocket connections and state sync.
Create app/page.tsx:
http://localhost:3000. Create a project, type a goal, and watch:
- The AI generates task suggestions (artifacts stream)
- Confirmation dialogs appear one by one
- Approved tasks appear in the list
- History shows what happened
useSystem hook handles everything: WebSocket connection, state sync, history updates, confirmation handling. The state object always reflects server state.
Part 5: Multiple Users
Because state lives on the server, multiple clients can connect to the same project. Open another browser tab with the same project ID — changes sync instantly. This happens automatically. The runtime broadcasts history updates to all connected clients. No additional code needed.What You Built
In 30 minutes, you built:- Two systems — Project for data, Planner for AI
- Persistent state — Tasks survive restarts, reconnections, deployments
- Human-in-the-loop — AI suggests, humans approve
- Streaming artifacts — See AI thinking in real-time
- Real-time sync — Multiple clients see the same state
Next Steps
Deploy to Production
Ship your task manager globally
Add File Uploads
Attach documents to tasks
Custom Renderers
Build specialized artifact displays
Background Jobs
Run scheduled task reminders
FAQ
Why separate Project and Planner into different systems?
Separation of concerns. Project holds state and business logic. Planner provides AI capabilities. You could put everything in one class, but separating them makes each easier to test, evolve, and reuse.What happens if the user closes the browser mid-confirmation?
The Durable Object hibernates with execution paused atthis.confirm(). When they reconnect and load the project, the pending confirmation appears. They respond, execution resumes, and the workflow completes.
Can I use a different LLM provider?
Yes. Swapopenai("gpt-4o") for anthropic("claude-3-opus") or any provider the AI SDK supports. The system code stays the same.