Skip to main content

Lesson 2: Custom Prompts

Building on your success from Lesson 1, you'll now learn the art and science of prompt engineering to create more intelligent, context-aware AI workflows. We'll enhance your Personal Goal Tracker with sophisticated prompting techniques.

Learning Objectives​

By the end of this lesson, you will:

  • ✅ Master prompt engineering fundamentals
  • ✅ Use dynamic prompt templates with variables
  • ✅ Configure AI behavior through context parameters
  • ✅ Implement domain-specific AI assistants
  • ✅ Optimize AI responses for different use cases

Overview: What We're Building​

We'll enhance the Personal Goal Tracker with:

  1. Smart Goal Detection: AI identifies goal categories automatically
  2. Specialized Coaches: Different AI personalities for different goal types
  3. Dynamic Prompting: Prompts that adapt based on goal content
  4. Advanced Configuration: Fine-tuned AI parameters for optimal results

Step 1: Download the Enhanced Workflow​

Let's get the upgraded workflow file that demonstrates advanced prompting techniques.

Step 2: Understanding Advanced Prompting​

Prompt Engineering Fundamentals​

What Makes a Great Prompt?

  1. Clear Role Definition: "You are a fitness coach..."
  2. Specific Instructions: Exact format and content requirements
  3. Context Awareness: Using input variables like {goal}
  4. Output Structure: Defined sections and formatting
  5. Personality: Tone and style that matches the use case

Dynamic Prompt Templates​

Notice how our prompts use variables to create dynamic content:

Your Goal: {goal}
Category: {goal_category}

This allows one prompt template to work with any user input while maintaining personalization.

Temperature Settings Explained​

TemperatureUse CaseExample
0.1Classification, precise answersGoal categorization
0.3Professional advice, structured responsesCareer coaching
0.4Creative but focused contentHealth coaching
0.5Balanced creativity and structureGeneral life coaching
0.7+Creative writing, brainstorming(Not used in this lesson)

Step 3: Advanced Agent Configuration​

Goal Classification Agent​

SmartGoals,ClassifyGoal,AI classifies the goal category,llm,RouteToCoach,ErrorHandler,goal,goal_category,"You are a goal classification expert...","{""provider"": ""anthropic"", ""model"": ""claude-sonnet-4-6"", ""temperature"": 0.1}"

Why Temperature 0.1?

  • Classification needs consistency
  • We want the same goal to always get the same category
  • Low temperature reduces randomness

Specialized Coach Agents​

Each coach has a unique personality and approach:

Health Coach:

  • Emoji: 🏃‍♀️ (energetic fitness vibe)
  • Temperature: 0.4 (creative but structured)
  • Focus: Evidence-based fitness strategies

Career Coach:

  • Emoji: 💼 (professional)
  • Temperature: 0.3 (structured professional advice)
  • Focus: Strategic career advancement

Learning Coach:

  • Emoji: 📚 (educational)
  • Temperature: 0.3 (methodical learning approaches)
  • Focus: Learning optimization techniques

General Coach:

  • Emoji: 🌟 (inspirational)
  • Temperature: 0.5 (balanced and holistic)
  • Focus: Life integration and systems thinking

Step 4: The Orchestrator Agent​

Intelligent Routing​

SmartGoals,RouteToCoach,Route to specialized coach based on category,orchestrator,HealthCoach,ErrorHandler,"goal,goal_category",coach_selection,,"{""nodes"": ""HealthCoach|CareerCoach|LearningCoach|GeneralCoach""}"

The OrchestratorAgent automatically routes to the appropriate coach based on the goal category:

  • HEALTH → HealthCoach
  • CAREER → CareerCoach
  • LEARNING → LearningCoach
  • All others → GeneralCoach

Step 5: Running the Enhanced Workflow​

Setup and Execution​

# Make sure you have your API key set
export ANTHROPIC_API_KEY="your-api-key-here"

# Save lesson2.csv to your project directory
# Run the enhanced workflow
agentmap run lesson2.csv

Example Interaction​

What goal would you like to achieve? Please describe it in detail with any relevant context about your situation:
> I want to lose 20 pounds in 6 months and build a sustainable exercise routine because I've been feeling low energy lately

[AI classifies as HEALTH goal...]
[Routes to HealthCoach...]
[Generates detailed fitness plan...]

🎉 Goal Analysis Complete!

Your HEALTH goal has been analyzed by our specialized coach and saved to your personal database.

✅ What's Been Created:
- Detailed action plan tailored to your goal type
- Specific strategies and techniques
- Progress tracking framework
- Obstacle anticipation and solutions

📁 Find Your Analysis: data/smart_goals_analysis.csv

Step 6: Examining the Enhanced Output​

Check your detailed analysis:

cat data/smart_goals_analysis.csv

You'll see structured output with:

  • Goal classification
  • Specialized coaching advice
  • Action plans with timelines
  • Specific strategies and techniques
  • Progress tracking methods

Step 7: Prompt Engineering Exercises​

Exercise 1: Create a Finance Coach​

