Schedule icon
ChatCompletion icon
Script icon
Docker icon
If icon
SlackIncomingWebhook icon
Log icon
Return icon

AI Prompt Drift and Quality Sentinel

Sends golden benchmark prompt suites to OpenAI daily, evaluates output schema and semantic quality, and alerts engineering on regression.

Categories
AICloud

Large Language Model (LLM) APIs are continuously updated by foundation model providers (such as OpenAI, Anthropic, and Google). Even within fixed alias endpoints like gpt-4o-mini, upstream weight refinements, safety guardrail alterations, and prompt template adjustments can silently alter response formatting and semantic classifications.

When production applications rely on structured JSON outputs from LLMs, a subtle provider update can cause models to omit required keys, wrap JSON in unexpected markdown fences, or misclassify critical user intents, causing downstream automated workflows to fail.

This blueprint provides an automated LLM quality gate that dispatches standardized golden benchmark prompts daily, verifies JSON schema validity, tests semantic intent assertions, and alerts AI engineering teams via Slack the moment quality regressions appear.

How it works

  1. Scheduled Daily Evaluation: The daily_model_evaluation trigger (io.kestra.plugin.core.trigger.Schedule) executes daily at 08:00 UTC.
  2. Model Inference: The execute_model_inference task (io.kestra.plugin.openai.ChatCompletion) sends the standardized golden prompt with system constraints to OpenAI.
  3. Python Quality Scoring: The analyze_response_quality task (io.kestra.plugin.scripts.python.Script) strips markdown wrappers, validates JSON parsing, checks expected intent keywords, and exports drift_report.json.
  4. Condition Branching: The evaluate_drift_alarm flowable task (io.kestra.plugin.core.flow.If) branches based on whether any drift criteria were triggered.
  5. Slack Alert Dispatch: When drift is detected, notify_slack_prompt_drift (io.kestra.plugin.slack.notifications.SlackIncomingWebhook) delivers an actionable triage card.
  6. Evaluation Manifest: The export_drift_manifest task records benchmark results for model evaluation dashboards.

Architecture diagram

flowchart TD
    A[Schedule: Daily 08:00 UTC] --> B[execute_model_inference: OpenAI]
    B --> C[analyze_response_quality: Python JSON & Semantic Validator]
    C --> D{Quality Drift Detected?}
    D -- Yes --> E[notify_slack_prompt_drift: Slack]
    D -- No --> F[log_model_accuracy_compliant: Log]
    E --> G[export_drift_manifest: Return JSON]
    F --> G

Use cases

  • Continuous Prompt Regression Guard: Catch silent provider-side model updates that degrade downstream JSON schema parsing.
  • Intent Classification Verification: Ensure customer support prompt benchmarks consistently produce expected classification labels.
  • Model Upgrade Certification: Benchmark new foundation model releases against standardized golden evaluation suites.

What you get

  • Automated regression testing of production LLMs against immutable ground truth suites.
  • Strict validation of output JSON schema integrity and required keys.
  • Semantic intent verification asserting business classification accuracy.
  • Immediate Slack alerts detailing exact failure causes (parse failure vs semantic mismatch).

Who it is for

  • AI Platform Engineers and Machine Learning Engineers maintaining production LLM services.
  • Product Developers building applications that consume structured JSON from generative models.
  • QA Engineers automating regression testing of prompt engineering pipelines.

Why orchestrate this with Kestra

Building custom LLM evaluation scripts requires managing API client keys, scheduling crons, and formatting incident webhooks. Kestra natively unifies OpenAI integration, containerized Python analysis, conditional branching, and enterprise Slack alerting into a declarative workflow that runs reliably.

Inputs

Name Type Default Description
model_name STRING gpt-4o-mini OpenAI model target identifier.
golden_prompt STRING Extract the core customer intent... Benchmark prompt payload.
expected_intent_keyword STRING cancel Keyword expected in structured intent output.
slack_channel STRING #ai-platform Slack channel destination for alerts.

Expected outputs

  • {{ outputs.analyze_response_quality.vars.drift_detected }}: Boolean flag indicating if regression occurred.
  • {{ outputs.analyze_response_quality.vars.parse_success }}: Boolean flag indicating valid JSON parsing.
  • {{ outputs.analyze_response_quality.vars.intent_matched }}: Boolean flag indicating expected keyword match.
  • {{ outputs.analyze_response_quality.outputFiles['drift_report.json'] }}: Complete JSON diagnostic report.

Prerequisites

  • OpenAI API account with active API credits.
  • OpenAI API key stored in Kestra secrets.
  • Slack Incoming Webhook configured for AI platform notifications.

Secrets

  • OPENAI_API_KEY: API key for OpenAI model inference.
  • SLACK_WEBHOOK_URL: Slack Incoming Webhook endpoint URL.

Quick start

  1. Configure OPENAI_API_KEY and SLACK_WEBHOOK_URL in your Kestra namespace secrets.
  2. Import this flow YAML into your Kestra instance.
  3. Click Execute in the UI to run an initial benchmark evaluation.
  4. Review execution outputs and Slack channels for verification.

Common pitfalls and troubleshooting

  • Markdown Code Fences: LLMs often wrap JSON outputs in ```json ... ```; the script safely handles and strips fences before validation.
  • Temperature Setting: In production benchmarks, use a low temperature (e.g. 0.0 or 0.1) to ensure deterministic evaluations.
  • API Rate Limits: Ensure your OpenAI organization tier supports scheduled inference without hitting 429 concurrency throttles.

How to extend

  • Add io.kestra.plugin.core.flow.EachParallel to test multiple models (e.g. gpt-4o-mini, gpt-4o, claude-3-5-sonnet) against the same prompt simultaneously.
  • Store historical evaluation scores in PostgreSQL to visualize model drift trends over months.
  • Automatically fall back to a backup model provider if golden evaluation fails.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.