Skip to main content

Habits Adapter

The Habits adapter helps users build and maintain habits with streak tracking and recovery support.

Installation

from sxth_mind import Mind
from examples.habits import HabitCoachAdapter

mind = Mind(adapter=HabitCoachAdapter())

Identity Types

TypeDescriptionCoaching Style
all_or_nothingStruggles with imperfectionEmphasize progress over perfection
slow_builderGradual, steady progressPatience, small wins
accountability_seekerNeeds external motivationCheck-ins, reminders
self_motivatedInternal driveMinimize interruptions

Journey Stages

starting → struggling → building → consistent
              ↓                        ↓
         recovering ←──────────────────┘
StageToneFocus
startingEncouragingSet expectations, first wins
strugglingSupportiveIdentify blockers, reduce friction
buildingCelebratoryReinforce progress, momentum
consistentMinimalStay out of the way
recoveringCompassionateNo judgment, restart gently

Pattern Detection

The Habits adapter tracks:
  • Streak length — Current consecutive days
  • Best streak — Longest streak achieved
  • Common blockers — What causes missed days
  • Time patterns — When they usually complete
  • Recovery rate — How quickly they restart after breaks

Nudge Templates

NudgePriorityTrigger
streak_risk7Approaching usual completion time
streak_celebration5Milestone reached (7, 30, 100 days)
recovery_support8Missed 2+ days
pattern_insight4Noticed success/failure pattern

Example Usage

import asyncio
from sxth_mind import Mind
from examples.habits import HabitCoachAdapter

async def main():
    mind = Mind(adapter=HabitCoachAdapter())

    # Daily check-ins
    await mind.chat("user_1", "Did my morning workout!", project_id="habit_exercise")
    await mind.chat("user_1", "Completed day 5!", project_id="habit_exercise")
    await mind.chat("user_1", "Missed yesterday, feeling bad about it", project_id="habit_exercise")

    # The adapter detects recovery stage and responds compassionately
    state = await mind.get_state("user_1", project_id="habit_exercise")
    print(f"Stage: {state['project_mind']['journey_stage']}")

asyncio.run(main())

Multi-Habit Support

Track multiple habits per user:
# Different habits
await mind.chat("user_1", "Morning run done", project_id="habit_running")
await mind.chat("user_1", "Read for 30 mins", project_id="habit_reading")
await mind.chat("user_1", "Meditated today", project_id="habit_meditation")

# Each habit has its own streak and stage

Context Data

The adapter stores in project_mind.context_data:
{
    "current_streak": 12,
    "best_streak": 30,
    "total_completions": 45,
    "missed_days": 3,
    "last_completion": "2024-01-15",
}