This article was created for the purpose of entering the Google #AllThingsAgentic Hackathon (Taskmaster Category).
The Friction: Haircare is a Chemistry Experiment
Anyone managing textured or curly hair knows that finding the right routine is rarely straightforward. It often turns into an accidental cosmetic chemistry experiment:
- Put a high-glycerin product in your hair when tomorrow's dew point spikes above 70Β°F? You get extreme frizz.
- Use a heavy silicone without alternating with a clarifying sulfate? You build up an occlusive layer that blocks hydration.
- Layer high-concentration keratin treatments over already protein-sensitive strands? You end up with brittle, snapping hair (protein overload).
Humans aren't built to memorize the chemical interactions of dozens of cosmetic compounds across multiple bottles, let alone reconcile those ingredients against tomorrow's local UV index and humidity forecast.
I wanted to fix thisβnot with another static chatbot where you paste text and read advice, but with an autonomous background Taskmaster that actually does the heavy lifting for you.
What is Curl Chemist?
Curl Chemist is an autonomous AI agent built to manage the entire lifecycle of a personalized haircare routine without manual intervention.
[ Snap Label Photo ] ββ> [ Cloud Storage ] ββ> [ Pub/Sub ]
β
βΌ
[ Google Calendar ] <ββ [ Nightly Scheduler ] <ββ [ Cloud Run + Gemini 3.5 ]
(Auto-booked) (Weather + Inventory) (NΓN Conflict Engine)
- Scan & Analyze: Snap a photo of any product label. Cloud Storage fires an event through Pub/Sub, triggering Gemini 3.5 Flash to extract the chemical formulation and cross-reference it against your existing digital shelf (detecting silicone/sulfate mismatches, moisture-protein balance issues, etc.).
- Autonomous Daily Scheduling: Every night at 9:00 PM, a Cloud Scheduler cron job wakes up the Taskmaster orchestrator. It fetches the next day's local weather forecast, calculates humidity/dew point risks, builds the optimal product combination, and autonomously books a time block on your Google Calendar if a deep treatment or wash day is needed.
Architectural Highlights & Engineering Deep-Dive
Building a system that operates asynchronously in the background requires failure tolerance, context boundaries, and data security.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Incoming Request β
ββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββ
β Agent Gateway (Gemma 2 9B) β ββ[ Off-Topic / Malicious ]ββ> [ Drop / 400 ]
ββββββββββββββββ¬βββββββββββββββ
β (Valid Haircare Intent)
βΌ
βββββββββββββββββββββββββββββββ
β Cloud DLP (PII Redaction) β
ββββββββββββββββ¬βββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββ
β Orchestrator (Cloud Run) β
β Self-Healing ReAct Loop β <ββ> [ Gemini 3.5 Flash ]
ββββββββββββββββ¬βββββββββββββββ
β
ββββββββββββββββββ΄βββββββββββββββββ
βΌ βΌ
[ Firestore Memory ] [ Google Calendar API ]
1. Self-Healing ReAct Loop
Background pipelines fail when an LLM produces a malformed tool call or bad JSON argument. Instead of letting the server crash, I built a custom self-healing ReAct loop using the Google GenAI SDK:
# Conceptual execution loop
while retries < MAX_RETRIES:
try:
response = agent_orchestrator.step(current_context)
if response.has_tool_call():
tool_output = execute_tool(response.tool_call)
current_context.append_tool_result(tool_output)
else:
break
except ToolExecutionError as e:
# Feed the literal traceback directly back into the LLM context
current_context.append_error(
f"Tool execution failed: {str(e)}. Please adjust your arguments and retry."
)
retries += 1
If a tool call fails, the Python backend catches the traceback and appends the exact error message back into the model's execution context. The agent inspects its own mistake, adjusts its arguments, and recovers gracefully without human intervention.
2. Zero-Trust Gateway with Gemma
To ensure efficient resource usage and guard against junk or off-topic prompts reaching Gemini 3.5 Flash, I implemented an Agent Gateway powered by gemma-2-9b-it.
Gemma acts as an ultra-fast, local-intent classifier that fails closed. If an incoming request falls outside cosmetic chemistry or routine scheduling, the gateway intercepts and drops the request before any heavy background processing occurs.
3. Model Armor & Inline Privacy (Cloud DLP)
To maintain enterprise privacy standards, all reasoning traces and raw inputs are passed through Google Cloud DLP (dlp_client.deidentify_content) prior to logging in Firestore. Any potential PII (such as personal contact details or location strings) is redacted inline, ensuring the long-term memory bank stays clean and compliant.
Tech Stack
-
AI & Agent Core: Gemini 3.5 Flash, Gemma (
gemma-2-9b-it), Google GenAI SDK - Compute & Services: Google Cloud Run, Cloud Scheduler, Cloud Storage, Cloud Pub/Sub, Cloud DLP
- Database & Memory: Google Cloud Firestore
- Backend: Python, FastAPI, Uvicorn
- Integrations: Google Calendar API, Open-Meteo API
Key Learnings
- Error traces make great prompts: Giving an agent its own runtime errors turns brittle API pipelines into resilient workflows.
- Decouple triage from heavy reasoning: Using a smaller model like Gemma as a gatekeeper significantly reduces latency and keeps the primary agent focused on domain-specific execution.
- Action beats conversation: Moving away from standard chat interfaces toward scheduled, event-driven autonomous tasks makes AI genuinely useful for recurring real-world friction.
















