|
| 1 | +# LLM Eval Canary (LLM-as-Judge) |
| 2 | + |
| 3 | +Periodically evaluates agent traces using HelpfulnessEvaluator (Bedrock Claude). Opt-in — requires AWS credentials. |
| 4 | + |
| 5 | +Enable by uncommenting `INCLUDE_COMPOSE_AGENT_EVAL_LLM` in `.env`. |
| 6 | + |
| 7 | +## Evaluation Signals |
| 8 | + |
| 9 | +Emits **1 evaluation span** per trace: |
| 10 | + |
| 11 | +| Eval Name | What it measures | Value | |
| 12 | +|---|---|---| |
| 13 | +| `helpfulness` | LLM judges whether the agent's response addressed the user's request | 0.0–1.0 (7-point scale) | |
| 14 | + |
| 15 | +## Configuration |
| 16 | + |
| 17 | +| Env Var | Default | Description | |
| 18 | +|---|---|---| |
| 19 | +| `EVAL_CANARY_LLM_INTERVAL` | `60` | Seconds between poll cycles | |
| 20 | +| `EVAL_CANARY_LLM_LOOKBACK_MINUTES` | `10` | How far back to search for traces | |
| 21 | +| `EVAL_CANARY_LLM_MAX_PER_CYCLE` | `20` | Max traces to evaluate per cycle | |
| 22 | +| `EVAL_CANARY_LLM_CONCURRENCY` | `8` | Parallel Bedrock calls | |
| 23 | +| `EVAL_JUDGE_MODEL` | `us.anthropic.claude-sonnet-4-20250514-v1:0` | Bedrock model ID | |
| 24 | + |
| 25 | +AWS credentials must be available in the environment (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_SESSION_TOKEN`). |
| 26 | + |
| 27 | +## Running with the Deterministic Canary |
| 28 | + |
| 29 | +Both canaries can run simultaneously without duplicating scores. Each deduplicates by its own evaluation name — this canary checks for existing `helpfulness` scores, the deterministic canary checks for `span_coverage`. Neither blocks the other. |
| 30 | + |
| 31 | +A trace scored by both gets **5 evaluation spans**: |
| 32 | + |
| 33 | +``` |
| 34 | +invoke_agent Events Agent |
| 35 | +├── evaluation span_coverage (deterministic) |
| 36 | +├── evaluation error_free (deterministic) |
| 37 | +├── evaluation tool_call_success_rate (deterministic) |
| 38 | +├── evaluation tool_diversity (deterministic) |
| 39 | +└── evaluation helpfulness (LLM-as-judge) |
| 40 | +``` |
| 41 | + |
| 42 | +## OTel Compliance |
| 43 | + |
| 44 | +All evaluation spans follow [OTel GenAI semantic conventions](https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-events/): |
| 45 | + |
| 46 | +- `gen_ai.operation.name = "evaluation"` |
| 47 | +- `gen_ai.evaluation.name = "helpfulness"` |
| 48 | +- `gen_ai.evaluation.score.value` — numeric score |
| 49 | +- `gen_ai.evaluation.score.label` — human-readable label (e.g. "Very helpful", "Somewhat unhelpful") |
| 50 | +- `gen_ai.evaluation.explanation` — LLM's reasoning |
| 51 | +- `gen_ai.evaluation.result` event emitted per span |
| 52 | + |
| 53 | +Score spans attach as children of the evaluated agent's `invoke_agent` span, so they appear in the same trace waterfall in OpenSearch Dashboards. |
0 commit comments