Add a specialized finance coach by modifying the workflow:

SmartGoals,FinanceCoach,Specialized financial planning coaching,llm,SaveAnalysis,ErrorHandler,"goal,goal_category",detailed_analysis,"💰 **FINANCIAL PLANNING ADVISOR**

I'm your personal finance strategist! Let's turn your financial goal into a concrete action plan.

**Your Goal**: {goal}

## 💡 Financial Strategy Analysis
**Goal Type**: [Investment, saving, debt reduction, etc.]
**Risk Assessment**: [Conservative, moderate, aggressive approach]

## 📊 Financial Action Plan
**Month 1**: [Immediate financial steps]
**Months 2-3**: [Building momentum]
**Months 4-6**: [Milestone achievements]
**Long-term**: [Sustained financial health]

## 🎯 Specific Recommendations
- [Concrete financial actions]
- [Tools and apps to use]
- [Tracking and budgeting methods]

## ⚠️ Risk Management
**Potential Pitfalls**: [Common financial mistakes]
**Protection Strategies**: [How to avoid setbacks]

## 📈 Success Metrics
[Specific financial KPIs to track]

Remember: Building wealth is about consistent, smart decisions over time! 💪","{""provider"": ""anthropic"", ""model"": ""claude-sonnet-4-6"", ""temperature"": 0.3}"

Exercise 2: Modify Classification Logic​

Update the ClassifyGoal prompt to include FINANCIAL as a category:

You are a goal classification expert. Analyze this goal and classify it into ONE category: HEALTH (fitness nutrition mental-health), CAREER (professional job business), LEARNING (education skills knowledge), FINANCIAL (money investment savings budgeting), PERSONAL (relationships hobbies lifestyle), or OTHER.

Exercise 3: Experiment with Temperature​

Try different temperature settings for the coaches:

More Creative Health Coach (temperature 0.6):

{"provider": "anthropic", "model": "claude-sonnet-4-6", "temperature": 0.6}

More Precise Career Coach (temperature 0.2):

{"provider": "anthropic", "model": "claude-sonnet-4-6", "temperature": 0.2}

Step 8: Advanced Prompting Techniques​

1. Structured Output Formatting​

Use markdown and emojis to create visually appealing responses:

## 🎯 Goal Analysis
**Why this matters**: [explanation]

## 📋 Action Plan
**Week 1**: [specific tasks]

2. Role-Based Prompting​

Define clear expertise areas:

You are a certified fitness trainer with 10 years of experience specializing in sustainable weight loss...

3. Context-Aware Prompting​

Use multiple input variables:

Your Goal: {goal}
Category: {goal_category}
Current Situation: {context}

4. Output Constraints​

Specify format requirements:

Respond with exactly 3 bullet points, each starting with an action verb...

Key Concepts Learned​

1. Prompt Engineering Principles​

  • Clear role definition creates better AI responses
  • Structured output formatting improves readability
  • Variable injection enables dynamic personalization
  • Temperature controls creativity vs. consistency

2. Specialized AI Assistants​

  • Different domains need different approaches
  • Personality and tone matter for user experience
  • Context-specific knowledge improves relevance
  • Template reusability across similar use cases

3. Intelligent Workflow Routing​

  • OrchestratorAgent enables smart routing decisions
  • Classification enables specialized processing
  • Multi-path workflows handle diverse inputs
  • Error handling maintains workflow robustness

4. Configuration Optimization​

  • Temperature settings affect response style
  • Model selection impacts capability and cost
  • Provider choice depends on specific needs
  • Context parameters fine-tune behavior

Troubleshooting​

Issue: Classification is inconsistent​

Solution: Lower the temperature for the classification agent:

{"temperature": 0.1}

Issue: Coach responses are too generic​

Solution: Add more specific role definition and examples in prompts.

Issue: Routing doesn't work correctly​

Solution: Check that node names in orchestrator context match actual node names.

Best Practices Learned​

1. Prompt Design​

  • Start with role definition
  • Provide specific instructions
  • Use structured output formatting
  • Include examples when helpful

2. Temperature Selection​

  • Use low temperature (0.1-0.2) for classification
  • Use medium temperature (0.3-0.4) for structured advice
  • Use higher temperature (0.5+) for creative content

3. Workflow Design​

  • Separate classification from processing
  • Use specialized agents for different domains
  • Implement error handling at each step
  • Provide clear user feedback

Next Steps​

Outstanding work! You've mastered:

  • ✅ Advanced prompt engineering techniques
  • ✅ Dynamic template creation with variables
  • ✅ AI behavior configuration through context
  • ✅ Intelligent workflow routing with orchestration
  • ✅ Domain-specific AI assistant creation

In Lesson 3, we'll take the next major step: creating your own custom agent by extending the BaseAgent class and implementing custom business logic.

Continue to Lesson 3: Custom Agent Development →


Additional Resources​


💡 Pro Tip: Save examples of effective prompts you create - they become valuable templates for future workflows! Also, experiment with different personalities and tones to see how they affect user engagement.