Prompt
How do I build something that alerts us when AI answers change?
Latest observation
A good way to do this is to treat AI responses like versioned outputs and continuously compare them against a baseline.
What you want to detect
“AI answers change” can mean a few different things:
- The same prompt now gives a different answer
- The answer changes in a meaningful way, not just wording
- The model/provider updated silently
- Your own prompt or tools changed
- The answer quality regressed even if wording is similar
A useful alerting system usually checks all of these.
Basic architecture
1. Define a fixed test set
Create a set of prompts that represent your important use cases.
Example:
- Support questions
- Policy questions
- Code generation tasks
- Structured extraction prompts
- Safety-sensitive prompts
Store for each test:
- Prompt text
- Expected format
- Importance/priority
- Tolerance for variation
- Optional “golden” reference answer
2. Run the prompts on a schedule
Have a job that runs:
- Daily
- Hourly
- After deployments
- After model/provider version changes
For each prompt, capture:
- Prompt
- Model name/version
- Temperature and other parameters
- Tool usage
- Raw response
- Timestamp
- Token usage
- Latency
3. Compare against a baseline
You need a baseline response to compare against.
Common baseline strategies:
- Exact previous response: simple but brittle
- Pinned “golden” response: manually approved
- Statistical baseline: compare against several historical samples
Then compare new output with the baseline using one or more methods:
A. Text similarity
- Levenshtein distance
- Diff on raw text
- Embedding similarity
- BLEU/ROUGE-style overlap
Useful for:
- Detecting wording drift
- Tracking format changes
B. Semantic comparison
Use an LLM or classifier to answer:
- Is the meaning the same?
- Is any factual content different?
- Is the structure preserved?
Useful for:
- Paraphrases
- Subtle answer changes
C. Schema validation
If output should be structured JSON:
- Validate JSON schema
- Check required fields
- Check types and ranges
This is the strongest signal for structured outputs.
D. Task-specific checks
Examples:
- Does the answer mention required policy clauses?
- Does code compile?
- Does extracted data match expected entities?
- Does the classification label stay the same?
4. Score the change
Give each response a change score, for example:
- No change
- Minor wording change
- Meaningful drift
- Format broken
- Critical regression
You can combine signals into one score:
- 30% text similarity
- 30% semantic similarity
- 20% schema compliance
- 20% business rules
5. Alert on thresholds
Trigger alerts when:
- Similarity drops below a threshold
- Schema fails
- Critical fields change
- Confidence is low
- Responses deviate from the historical cluster
Send alerts to:
- Slack
- PagerDuty
- Jira ticket
Include:
- Prompt
- Old answer
- New answer
- Diff
- Change score
- Model version
- Timestamp
A practical design pattern
Store every run
Use a database table like:
prompt_idprompt_textmodeltemperatureresponse_textresponse_jsonembeddingrun_timebaseline_versiondiff_scorealerted
Compute diffs
For each new run:
- Fetch baseline
- Generate a diff
- Run semantic evaluator
- Validate schema
- Store results
- Alert if needed
Suggested implementation stack
Simple version
- Scheduler: cron, GitHub Actions, Airflow, or Celery
- Storage: PostgreSQL or SQLite
- Diffing: Python
difflib - Embeddings: OpenAI embeddings or local embedding model
- Alerts: Slack webhook
More robust version
- Orchestrator: Airflow / Dagster
- Storage: Postgres + object storage
- Vector search: pgvector / Pinecone / Weaviate
- Evaluation: LLM-as-judge + rules
- Dashboard: Grafana / Metabase / custom web app
Minimal viable version
You can start with just:
- A list of 20–50 important prompts
- A nightly job
- Save the previous response
- Compare with diff + embedding similarity
- Alert if similarity drops or structured output breaks
That catches most accidental changes.
Important pitfalls
Don’t rely only on exact text
LLMs often rephrase while preserving meaning.
Don’t rely only on embeddings
Semantic similarity can miss critical factual changes.
Control randomness
Use:
- temperature = 0 for regression tests when possible
- fixed seed if supported
- consistent system prompts
Pin model versions if possible
Otherwise, changes may be due to provider updates.
Track environment changes
Alert separately on:
- prompt edits
- retrieval index updates
- tool/API changes
- model version changes
If you want “meaningful change” detection
The best approach is usually:
- Rules for format
- Semantic judge for meaning
- Human review for edge cases
Example workflow:
- Output changes
- Automated evaluator flags it
- If severity is high, create a review item
- Human confirms whether it’s acceptable
Example alert logic
Alert if any of these are true:
- JSON schema invalid
- Required field missing
- Similarity < 0.85
- Judge says “meaning changed”
- Safety policy violation detected
- Answer differs on any critical fact
Example message to send
AI response changed for prompt
refund_policy_q12
Model:gpt-4.1
Severity: High
Old: “Refunds are available within 30 days...”
New: “Refunds are not available...”
Similarity: 0.61
Schema: pass
Judge: meaning changed
Best starting point
If you want the fastest path:
- Build a prompt suite
- Store baseline outputs
- Re-run daily
- Use a combination of:
- schema checks
- text diff
- semantic judge
- Alert on significant deviations
If you want, I can also give you:
- a system design diagram,
- a Python prototype, or
- a database schema + alerting logic for this.