Webhook icon
Schedule icon
Log icon
Commands icon
Docker icon
If icon
SlackIncomingWebhook icon
Pause icon

Continuous GenAI Evaluation and Prompt Regression Guardrails with Comet Opik

Automate GenAI prompt evaluation with Comet Opik, calculate relevance and hallucination metrics, enforce CI/CD guardrails, and alert via Slack.

Categories
AIData

Diagram unavailable

We could not build the topology for this blueprint. The flow itself is valid, use the YAML on the left to run it.

Continuously evaluate prompt templates and LLM responses against benchmark datasets using Comet Opik, calculating multi-dimensional quality metrics, enforcing automated quality gates, and alerting engineering teams via Slack.

Prompt engineering, model checkpoint updates, and retrieval-augmented generation (RAG) parameter tuning frequently introduce silent regressions. These regressions manifest as degraded answer relevance, increased hallucination rates, broken structured output formatting (such as invalid JSON), and subtle drift in brand alignment. Traditional unit tests cannot detect these non-deterministic failure modes. Without continuous evaluation guardrails embedded directly into CI/CD pipelines and deployment lifecycles, flawed prompt changes can slip into production, degrading user trust and violating service level agreements.

How it works

  1. Ingestion Triggers:
    • The ci_cd_webhook_trigger trigger (io.kestra.plugin.core.trigger.Webhook) allows CI/CD systems (GitHub Actions, GitLab CI) to initiate evaluation on prompt pull requests or releases via HTTP endpoint using key: {{ secret('OPIK_EVAL_WEBHOOK_KEY') }}.
    • The nightly_regression_sweep trigger (io.kestra.plugin.core.trigger.Schedule) enables automated recurring evaluation every night at 02:00 UTC to catch silent upstream provider model updates.
  2. Execution Context (setup_evaluation_context):
    • Logs the target model, prompt template version, benchmark dataset, and quality thresholds.
  3. Containerized Opik Evaluation (run_opik_evaluation):
    • Executes inside an isolated python:3.11-slim Docker container using io.kestra.plugin.scripts.python.Commands.
    • Connects to Comet Opik using OPIK_API_KEY and OPIK_WORKSPACE.
    • Pulls or synchronizes benchmark dataset items and candidate model outputs.
    • Computes multi-dimensional quality scores: Answer Relevance, Hallucination Prevention (Context Groundedness), and RFC 8259 JSON syntax validity.
    • Creates structured trace spans and attaches feedback scores to the Comet Opik experiment.
    • Emits evaluation aggregates through Kestra outputs (passed_evaluation, mean_relevance, mean_hallucination, mean_json_valid, opik_experiment_url).
  4. Guardrail Decision & Alerting (check_evaluation_guardrail):
    • An io.kestra.plugin.core.flow.If task verifies if passed_evaluation == true.
    • If passed: logs success and notifies Slack #genai-evaluations.
    • If failed: logs failure metrics, dispatches an alert to Slack #genai-alerts, and halts via io.kestra.plugin.core.flow.Pause for 24 hours to await human review or authorized override.

What you get

  • Automated CI/CD guardrails preventing prompt regressions from reaching production.
  • Multi-dimensional scoring for answer relevance, context faithfulness, and JSON compliance.
  • Native Comet Opik experiment tracking with deep-linked trace dashboards.
  • Human-in-the-loop pause gate allowing SREs and Prompt Engineers to review failing runs before deployment.
  • Zero external daemon requirements: completely serverless and orchestrated by Kestra.

Who it's for

  • GenAI Engineers maintaining production LLM applications and RAG systems.
  • Platform & MLOps teams implementing automated model quality gates in CI/CD.
  • Engineering Managers requiring verifiable prompt release audits and SLA compliance.

Why orchestrate this with Kestra

Evaluating LLMs requires orchestrating containerized Python environments, secrets management, webhook triggers from code repositories, metric aggregation, conditional routing, human-in-the-loop pauses, and team notification channels. Hand-rolling scripts or managing standalone cron instances is fragile and lacks visibility. Kestra provides a declarative, unified control plane that handles the entire evaluation lifecycle out of the box.

Prerequisites

  • A Comet Opik account (Cloud or self-hosted).
  • An active Slack Incoming Webhook URL (if notifications are enabled).

Secrets

  • OPIK_API_KEY: Comet Opik Cloud API key.
  • OPIK_WORKSPACE: Comet workspace identifier.
  • OPIK_EVAL_WEBHOOK_KEY: Secret authentication key for the inbound webhook trigger.
  • SLACK_WEBHOOK_URL: Slack Incoming Webhook URL for alerting.

Inputs

Name Type Default Description
dataset_name STRING customer-support-rag-eval-v1 Comet Opik evaluation dataset identifier.
model_name STRING gpt-4o-mini LLM model identifier under test.
prompt_version STRING v2.4.0-release Prompt template version tag under evaluation.
min_relevance_threshold FLOAT 0.80 Minimum acceptable score for answer relevance.
min_hallucination_threshold FLOAT 0.85 Minimum acceptable score for factual grounding.

Quick start runbook

  1. Configure secrets OPIK_API_KEY, OPIK_WORKSPACE, OPIK_EVAL_WEBHOOK_KEY, and SLACK_WEBHOOK_URL in your Kestra namespace.
  2. Run the flow manually from the Kestra UI to verify containerized Opik trace generation and metric calculation.
  3. Test the inbound webhook from your CI/CD pipeline using the webhook trigger URL and key.
  4. Enable or adjust the nightly_regression_sweep cron schedule to match your team's deployment schedule.

How to extend

  • Add multi-judge consensus scoring using Claude 3.5 Sonnet, GPT-4o, or Gemini 1.5 Pro.
  • Integrate Langfuse, Arize Phoenix, or OpenTelemetry trace exporters alongside Opik.
  • Add automated GitOps rollbacks via GitHub Actions dispatch if evaluation fails and human approval is rejected.
  • Store evaluation metrics in DuckDB or BigQuery for historical prompt quality trending.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.