Skip to content
Learn Agentic AI
Learn Agentic AI13 min read0 views

Building a Size and Fit Agent: AI-Powered Sizing Recommendations for Fashion Retail

Learn how to build an AI agent that recommends accurate clothing sizes by mapping body measurements to brand-specific sizing charts, predicting fit preferences, and reducing return rates in fashion e-commerce.

The Sizing Problem in Online Fashion

Size-related returns account for 30 to 40 percent of all fashion e-commerce returns. A "Medium" from one brand fits like a "Large" from another. Customers cannot try items on, so they either order multiple sizes or guess — both outcomes are expensive for retailers. An AI sizing agent solves this by mapping a customer's measurements and preferences to brand-specific sizing data.

Modeling Size Charts

The foundation is a structured representation of brand sizing data. Each brand-product combination maps size labels to measurement ranges in centimeters.

flowchart TD
    START["Building a Size and Fit Agent: AI-Powered Sizing …"] --> A
    A["The Sizing Problem in Online Fashion"]
    A --> B
    B["Modeling Size Charts"]
    B --> C
    C["Cross-Brand Size Mapping"]
    C --> D
    D["Assembling the Size Agent"]
    D --> E
    E["Reducing Returns with Confidence Scores"]
    E --> F
    F["FAQ"]
    F --> DONE["Key Takeaways"]
    style START fill:#4f46e5,stroke:#4338ca,color:#fff
    style DONE fill:#059669,stroke:#047857,color:#fff
from agents import Agent, Runner, function_tool
from typing import Optional

# Brand sizing data: size -> measurement ranges in cm
SIZE_CHARTS = {
    "BrandA_T-Shirt": {
        "S":  {"chest": (86, 91),  "waist": (71, 76),  "length": 68},
        "M":  {"chest": (91, 97),  "waist": (76, 81),  "length": 71},
        "L":  {"chest": (97, 102), "waist": (81, 86),  "length": 74},
        "XL": {"chest": (102, 107), "waist": (86, 91), "length": 76},
    },
    "BrandB_T-Shirt": {
        "S":  {"chest": (88, 94),  "waist": (73, 78),  "length": 70},
        "M":  {"chest": (94, 100), "waist": (78, 84),  "length": 73},
        "L":  {"chest": (100, 106), "waist": (84, 90), "length": 76},
        "XL": {"chest": (106, 112), "waist": (90, 96), "length": 79},
    },
}

FIT_PREFERENCES = {
    "slim": -2,    # Subtract 2cm from measurements for tighter fit
    "regular": 0,
    "relaxed": 3,  # Add 3cm for looser fit
}

@function_tool
def recommend_size(brand_product: str, chest_cm: float,
                   waist_cm: float, fit_preference: str = "regular") -> str:
    """Recommend a size based on body measurements and fit preference."""
    chart = SIZE_CHARTS.get(brand_product)
    if not chart:
        return f"No sizing data available for {brand_product}."

    adjustment = FIT_PREFERENCES.get(fit_preference, 0)
    adjusted_chest = chest_cm - adjustment
    adjusted_waist = waist_cm - adjustment

    best_size = None
    best_score = float("inf")
    for size_label, measurements in chart.items():
        chest_range = measurements["chest"]
        waist_range = measurements["waist"]
        chest_mid = (chest_range[0] + chest_range[1]) / 2
        waist_mid = (waist_range[0] + waist_range[1]) / 2
        score = abs(adjusted_chest - chest_mid) + abs(adjusted_waist - waist_mid)
        if score < best_score:
            best_score = score
            best_size = size_label

    return (
        f"Recommended size for {brand_product}: {best_size} "
        f"(fit: {fit_preference}). Based on chest {chest_cm}cm, "
        f"waist {waist_cm}cm with {fit_preference} fit adjustment."
    )

Cross-Brand Size Mapping

Customers often know their size in one brand but not another. A mapping tool translates between brand size systems.

@function_tool
def map_size_across_brands(source_brand: str, source_size: str,
                           target_brand: str) -> str:
    """Map a known size from one brand to the equivalent in another."""
    source_chart = SIZE_CHARTS.get(source_brand)
    target_chart = SIZE_CHARTS.get(target_brand)
    if not source_chart or not target_chart:
        return "Sizing data not available for one or both brands."

    source_measurements = source_chart.get(source_size)
    if not source_measurements:
        return f"Size {source_size} not found for {source_brand}."

    # Find closest match in target brand
    source_chest_mid = sum(source_measurements["chest"]) / 2
    source_waist_mid = sum(source_measurements["waist"]) / 2

    best_size = None
    best_score = float("inf")
    for size_label, measurements in target_chart.items():
        chest_mid = sum(measurements["chest"]) / 2
        waist_mid = sum(measurements["waist"]) / 2
        score = abs(source_chest_mid - chest_mid) + abs(source_waist_mid - waist_mid)
        if score < best_score:
            best_score = score
            best_size = size_label

    return (
        f"Your {source_size} in {source_brand} maps to "
        f"{best_size} in {target_brand}."
    )

