Skip to content

Repository files navigation

🕵🏻‍♀️Exercise & Calorie Coach Orchestrator Agent (Gemini + ADK)

AI “fitness coach” agent that recommends personalized workout plans using Google’s Agent Development Kit (ADK), Gemini, and the Calories Burned During Exercise and Activities Kaggle dataset.

Given a user’s weight, calorie goal, and time budget, the agent:

  • Selects high‑impact activities from a calories‑burned table.
  • Computes minutes and estimated calories per activity.
  • Explains the workout plan in natural language, with alternatives.

Built as part of the Kaggle Agents Intensive Capstone (2025) to practice real‑world agent tooling, orchestration, and observability.

🔍 Project Overview

Traditional calorie calculators are rigid and require manual lookup and math.

This project turns a static “calories burned” table into an interactive agent that can:

  • Understand natural‑language goals (e.g. “Burn ~400 calories in 45 minutes”).
  • Call a Python tool over a Kaggle dataset to compute options.
  • Return a coherent workout plan tailored to user constraints.

The core idea is to pair:

  • Tabular data + simple numeric logic (calories per minute).
  • Gemini + ADK tools for planning and explanation.

✨ Key Features

Personalized workout planning

  • Input: weight (lbs), target calories, max time (minutes).
  • Output: activities, minutes, and estimated calories.

Tool‑driven agent (Gemini + ADK)

  • recommend_activities_tool is exposed as an ADK function tool.
  • Gemini automatically calls the tool with structured arguments.

Data‑aware reasoning

  • Uses actual calories‑burned values from a 248‑activity dataset.
  • Handles different weights via nearest weight column (130/155/180/205 lb).

Basic observability

  • Logs every tool invocation (tool_logs) with inputs and number of plans.
  • Easy to inspect behavior across multiple user scenario.

🧠 Concepts & Stack

Agent concepts

  • Tool calling (Python function as ADK tool).
  • Simple orchestration via Agent + InMemoryRunner.
  • Lightweight observability/logging for tool usage.

Tech stack

  • Language: Python
  • Libraries: Pandas, Google ADK, Google Gemini
  • Environment: Kaggle Notebooks (Agents Intensive)
  • Data: Kaggle – Calories Burned During Exercise and Activities

📊 Dataset

