Your First Multi-Agent Workflow
Now that you've run a simple workflow, let's build something practical: a document analysis system where multiple AI agents collaborate to analyze and summarize documents.
⚡ Progress Tracker
Total Time: ~15 minutes
- Step 1: Understand the workflow design (2 min)
- Step 2: Create the workflow CSV (5 min)
- Step 3: Prepare sample data (3 min)
- Step 4: Run and test (3 min)
- Step 5: Understand what happened (2 min)
Step 1: Workflow Design
We'll build a Personal Goal Analyzer that:
- Collects a personal goal from the user
- Analyzes it using AI to provide insights and action steps
- Saves the analysis to a CSV file for tracking
- Thanks the user and shows next steps
This demonstrates:
- ✅ User interaction (input agent)
- ✅ AI processing (LLM agent)
- ✅ Data persistence (CSV writer agent)
- ✅ Error handling (error handler)
- ✅ Data flow between agents
Expected time: 2 minutes
Step 2: Create the Workflow
Create a file called personal_goals.csv:
graph_name,node_name,description,agent_type,next_node,error_node,input_fields,output_field,prompt,context
PersonalGoals,GetGoal,Collect user's personal goal,input,AnalyzeGoal,ErrorHandler,,goal,What personal goal would you like to work on this year? Please be specific:,
PersonalGoals,AnalyzeGoal,AI analysis of the goal,llm,SaveGoal,ErrorHandler,goal,analysis,"You are a personal development coach. Analyze this goal and provide: 1) Why this goal is valuable 2) Three specific action steps 3) One potential challenge and how to overcome it. Goal: {goal}","{""provider"": ""anthropic"", ""model"": ""claude-sonnet-4-6"", ""temperature"": 0.3}"
PersonalGoals,SaveGoal,Save goal and analysis to CSV,csv_writer,ThankUser,ErrorHandler,"goal,analysis",save_result,personal_goals.csv,"{""format"": ""records"", ""mode"": ""append""}"
PersonalGoals,ThankUser,Thank user and show summary,echo,End,,save_result,final_message,Thank you! Your goal and AI analysis have been saved. You can view your goals database at personal_goals.csv,
PersonalGoals,ErrorHandler,Handle any errors,echo,End,,error,error_message,Sorry there was an error: {error},
PersonalGoals,End,Workflow complete,echo,,,final_message,completion,Workflow completed successfully!,
🔍 Understanding the Workflow
Let's break down what each agent does:
| Agent | Type | Purpose | Input | Output |
|---|---|---|---|---|
GetGoal | input | Prompts user for their goal | - | goal |
AnalyzeGoal | llm | AI analyzes the goal | goal | analysis |
SaveGoal | csv_writer | Saves to CSV file | goal, analysis | save_result |
ThankUser | echo | Shows completion message | save_result | final_message |
ErrorHandler | echo | Handles any errors | error | error_message |
End | echo | Workflow completion | final_message | completion |
Data Flow: goal → analysis → save_result → final_message → completion
Expected time: 5 minutes
Step 3: Prepare Sample Data
No preparation needed! The CSV writer will automatically create the personal_goals.csv file when it runs.
Expected time: 3 minutes
Step 4: Run the Workflow
agentmap run --csv personal_goals.csv --graph PersonalGoals
Sample interaction:
What personal goal would you like to work on this year? Please be specific:
> Learn to play piano and perform one song for my family
[AI processes the goal...]
Thank you! Your goal and AI analysis have been saved.
You can view your goals database at data/personal_goals.csv
Workflow completed successfully!
Expected time: 3 minutes