@function_tool
def get_fit_feedback_summary(product_id: str) -> str:
    """Get aggregated fit feedback from other customers."""
    # In production, query your reviews database
    feedback = {
        "total_reviews": 234,
        "runs_small_pct": 15,
        "true_to_size_pct": 72,
        "runs_large_pct": 13,
        "common_note": "Sleeves run slightly long",
    }
    return (
        f"Fit feedback for {product_id}: {feedback['true_to_size_pct']}% "
        f"say true to size, {feedback['runs_small_pct']}% runs small, "
        f"{feedback['runs_large_pct']}% runs large. "
        f"Note: {feedback['common_note']}"
    )

Assembling the Size Agent

size_agent = Agent(
    name="Size and Fit Advisor",
    instructions="""You are a sizing expert for an online fashion store.
    Help customers find their perfect size.

    Process:
    1. Ask for the customer's key measurements (chest, waist) in cm or inches
    2. Ask about their fit preference (slim, regular, relaxed)
    3. If they know their size in another brand, use cross-brand mapping
    4. Check fit feedback from other customers for the specific item
    5. Recommend a size with confidence level and explanation
    6. Mention the return policy for size exchanges

    Always convert inches to cm internally (1 inch = 2.54 cm).
    If uncertain between two sizes, recommend the larger one and
    explain why.""",
    tools=[recommend_size, map_size_across_brands, get_fit_feedback_summary],
)

result = Runner.run_sync(
    size_agent,
    "I wear a Medium in BrandA t-shirts. What size should I get in BrandB?",
)
print(result.final_output)

Reducing Returns with Confidence Scores

Add a confidence indicator that tells customers how reliable the recommendation is. High confidence means measurements fall squarely within a size range. Low confidence means the customer is between sizes and should consider their fit preference carefully.

See AI Voice Agents Handle Real Calls

Book a free demo or calculate how much you can save with AI voice automation.

def calculate_fit_confidence(chest_cm: float, waist_cm: float,
                             size_range: dict) -> float:
    """Return 0-100 confidence score for a size recommendation."""
    chest_low, chest_high = size_range["chest"]
    waist_low, waist_high = size_range["waist"]

    chest_in_range = chest_low <= chest_cm <= chest_high
    waist_in_range = waist_low <= waist_cm <= waist_high

    if chest_in_range and waist_in_range:
        return 95.0
    elif chest_in_range or waist_in_range:
        return 70.0
    else:
        return 45.0

FAQ

How do I handle customers who only know their measurements in inches?

Build unit conversion directly into the agent's measurement collection flow. When a customer provides measurements, detect whether the values are likely inches (typically 30-50 for chest) or centimeters (typically 76-127 for chest). Confirm the unit with the customer and convert to your internal standard. Store both the original and converted values.

How accurate are AI size recommendations compared to physical try-ons?

With good sizing data and customer measurements, AI recommendations achieve 80 to 85 percent accuracy for basic garments like t-shirts and pants. Accuracy drops for items with complex fits like blazers or dresses. Incorporating community fit feedback ("runs small") and the customer's historical return data improves accuracy to 90 percent or higher over time.

Should I store customer measurements for future visits?

Yes, with explicit consent. Stored measurements allow instant recommendations on return visits without re-measuring. Implement this as an opt-in profile feature with clear data privacy disclosures. Let customers update measurements anytime and delete their data on request to comply with GDPR and CCPA requirements.


#SizeRecommendation #FashionTech #FitPrediction #RetailAI #ReturnReduction #AgenticAI #LearnAI #AIEngineering

Share
C

Written by

CallSphere Team

Expert insights on AI voice agents and customer communication automation.

Try CallSphere AI Voice Agents

See how AI voice agents work for your industry. Live demo available -- no signup required.

Related Articles You May Like

Learn Agentic AI

Building a Product Discovery Agent: AI-Powered Shopping Assistance and Recommendations

Learn how to build an AI agent that helps shoppers discover products through natural language search, personalized filtering, side-by-side comparisons, and recommendation engines tailored to individual preferences.

Learn Agentic AI

AI Agent for Order Support: Tracking, Returns, Exchanges, and Modifications

Build an AI agent that handles the complete order support lifecycle — from tracking shipments and processing returns to managing exchanges and order modifications — reducing support ticket volume significantly.

Learn Agentic AI

AI Agent for Inventory Inquiries: Store Availability, Restock Alerts, and Alternatives

Build an AI agent that checks real-time store inventory, sets up restock notifications for out-of-stock items, and suggests suitable alternatives — keeping customers engaged instead of bouncing to competitors.

Learn Agentic AI

Building a Price Matching Agent: Competitor Price Monitoring and Adjustment

Learn how to build an AI agent that monitors competitor prices, evaluates price match requests against policy rules, calculates adjustments, and communicates price matches to customers — protecting margins while staying competitive.

Learn Agentic AI

AI Agent for Loyalty Programs: Points Balance, Rewards, and Redemption Assistance

Build an AI agent that helps customers check loyalty points balances, browse reward catalogs, redeem rewards, and understand how to earn points faster — increasing program engagement and customer retention.

Agentic AI

AI Agents for Real-Time Demand Sensing and Predictive Commerce

How agentic AI systems sense consumer demand signals in real time to adjust pricing, optimize inventory, and drive predictive commerce across global retail and CPG markets.