Kaggle: Calories Burned During Exercise and Activities (https://www.kaggle.com/datasets/a5ee8b9d770e65ca566f73016e860e693b7d966a8fa0f24137942a380ce4fc84)

Contains per‑hour calorie expenditure at multiple body weights.

Key columns used:

  • Activity, Exercise or Sport (1 hour) – activity name
  • 130 lb, 155 lb, 180 lb, 205 lb – calories/hour by weight
  • Calories per kg – calories normalized by body weight
  • The tool converts these to calories per minute and estimates how long each activity needs to meet a target.

🏗 Architecture

High‑level components:

  1. Data layer
  • load_calorie_dataset(path): reads the CSV into a Pandas DataFrame.
  • choose_nearest_weight_column_simple(weight_lbs): maps user weight → nearest dataset weight column.
  • Derived metrics: calories_per_min, max_calories_in_time.
  1. Tool layer (Python)
  • recommend_activities_tool(user_weight_lbs, target_calories, max_time_minutes, top_n=10):
    • Uses global cal_df and activity_col.
    • Computes calories per minute for each activity.
    • Filters activities that can realistically reach the goal in the user’s time.
    • Returns top‑N structured plans with:
      • activity
      • minutes
      • calories
      • calories_per_min
    • Appends each call to tool_logs for observability.
  1. Agent layer (Gemini + ADK)
  • coach_agent = Agent(...):
    • Model: gemini-2.5-flash-lite.
    • Tools: [recommend_activities_tool].
    • Instruction: act as a fitness coach, call the tool with reasonable arguments, and explain the plan in simple language (including alternatives and basic safety notes).
  1. Runner & trace
  • InMemoryRunner(agent=coach_agent).
  • run_debug(...):
    • Shows function_call → recommend_activities_tool.
    • Shows function_response containing the structured plans.
    • Shows final natural‑language explanation.

🧮 Core Logic (Tool)

Simplified pseudocode for recommend_activities_tool:


def recommend_activities_tool(user_weight_lbs, target_calories, max_time_minutes, top_n=10):
    df = cal_df.copy()
    weight_col = choose_nearest_weight_column_simple(user_weight_lbs)

    # 1. Calories per minute
    df["calories_per_min"] = df[weight_col] / 60.0
    df = df[df["calories_per_min"] > 0]

    # 2. Maximum achievable calories in given time
    df["max_calories_in_time"] = df["calories_per_min"] * max_time_minutes

    # 3. Filter activities that can reach a significant portion of the target
    df = df[df["max_calories_in_time"] >= 0.4 * target_calories]

    # 4. Take top N by calories per minute
    df = df.sort_values("calories_per_min", ascending=False).head(top_n)

    # 5. Compute minutes needed and estimated calories
    plans = []
    for _, row in df.iterrows():
        minutes_needed = min(max_time_minutes, target_calories / row["calories_per_min"])
        calories_burned = minutes_needed * row["calories_per_min"]
        plans.append({
            "activity": row[activity_col],
            "minutes": round(minutes_needed, 1),
            "calories": round(calories_burned, 1),
            "calories_per_min": round(row["calories_per_min"], 2),
        })

    # 6. Log for observability
    tool_logs.append({
        "user_weight_lbs": user_weight_lbs,
        "target_calories": target_calories,
        "max_time_minutes": max_time_minutes,
        "top_n": top_n,
        "n_plans": len(plans),
    })

    return plans

🚀 Example Usage

  1. Direct tool call (no agent)

  plans = recommend_activities_tool(
      user_weight_lbs=155,
      target_calories=400,
      max_time_minutes=45,
      top_n=5,
  )
  pd.DataFrame(plans)

Example output: top 5 activities with minutes and calories to hit ~400 kcal.

  1. Agent call with Gemini + ADK

  coach_agent = Agent(
      model="gemini-2.5-flash-lite",
      name="coach_agent",
      description="A fitness coach that suggests activities to hit calorie goals.",
      instruction=(
          "You are a fitness coach.\n"
          "Use the tool `recommend_activities_tool` to choose activities that match "
          "the user's weight, calorie target, and time limit, then explain the plan."
      ),
      tools=[recommend_activities_tool],
  )
  
  runner = InMemoryRunner(agent=coach_agent)
  
  response_events = await runner.run_debug(
      "My weight is 155 lbs. I want to burn about 400 calories in at most 45 minutes. "
      "Use your tool to choose activities and describe the workout plan."
  )
  
  for event in response_events:
      print(event)

Typical natural‑language answer:


“Run at 10.9 mph for ~18.9 minutes to burn ~400 calories. Alternatives: cross‑country skiing uphill or racing‑speed cycling for similar durations.”


📈 Evaluation

The agent is evaluated qualitatively by testing multiple scenarios:

  • Different weights: 130, 155, 180, 205 lbs
  • Different targets: 250–500 kcal
  • Different time limits: 20–60 minutes

For each scenario:

  • Inspect the agent’s final text (does it match the numbers?).

Inspect tool_logs:

  • user_weight_lbs, target_calories, max_time_minutes
  • n_plans returned
  • Optionally, compare with direct recommend_activities_tool(...) output.

Observed behavior:

  • For tight time windows → high‑intensity options (fast running, racing cycling).
  • For longer time windows → more options and moderate durations.

⚠️ Limitations & Future Work

Current limitations:

  • Uses average calorie estimates; individual burn rates vary.
  • No personalization for fitness level, injuries, or medical constraints.
  • Single‑activity focus (greedy selection of best activities), not full multi‑activity scheduling.

Potential extensions:

  • User profiles with preferences and constraints (e.g. “no running”, “low‑impact only”) using memory.
  • Multi‑activity plans (e.g. 10 min running + 15 min cycling).
  • Safety‑aware constraints (e.g. cap max running speed, adjust for beginners).
  • Simple web UI (e.g. Streamlit) hooked into the agent backend.

📂 Repository Structure (suggested)

text exercise-calorie-coach-agent/ ├── notebooks/ │ └── exercise_calorie_coach_capstone.ipynb # Kaggle agent notebook ├── data/ # (optional, .gitignore large files) ├── README.md └── requirements.txt # pandas, google-adk, google-genai, jupyter, etc.

🧰 Tools

Python, Pandas Google Gemini (Gemini 2.5 Flash Lite) Google Agent Development Kit (ADK) Kaggle Notebooks (Agents Intensive environment)

About

Exercise & Calorie Coach Orchestrator Agent (Gemini + ADK) AI “fitness coach” agent that recommends personalized workout plans using Google’s Agent Development Kit (ADK), Gemini, and the Calories Burned During Exercise and Activities Kaggle dataset.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages