Sanitize Agent
Schema Normalization & Economic Validation Layer · POST /v1/agent/sanitize/run

Category: Normalization & Validation · Execution Model: Deterministic, Stateless, Idempotent

Purpose

The Sanitize Agent is responsible for transforming raw, untrusted JSON payloads produced by LLMs and scraper agents into a normalized, economically-evaluated, and schema-safe format suitable for downstream scoring, scheduling, and launch decisions. It acts as the system’s primary integrity gate — enforcing defaults, validating structure, computing financial viability, and preventing malformed or hallucinated data from propagating through the Whook pipeline.

Expected Inputs

  • meta object (required)
    Metadata describing the context of the chunk. Includes region, discovery assumptions, and chunk-level parameters.
  • items array (required)
    Array of raw event or session objects generated by LLMs or supply scrapers. Each item may be incomplete or partially hallucinated prior to sanitization.

Outputs

  • HTTP Response
    {
      "success": "boolean",
      "message": "string",
      "savedCount": "number"
    }
  • Side Effect
    Writes NormalizedEvent documents to events_normalized collection
  • Side Effect
    Rejects malformed chunks with 400-level validation errors

Responsibilities

Lifecycle

Downstream Dependencies

Guarantees

Failure Model

If required schema fields are missing or validation fails, the sanitizer returns a 400 response with explicit error messages and does not persist any data. Unexpected runtime failures return a 500 response and log errors without partially writing invalid state.

Internal State

{
  "persistence": [
    "events_normalized"
  ],
  "guarantees": [
    "All persisted events conform to normalized schema",
    "All numeric economics are deterministically computed",
    "No malformed items reach downstream agents"
  ]
}

Sample cURL


curl -X POST https://api.whook.ai/v1/agent/sanitize/run \
  -H "Content-Type: application/json" \
  -d '{
    "meta": {
      "region": "Los Angeles County, CA",
      "assumptions": "Supply scraper ingestion"
    },
    "items": [
      {
        "title": "Outdoor Power Yoga",
        "about": "Intense 90-minute yoga session outdoors.",
        "recommendedCreditsRequired": 2,
        "estimatedSessionCostBreakdown": {
          "instructorCost": 50,
          "venueCost": 20
        }
      }
    ]
  }'