- Does NOT block the response to the user
- Logs evaluation results for monitoring and analytics
- Can trigger alerts or store metrics without affecting latency
- Quality monitoring in production
- Compliance auditing
- Validating hallucinations or other inappropriate content
What Happens
- User sends a request to the agent
- The agent processes and generates a response
- The response is sent to the user immediately
- Background evaluation runs:
AgentAsJudgeEvalautomatically evaluates the response against the criteria- Scores the response on a scale of 1-10
- Stores results in the database
Production Extensions
In production, you could extend this pattern to:| Extension | Description |
|---|---|
| Database Storage | Store evaluations for analytics dashboards |
| Alerting | Use on_fail callback to send alerts when evaluations fail |
| Observability | Log to platforms like Datadog or OpenTelemetry |
| A/B Testing | Compare response quality across model versions |
| Training Data | Build datasets for fine-tuning |
Related Examples
Global Background Hooks
Run all hooks as background tasks
Per-Hook Background
Mix synchronous and background hooks