Metrics
Metrics are grouped by dimension. Names, scoring scales, and requirements are in the Metrics Catalog; to write your own, see Custom Metrics.
uaef.metrics.base
Base metric interface for UAEF.
BaseMetric
Bases: ABC
Abstract base class for all metrics in UAEF.
All metrics must inherit from this class and implement the calculate method. Metrics can be deterministic (rule-based), ground truth-based (require expected outputs), or LLM-based (use LLM judge for subjective evaluation).
Source code in uaef/metrics/base.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
batch_calculate(metrics, evaluation_input)
classmethod
Evaluate multiple metrics of this batch group in a single operation.
Override this in subclasses that support batching. The base evaluator
calls this instead of individual calculate() when metrics share the
same batch_group() key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metrics
|
List[BaseMetric]
|
List of metric instances in this batch group. |
required |
evaluation_input
|
EvaluationInput
|
Shared evaluation input for all metrics. |
required |
Returns:
| Type | Description |
|---|---|
List[MetricScore]
|
List of MetricScore objects (one per successfully evaluated metric). |
Source code in uaef/metrics/base.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
batch_group()
Return a batch group key if this metric supports batched evaluation.
Metrics that return the same non-None key will be grouped together and
evaluated via batch_calculate in a single call, which can be much
faster for metrics that make external LLM calls.
Returns:
| Type | Description |
|---|---|
Optional[str]
|
A string key identifying the batch group, or None (default) to |
Optional[str]
|
indicate this metric does not support batching. |
Source code in uaef/metrics/base.py
142 143 144 145 146 147 148 149 150 151 152 153 | |
calculate(evaluation_input)
abstractmethod
Calculate the metric score for the given evaluation input.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
evaluation_input
|
EvaluationInput
|
Input data containing trace, ground truth, and context |
required |
Returns:
| Type | Description |
|---|---|
MetricScore
|
MetricScore object with score, reasoning, and metadata |
Raises:
| Type | Description |
|---|---|
ValueError
|
If required data is missing (e.g., ground truth when required) |
Source code in uaef/metrics/base.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | |
calculate_async(evaluation_input)
abstractmethod
async
Asynchronously calculate the metric score (for LLM-based metrics).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
evaluation_input
|
EvaluationInput
|
Input data containing trace, ground truth, and context |
required |
Returns:
| Type | Description |
|---|---|
MetricScore
|
MetricScore object with score, reasoning, and metadata |
Raises:
| Type | Description |
|---|---|
ValueError
|
If required data is missing |
Source code in uaef/metrics/base.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
get_dependencies()
Get dependencies for this metric.
Returns:
| Type | Description |
|---|---|
Dict[str, List[str]]
|
Dictionary with dependency information: |
Dict[str, List[str]]
|
|
Dict[str, List[str]]
|
|
Dict[str, List[str]]
|
|
Example
{"requires_metadata": ["quality_score"]}
Source code in uaef/metrics/base.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
get_description()
Get a human-readable description of what this metric measures.
Returns:
| Type | Description |
|---|---|
Optional[str]
|
Description string or None |
Source code in uaef/metrics/base.py
108 109 110 111 112 113 114 115 | |
get_dimension()
Get the dimension this metric belongs to.
Returns:
| Type | Description |
|---|---|
Optional[str]
|
Dimension name (e.g., "Tool Calling", "Response Quality") or None |
Source code in uaef/metrics/base.py
117 118 119 120 121 122 123 124 | |
get_name()
abstractmethod
Get the name of this metric.
Returns:
| Type | Description |
|---|---|
str
|
String name of the metric (e.g., "tool_selection_accuracy") |
Source code in uaef/metrics/base.py
78 79 80 81 82 83 84 85 86 | |
requires_ground_truth()
abstractmethod
Check if this metric requires ground truth data.
Returns:
| Type | Description |
|---|---|
bool
|
True if ground truth is required, False otherwise |
Source code in uaef/metrics/base.py
88 89 90 91 92 93 94 95 96 | |
requires_llm_judge()
abstractmethod
Check if this metric requires an LLM judge for evaluation.
Returns:
| Type | Description |
|---|---|
bool
|
True if LLM judge is required, False otherwise |
Source code in uaef/metrics/base.py
98 99 100 101 102 103 104 105 106 | |
get_bedrock_client()
Create a Bedrock runtime client using the default credential chain.
Uses config for region but lets boto3 resolve credentials from environment variables, IAM roles, or credential files — never passes None explicitly which would break the default chain.
Source code in uaef/metrics/base.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | |
uaef.metrics.registry
Metric registry and factory for UAEF.
This module provides a centralized registry for all metrics and a factory pattern for creating metric instances by name.
MetricRegistry
Registry for all available metrics in UAEF.
Provides centralized registration and factory methods for creating metric instances. Supports both built-in and custom metrics.
Source code in uaef/metrics/registry.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 | |
get_all_metrics_info()
Get detailed information about all registered metrics.
Returns:
| Type | Description |
|---|---|
List[Dict[str, any]]
|
List of dictionaries with metric information |
Source code in uaef/metrics/registry.py
381 382 383 384 385 386 387 388 389 390 391 | |
get_metric(metric_name, **kwargs)
Factory method to create a metric instance by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metric_name
|
str
|
Name of the metric to create |
required |
**kwargs
|
Additional arguments to pass to the metric constructor |
{}
|
Returns:
| Type | Description |
|---|---|
BaseMetric
|
Instance of the requested metric |
Raises:
| Type | Description |
|---|---|
KeyError
|
If metric is not found in registry |
Source code in uaef/metrics/registry.py
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 | |
get_metric_info(metric_name)
Get detailed information about a metric.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metric_name
|
str
|
Name of the metric |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, any]
|
Dictionary with metric information |
Raises:
| Type | Description |
|---|---|
KeyError
|
If metric is not found in registry |
Source code in uaef/metrics/registry.py
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 | |
get_metrics_requiring_ground_truth()
Get list of metrics that require ground truth.
Returns:
| Type | Description |
|---|---|
List[str]
|
List of metric names that require ground truth |
Source code in uaef/metrics/registry.py
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 | |
get_metrics_requiring_llm_judge()
Get list of metrics that require LLM judge.
Returns:
| Type | Description |
|---|---|
List[str]
|
List of metric names that require LLM judge |
Source code in uaef/metrics/registry.py
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 | |
list_metrics()
Get a list of all registered metric names.
Returns:
| Type | Description |
|---|---|
List[str]
|
List of metric names |
Source code in uaef/metrics/registry.py
243 244 245 246 247 248 249 250 | |
list_metrics_by_dimension()
Get metrics grouped by dimension.
Returns:
| Type | Description |
|---|---|
Dict[str, List[str]]
|
Dictionary mapping dimension names to lists of metric names |
Source code in uaef/metrics/registry.py
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | |
register(metric_class)
Register a metric class in the registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metric_class
|
Type[BaseMetric]
|
The metric class to register (must inherit from BaseMetric) |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If metric_class is not a subclass of BaseMetric |
ValueError
|
If a metric with the same name is already registered |
Source code in uaef/metrics/registry.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | |
unregister(metric_name)
Unregister a metric from the registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metric_name
|
str
|
Name of the metric to unregister |
required |
Raises:
| Type | Description |
|---|---|
KeyError
|
If metric is not found in registry |
Source code in uaef/metrics/registry.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 | |
validate_metric_implementation(metric_class)
Validate that a metric class properly implements the BaseMetric interface.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metric_class
|
Type[BaseMetric]
|
The metric class to validate |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if valid, False otherwise |
Source code in uaef/metrics/registry.py
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 | |
get_metric(metric_name, **kwargs)
Factory function to create a metric instance by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metric_name
|
str
|
Name of the metric to create |
required |
**kwargs
|
Additional arguments to pass to the metric constructor |
{}
|
Returns:
| Type | Description |
|---|---|
BaseMetric
|
Instance of the requested metric |
Source code in uaef/metrics/registry.py
430 431 432 433 434 435 436 437 438 439 440 441 442 | |
get_registry()
Get the global metric registry instance.
Creates the registry on first call with all built-in metrics registered.
Returns:
| Type | Description |
|---|---|
MetricRegistry
|
MetricRegistry instance |
Source code in uaef/metrics/registry.py
398 399 400 401 402 403 404 405 406 407 408 409 410 | |
list_metrics()
Get a list of all registered metric names.
Returns:
| Type | Description |
|---|---|
List[str]
|
List of metric names |
Source code in uaef/metrics/registry.py
445 446 447 448 449 450 451 452 453 | |
list_metrics_by_dimension()
Get metrics grouped by dimension.
Returns:
| Type | Description |
|---|---|
Dict[str, List[str]]
|
Dictionary mapping dimension names to lists of metric names |
Source code in uaef/metrics/registry.py
456 457 458 459 460 461 462 463 464 | |
register_metric(metric_class)
Register a custom metric in the global registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metric_class
|
Type[BaseMetric]
|
The metric class to register |
required |
Source code in uaef/metrics/registry.py
419 420 421 422 423 424 425 426 427 | |
register_use_case_specific_metrics()
Opt-in registration for use-case-specific metrics.
These metrics evaluate behavior that's only meaningful for specific use cases (e.g., customer-service / contact-center agents) and are deliberately excluded from the default registry. Call this once at startup if you want them to participate in evaluations.
Currently registers
- ContainmentMetric ("containment")
- ResolutionMetric ("resolution")
The call is idempotent — invoking it multiple times has no effect.
Example
from uaef.metrics.registry import register_use_case_specific_metrics
register_use_case_specific_metrics() result = evaluate(trace, metrics=["containment", "resolution"])
Source code in uaef/metrics/registry.py
467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 | |
reset_registry()
Reset the global registry to None.
Source code in uaef/metrics/registry.py
413 414 415 416 | |
uaef.metrics.tool_calling
Tool calling metrics for UAEF.
This module implements metrics for evaluating agent tool calling accuracy, including tool selection, sequence correctness, and parameter quality.
MCPComplianceMetric
Bases: BaseMetric
Metric for evaluating Model Context Protocol (MCP) compliance.
Checks if tool calls follow MCP standards and conventions.
Source code in uaef/metrics/tool_calling.py
489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 | |
calculate(evaluation_input)
Calculate MCP compliance.
Source code in uaef/metrics/tool_calling.py
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 | |
calculate_async(evaluation_input)
async
Async version (just calls synchronous version for deterministic metric).
Source code in uaef/metrics/tool_calling.py
613 614 615 | |
get_description()
Get metric description.
Source code in uaef/metrics/tool_calling.py
508 509 510 | |
get_dimension()
Get metric dimension.
Source code in uaef/metrics/tool_calling.py
512 513 514 | |
get_name()
Get metric name.
Source code in uaef/metrics/tool_calling.py
496 497 498 | |
requires_ground_truth()
This metric does not require ground truth.
Source code in uaef/metrics/tool_calling.py
500 501 502 | |
requires_llm_judge()
This metric does not require LLM judge.
Source code in uaef/metrics/tool_calling.py
504 505 506 | |
ParameterQualityMetric
Bases: BaseMetric
Metric for evaluating tool parameter/argument quality.
Uses per-call key-value pair matching to evaluate parameter correctness. Detects swapped arguments and incorrect parameter values.
Source code in uaef/metrics/tool_calling.py
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 | |
calculate(evaluation_input)
Calculate parameter quality.
Source code in uaef/metrics/tool_calling.py
382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 | |
calculate_async(evaluation_input)
async
Async version (just calls synchronous version for deterministic metric).
Source code in uaef/metrics/tool_calling.py
484 485 486 | |
get_description()
Get metric description.
Source code in uaef/metrics/tool_calling.py
374 375 376 | |
get_dimension()
Get metric dimension.
Source code in uaef/metrics/tool_calling.py
378 379 380 | |
get_name()
Get metric name.
Source code in uaef/metrics/tool_calling.py
362 363 364 | |
requires_ground_truth()
This metric requires ground truth.
Source code in uaef/metrics/tool_calling.py
366 367 368 | |
requires_llm_judge()
This metric does not require LLM judge.
Source code in uaef/metrics/tool_calling.py
370 371 372 | |
ToolSelectionAccuracyMetric
Bases: BaseMetric
Metric for evaluating tool selection accuracy using Jaccard similarity.
Evaluates tool names only (ignores parameters). Uses multiset/bag semantics where duplicate tool calls are meaningful. Computes Jaccard similarity: matched / (expected + actual - matched)
Source code in uaef/metrics/tool_calling.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | |
calculate(evaluation_input)
Calculate tool selection accuracy using Jaccard similarity.
Source code in uaef/metrics/tool_calling.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |
calculate_async(evaluation_input)
async
Async version (just calls synchronous version for deterministic metric).
Source code in uaef/metrics/tool_calling.py
232 233 234 | |
get_description()
Get metric description.
Source code in uaef/metrics/tool_calling.py
161 162 163 | |
get_dimension()
Get metric dimension.
Source code in uaef/metrics/tool_calling.py
165 166 167 | |
get_name()
Get metric name.
Source code in uaef/metrics/tool_calling.py
149 150 151 | |
requires_ground_truth()
This metric requires ground truth.
Source code in uaef/metrics/tool_calling.py
153 154 155 | |
requires_llm_judge()
This metric does not require LLM judge.
Source code in uaef/metrics/tool_calling.py
157 158 159 | |
ToolSequenceCorrectnessMetric
Bases: BaseMetric
Metric for evaluating tool call sequence correctness.
Validates that tools are called in the correct order compared to ground truth. Uses sequence similarity scoring.
Source code in uaef/metrics/tool_calling.py
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 | |
calculate(evaluation_input)
Calculate tool sequence correctness.
Source code in uaef/metrics/tool_calling.py
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 | |
calculate_async(evaluation_input)
async
Async version (just calls synchronous version for deterministic metric).
Source code in uaef/metrics/tool_calling.py
349 350 351 | |
get_description()
Get metric description.
Source code in uaef/metrics/tool_calling.py
257 258 259 | |
get_dimension()
Get metric dimension.
Source code in uaef/metrics/tool_calling.py
261 262 263 | |
get_name()
Get metric name.
Source code in uaef/metrics/tool_calling.py
245 246 247 | |
requires_ground_truth()
This metric requires ground truth.
Source code in uaef/metrics/tool_calling.py
249 250 251 | |
requires_llm_judge()
This metric does not require LLM judge.
Source code in uaef/metrics/tool_calling.py
253 254 255 | |
uaef.metrics.response_quality
Response quality metrics for UAEF.
This module implements metrics for evaluating agent response quality, including relevance, completeness, hallucination detection, and accuracy.
Reuses LLM judge logic from agenticevaluationframework-main/frontend/evaluation.py.
AccuracyMetric
Bases: BaseMetric
Metric for evaluating response accuracy against reference answer.
Compares the response against ground truth reference answer for correctness. Reuses llm_as_judge_score from evaluation.py (lines 360-459). Requires ground truth for comparison.
Source code in uaef/metrics/response_quality.py
717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 | |
calculate(evaluation_input)
Calculate accuracy score.
Source code in uaef/metrics/response_quality.py
746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 | |
calculate_async(evaluation_input)
async
Calculate accuracy asynchronously.
Source code in uaef/metrics/response_quality.py
864 865 866 | |
get_description()
Get metric description.
Source code in uaef/metrics/response_quality.py
738 739 740 | |
get_dimension()
Get metric dimension.
Source code in uaef/metrics/response_quality.py
742 743 744 | |
get_name()
Get metric name.
Source code in uaef/metrics/response_quality.py
726 727 728 | |
requires_ground_truth()
This metric requires ground truth.
Source code in uaef/metrics/response_quality.py
730 731 732 | |
requires_llm_judge()
This metric uses LLM judge for evaluation.
Source code in uaef/metrics/response_quality.py
734 735 736 | |
AnswerRelevanceMetric
Bases: BaseMetric
Metric for evaluating answer relevance using LLM judge.
Evaluates if the response is relevant to the question without requiring ground truth. Reuses llm_as_judge_score_answer_relevancy from evaluation.py (lines 462-551).
Source code in uaef/metrics/response_quality.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | |
calculate(evaluation_input)
Calculate answer relevance synchronously.
Note: This is a blocking call. Use calculate_async for non-blocking evaluation.
Source code in uaef/metrics/response_quality.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | |
calculate_async(evaluation_input)
async
Calculate answer relevance asynchronously.
Source code in uaef/metrics/response_quality.py
160 161 162 163 164 | |
get_description()
Get metric description.
Source code in uaef/metrics/response_quality.py
53 54 55 | |
get_dimension()
Get metric dimension.
Source code in uaef/metrics/response_quality.py
57 58 59 | |
get_name()
Get metric name.
Source code in uaef/metrics/response_quality.py
41 42 43 | |
requires_ground_truth()
This metric does not require ground truth.
Source code in uaef/metrics/response_quality.py
45 46 47 | |
requires_llm_judge()
This metric requires LLM judge.
Source code in uaef/metrics/response_quality.py
49 50 51 | |
CompletenessMetric
Bases: BaseMetric
Metric for evaluating response completeness against ground truth.
Compares the response against expected output to identify missing information. Requires ground truth for comparison.
Source code in uaef/metrics/response_quality.py
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 | |
calculate(evaluation_input)
Calculate completeness score.
Source code in uaef/metrics/response_quality.py
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 | |
calculate_async(evaluation_input)
async
Calculate completeness asynchronously.
Source code in uaef/metrics/response_quality.py
399 400 401 | |
get_description()
Get metric description.
Source code in uaef/metrics/response_quality.py
302 303 304 | |
get_dimension()
Get metric dimension.
Source code in uaef/metrics/response_quality.py
306 307 308 | |
get_name()
Get metric name.
Source code in uaef/metrics/response_quality.py
290 291 292 | |
requires_ground_truth()
This metric requires ground truth.
Source code in uaef/metrics/response_quality.py
294 295 296 | |
requires_llm_judge()
This metric uses LLM judge for evaluation.
Source code in uaef/metrics/response_quality.py
298 299 300 | |
HallucinationScoreMetric
Bases: BaseMetric
Metric for detecting hallucinations in agent responses.
Validates that claims in the response are supported by the provided context. Does not require ground truth, uses context documents for validation.
Source code in uaef/metrics/response_quality.py
506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 | |
calculate(evaluation_input)
Calculate hallucination score.
Source code in uaef/metrics/response_quality.py
534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 | |
calculate_async(evaluation_input)
async
Calculate hallucination score asynchronously.
Source code in uaef/metrics/response_quality.py
615 616 617 | |
get_description()
Get metric description.
Source code in uaef/metrics/response_quality.py
526 527 528 | |
get_dimension()
Get metric dimension.
Source code in uaef/metrics/response_quality.py
530 531 532 | |
get_name()
Get metric name.
Source code in uaef/metrics/response_quality.py
514 515 516 | |
requires_ground_truth()
This metric does not require ground truth.
Source code in uaef/metrics/response_quality.py
518 519 520 | |
requires_llm_judge()
This metric uses LLM judge for evaluation.
Source code in uaef/metrics/response_quality.py
522 523 524 | |
uaef.metrics.responsible_ai
Responsible AI metrics for UAEF.
This module implements metrics for evaluating agent safety, bias, toxicity, and prompt injection detection.
BiasScoreMetric
Bases: BaseMetric
Metric for detecting bias in agent responses using LLM judge.
Identifies potentially biased language or unfair treatment based on protected characteristics.
Source code in uaef/metrics/responsible_ai.py
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 | |
calculate(evaluation_input)
Calculate bias score.
Source code in uaef/metrics/responsible_ai.py
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 | |
calculate_async(evaluation_input)
async
Calculate bias score asynchronously.
Source code in uaef/metrics/responsible_ai.py
322 323 324 | |
get_description()
Get metric description.
Source code in uaef/metrics/responsible_ai.py
244 245 246 | |
get_dimension()
Get metric dimension.
Source code in uaef/metrics/responsible_ai.py
248 249 250 | |
get_name()
Get metric name.
Source code in uaef/metrics/responsible_ai.py
232 233 234 | |
requires_ground_truth()
This metric does not require ground truth.
Source code in uaef/metrics/responsible_ai.py
236 237 238 | |
requires_llm_judge()
This metric requires LLM judge.
Source code in uaef/metrics/responsible_ai.py
240 241 242 | |
PromptInjectionDetectionMetric
Bases: BaseMetric
Metric for detecting prompt injection attempts using rule-based detection.
Identifies attempts to manipulate the agent through malicious inputs. This is a deterministic metric using pattern matching.
Source code in uaef/metrics/responsible_ai.py
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 | |
calculate(evaluation_input)
Calculate prompt injection detection score.
Source code in uaef/metrics/responsible_ai.py
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 | |
calculate_async(evaluation_input)
async
Async version (just calls synchronous version for deterministic metric).
Source code in uaef/metrics/responsible_ai.py
511 512 513 | |
get_description()
Get metric description.
Source code in uaef/metrics/responsible_ai.py
438 439 440 | |
get_dimension()
Get metric dimension.
Source code in uaef/metrics/responsible_ai.py
442 443 444 | |
get_name()
Get metric name.
Source code in uaef/metrics/responsible_ai.py
426 427 428 | |
requires_ground_truth()
This metric does not require ground truth.
Source code in uaef/metrics/responsible_ai.py
430 431 432 | |
requires_llm_judge()
This metric does not require LLM judge.
Source code in uaef/metrics/responsible_ai.py
434 435 436 | |
SafetyScoreMetric
Bases: BaseMetric
Metric for evaluating response safety using LLM judge.
Detects harmful, offensive, or inappropriate content in agent responses. Uses LLM judge to evaluate safety concerns.
Source code in uaef/metrics/responsible_ai.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | |
calculate(evaluation_input)
Calculate safety score.
Source code in uaef/metrics/responsible_ai.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
calculate_async(evaluation_input)
async
Calculate safety score asynchronously.
Source code in uaef/metrics/responsible_ai.py
128 129 130 | |
get_description()
Get metric description.
Source code in uaef/metrics/responsible_ai.py
50 51 52 | |
get_dimension()
Get metric dimension.
Source code in uaef/metrics/responsible_ai.py
54 55 56 | |
get_name()
Get metric name.
Source code in uaef/metrics/responsible_ai.py
38 39 40 | |
requires_ground_truth()
This metric does not require ground truth.
Source code in uaef/metrics/responsible_ai.py
42 43 44 | |
requires_llm_judge()
This metric requires LLM judge.
Source code in uaef/metrics/responsible_ai.py
46 47 48 | |
ToxicityScoreMetric
Bases: BaseMetric
Metric for evaluating response toxicity using LLM judge.
Detects toxic, rude, or disrespectful language in agent responses.
Source code in uaef/metrics/responsible_ai.py
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 | |
calculate(evaluation_input)
Calculate toxicity score.
Source code in uaef/metrics/responsible_ai.py
543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 | |
calculate_async(evaluation_input)
async
Calculate toxicity score asynchronously.
Source code in uaef/metrics/responsible_ai.py
613 614 615 | |
get_description()
Get metric description.
Source code in uaef/metrics/responsible_ai.py
535 536 537 | |
get_dimension()
Get metric dimension.
Source code in uaef/metrics/responsible_ai.py
539 540 541 | |
get_name()
Get metric name.
Source code in uaef/metrics/responsible_ai.py
523 524 525 | |
requires_ground_truth()
This metric does not require ground truth.
Source code in uaef/metrics/responsible_ai.py
527 528 529 | |
requires_llm_judge()
This metric requires LLM judge.
Source code in uaef/metrics/responsible_ai.py
531 532 533 | |
uaef.metrics.performance
Performance metrics for UAEF.
This module implements metrics for evaluating agent performance including latency, token efficiency, cost efficiency, and throughput.
All metrics in this module are deterministic and do not require LLM judge.
CostEfficiencyMetric
Bases: BaseMetric
Metric for evaluating cost efficiency (quality per dollar).
Calculates efficiency based on quality score and cost. REQUIRES quality_score to be provided via trace.metadata.
Formula: - If cost <= expected: efficiency = quality (flat, no penalty) - If cost > expected: efficiency = quality / (ratio ** penalty_exponent) where ratio = actual_cost / expected_cost
This is a deterministic metric.
Source code in uaef/metrics/performance.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | |
calculate(evaluation_input)
Calculate cost efficiency.
Source code in uaef/metrics/performance.py
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 | |
calculate_async(evaluation_input)
async
Async version (just calls synchronous version for deterministic metric).
Source code in uaef/metrics/performance.py
335 336 337 | |
get_dependencies()
Get metric dependencies.
Source code in uaef/metrics/performance.py
269 270 271 272 273 274 | |
get_description()
Get metric description.
Source code in uaef/metrics/performance.py
261 262 263 | |
get_dimension()
Get metric dimension.
Source code in uaef/metrics/performance.py
265 266 267 | |
get_name()
Get metric name.
Source code in uaef/metrics/performance.py
249 250 251 | |
requires_ground_truth()
This metric does not require ground truth.
Source code in uaef/metrics/performance.py
253 254 255 | |
requires_llm_judge()
This metric does not require LLM judge.
Source code in uaef/metrics/performance.py
257 258 259 | |
LatencyScoreMetric
Bases: BaseMetric
Metric for evaluating agent latency using threshold-based scoring.
Scores based on how quickly the agent responds. Lower latency = higher score. This is a deterministic metric that doesn't require ground truth or LLM judge.
Source code in uaef/metrics/performance.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |
calculate(evaluation_input)
Calculate latency score.
Source code in uaef/metrics/performance.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
calculate_async(evaluation_input)
async
Async version (just calls synchronous version for deterministic metric).
Source code in uaef/metrics/performance.py
108 109 110 | |
get_description()
Get metric description.
Source code in uaef/metrics/performance.py
49 50 51 | |
get_dimension()
Get metric dimension.
Source code in uaef/metrics/performance.py
53 54 55 | |
get_name()
Get metric name.
Source code in uaef/metrics/performance.py
37 38 39 | |
requires_ground_truth()
This metric does not require ground truth.
Source code in uaef/metrics/performance.py
41 42 43 | |
requires_llm_judge()
This metric does not require LLM judge.
Source code in uaef/metrics/performance.py
45 46 47 | |
ThroughputMetric
Bases: BaseMetric
Metric for evaluating agent throughput (requests per second).
Measures how many requests the agent can handle per unit time. This is typically calculated at the batch level rather than per-request. This is a deterministic metric.
Source code in uaef/metrics/performance.py
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 | |
calculate(evaluation_input)
Calculate throughput.
Source code in uaef/metrics/performance.py
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 | |
calculate_async(evaluation_input)
async
Async version (just calls synchronous version for deterministic metric).
Source code in uaef/metrics/performance.py
417 418 419 | |
get_description()
Get metric description.
Source code in uaef/metrics/performance.py
361 362 363 | |
get_dimension()
Get metric dimension.
Source code in uaef/metrics/performance.py
365 366 367 | |
get_name()
Get metric name.
Source code in uaef/metrics/performance.py
349 350 351 | |
requires_ground_truth()
This metric does not require ground truth.
Source code in uaef/metrics/performance.py
353 354 355 | |
requires_llm_judge()
This metric does not require LLM judge.
Source code in uaef/metrics/performance.py
357 358 359 | |
TokenEfficiencyMetric
Bases: BaseMetric
Metric for evaluating token efficiency (quality per token).
Calculates efficiency based on quality score and token usage. REQUIRES quality_score to be provided via trace.metadata.
Formula: - If tokens <= expected: efficiency = quality (flat, no penalty) - If tokens > expected: efficiency = quality / (ratio ** penalty_exponent) where ratio = actual_tokens / expected_tokens
This is a deterministic metric.
Source code in uaef/metrics/performance.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | |
calculate(evaluation_input)
Calculate token efficiency.
Source code in uaef/metrics/performance.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | |
calculate_async(evaluation_input)
async
Async version (just calls synchronous version for deterministic metric).
Source code in uaef/metrics/performance.py
217 218 219 | |
get_description()
Get metric description.
Source code in uaef/metrics/performance.py
152 153 154 | |
get_dimension()
Get metric dimension.
Source code in uaef/metrics/performance.py
156 157 158 | |
get_name()
Get metric name.
Source code in uaef/metrics/performance.py
140 141 142 | |
requires_ground_truth()
This metric does not require ground truth.
Source code in uaef/metrics/performance.py
144 145 146 | |
requires_llm_judge()
This metric does not require LLM judge.
Source code in uaef/metrics/performance.py
148 149 150 | |
uaef.metrics.multi_turn
Multi-turn conversation metrics for UAEF.
This module implements metrics for evaluating multi-turn conversations including context retention, coherence, conversation completeness, turn efficiency, plus additional customer-service-flavored LLM-judge metrics ported from the AMACE Conversation Evaluator (role adherence, holistic LLM judge, user satisfaction, sentiment, agent tone, naturalness, instruction compliance, optimum turns).
Per-turn variants of sentiment / agent_tone / naturalness — per_turn_sentiment,
per_turn_agent_tone, per_turn_naturalness — score each user→assistant
exchange independently and aggregate by mean. They sit alongside the full-trace
versions; users opt in by metric name.
AgentToneMetric
Bases: _AMACEFullTraceMetric
Evaluates the agent's tone on a 1-5 professionalism scale (super unprofessional → super professional). Normalized to 0-1.
Source code in uaef/metrics/multi_turn.py
1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 | |
CoherenceMetric
Bases: BaseMetric
Metric for evaluating conversation coherence and logical flow.
Evaluates whether the conversation flows logically and maintains coherence across turns. Uses LLM judge to assess logical consistency.
Source code in uaef/metrics/multi_turn.py
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 | |
ContextRetentionMetric
Bases: BaseMetric
Metric for evaluating context retention across conversation turns.
Evaluates whether the agent maintains and uses information from earlier turns in later responses. Uses LLM judge to assess context carryover.
Source code in uaef/metrics/multi_turn.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | |
ConversationCompletenessMetric
Bases: BaseMetric
Metric for evaluating conversation completeness (goal achievement).
Evaluates whether the user's goal was achieved by the end of the conversation. Optionally uses ground-truth success criteria; if absent, the judge extracts the user's intentions from the conversation itself.
Source code in uaef/metrics/multi_turn.py
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 | |
HolisticLLMJudgeMetric
Bases: _AMACEFullTraceMetric
Composite multi-factor LLM judge ported from AMACE's LLMJudgeScore.
Evaluates the conversation across completeness, relevancy, knowledge retention, sentiment, tone, satisfaction, and containment, weighting containment more heavily. Returns a single 0-1 quality score.
Source code in uaef/metrics/multi_turn.py
1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 | |
InstructionComplianceMetric
Bases: _AMACEFullTraceMetric
Evaluates whether the agent complied with the original system prompt / instructions across the conversation. Returns a 0-1 score.
Reads the instruction text from
GroundTruth.expected_arguments['system_instructions'] (preferred) or
falls back to GroundTruth.expected_output.
Source code in uaef/metrics/multi_turn.py
1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 | |
NaturalnessMetric
Bases: _AMACEFullTraceMetric
Evaluates how natural and human-like the agent's responses sound across the conversation, on a 1-5 scale (1 = robotic / unnatural, 5 = natural / human-like). Normalized to 0-1.
Source code in uaef/metrics/multi_turn.py
1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 | |
OptimumTurnsMetric
Bases: _AMACEFullTraceMetric
LLM-estimated optimum-turn-count efficiency.
Asks the judge to estimate the optimum number of turns this conversation should have taken, then computes a 0-1 efficiency score:
score = min(1.0, optimum / actual)
The raw integer optimum count is preserved in metadata['optimum_turns'].
Source code in uaef/metrics/multi_turn.py
1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 | |
PerTurnAgentToneMetric
Bases: _AMACEPerTurnMetric
Agent tone per user→assistant exchange (1–5 normalized to 0–1).
See AgentToneMetric for the full-trace counterpart. Per-turn scores
are independent: each judge call sees exactly one exchange, with no
cross-turn context.
Source code in uaef/metrics/multi_turn.py
984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 | |
PerTurnNaturalnessMetric
Bases: _AMACEPerTurnMetric
Agent naturalness per user→assistant exchange (1–5 normalized to 0–1).
See NaturalnessMetric for the full-trace counterpart. Per-turn scores
are independent: each judge call sees exactly one exchange, with no
cross-turn context.
Source code in uaef/metrics/multi_turn.py
1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 | |
PerTurnSentimentMetric
Bases: _AMACEPerTurnMetric
User sentiment per user→assistant exchange (1–5 normalized to 0–1).
See SentimentMetric for the full-trace counterpart. Per-turn scores
are independent: each judge call sees exactly one exchange, with no
cross-turn context.
Source code in uaef/metrics/multi_turn.py
937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 | |
RoleAdherenceMetric
Bases: _AMACEFullTraceMetric
Metric for evaluating chatbot role adherence across the conversation.
Computes the ratio of turns whose assistant response stayed in-role versus
drifting away from the persona / system message. Requires the chatbot's
role/persona via GroundTruth.expected_arguments['chatbot_role'].
Source code in uaef/metrics/multi_turn.py
1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 | |
SentimentMetric
Bases: _AMACEFullTraceMetric
Estimates the user's sentiment across the conversation on a 1-5 scale, weighting later interactions more heavily. Normalizes to 0-1.
Source code in uaef/metrics/multi_turn.py
1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 | |
TurnEfficiencyMetric
Bases: BaseMetric
Metric for evaluating turn efficiency (how quickly goal is achieved).
Deterministic — incorporates a completeness signal from trace metadata when available so unfinished conversations are penalized.
Source code in uaef/metrics/multi_turn.py
513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 | |
UserSatisfactionMetric
Bases: _AMACEFullTraceMetric
Metric estimating end-of-conversation user satisfaction on a 1-5 scale, normalized to 0-1 with the raw value preserved in metadata.
Source code in uaef/metrics/multi_turn.py
1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 | |
uaef.metrics.multi_agent
Multi-agent coordination metrics for UAEF.
This module implements metrics for evaluating multi-agent coordination including agent utilization, delegation quality, workflow completion, and coordination efficiency.
AgentUtilizationMetric
Bases: BaseMetric
Metric for evaluating agent utilization (workload distribution).
Measures how evenly work is distributed across agents. Identifies underutilized or overutilized agents. This is a deterministic metric.
Source code in uaef/metrics/multi_agent.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | |
calculate(evaluation_input)
Calculate agent utilization score.
Source code in uaef/metrics/multi_agent.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
calculate_async(evaluation_input)
async
Async version (just calls synchronous version for deterministic metric).
Source code in uaef/metrics/multi_agent.py
146 147 148 | |
calculate_batch(evaluation_inputs)
staticmethod
Calculate agent utilization across a batch of multi-agent traces.
Batch calculation is more meaningful than single-trace calculation because: - Some tasks naturally require more agents, some require fewer - Single-trace utilization depends heavily on task complexity - Batch metrics show overall agent usage patterns across diverse tasks
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
evaluation_inputs
|
List[EvaluationInput]
|
List of evaluation inputs with multi_agent_traces |
required |
Returns:
| Type | Description |
|---|---|
MetricScore
|
MetricScore with batch-level agent utilization across all traces |
Source code in uaef/metrics/multi_agent.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | |
get_description()
Get metric description.
Source code in uaef/metrics/multi_agent.py
50 51 52 | |
get_dimension()
Get metric dimension.
Source code in uaef/metrics/multi_agent.py
54 55 56 | |
get_name()
Get metric name.
Source code in uaef/metrics/multi_agent.py
38 39 40 | |
requires_ground_truth()
This metric does not require ground truth.
Source code in uaef/metrics/multi_agent.py
42 43 44 | |
requires_llm_judge()
This metric does not require LLM judge.
Source code in uaef/metrics/multi_agent.py
46 47 48 | |
CoordinationEfficiencyMetric
Bases: BaseMetric
Metric for evaluating coordination efficiency.
Measures the efficiency of agent coordination based on the number of coordination events relative to work completed. This is a deterministic metric.
Ideal ratios by workflow type: - Hierarchical: 0.05 (centralized orchestrator, minimal coordination) - Balanced: 0.10 (default, moderate coordination) - Collaborative: 0.20 (peer-to-peer, more coordination) - Sequential: 0.25 (many handoffs between agents)
Source code in uaef/metrics/multi_agent.py
748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 | |
calculate(evaluation_input)
Calculate coordination efficiency score.
Source code in uaef/metrics/multi_agent.py
792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 | |
calculate_async(evaluation_input)
async
Async version (just calls synchronous version for deterministic metric).
Source code in uaef/metrics/multi_agent.py
852 853 854 | |
get_description()
Get metric description.
Source code in uaef/metrics/multi_agent.py
784 785 786 | |
get_dimension()
Get metric dimension.
Source code in uaef/metrics/multi_agent.py
788 789 790 | |
get_name()
Get metric name.
Source code in uaef/metrics/multi_agent.py
772 773 774 | |
requires_ground_truth()
This metric does not require ground truth.
Source code in uaef/metrics/multi_agent.py
776 777 778 | |
requires_llm_judge()
This metric does not require LLM judge.
Source code in uaef/metrics/multi_agent.py
780 781 782 | |
DelegationQualityMetric
Bases: BaseMetric
Metric for evaluating delegation quality (task assignment appropriateness).
Evaluates whether tasks were assigned to appropriate agents based on their capabilities. Uses LLM judge to assess delegation decisions.
Source code in uaef/metrics/multi_agent.py
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 | |
calculate(evaluation_input)
Calculate delegation quality score.
Source code in uaef/metrics/multi_agent.py
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 | |
calculate_async(evaluation_input)
async
Calculate delegation quality asynchronously.
Source code in uaef/metrics/multi_agent.py
374 375 376 | |
get_description()
Get metric description.
Source code in uaef/metrics/multi_agent.py
269 270 271 | |
get_dimension()
Get metric dimension.
Source code in uaef/metrics/multi_agent.py
273 274 275 | |
get_name()
Get metric name.
Source code in uaef/metrics/multi_agent.py
257 258 259 | |
requires_ground_truth()
This metric does not require ground truth.
Source code in uaef/metrics/multi_agent.py
261 262 263 | |
requires_llm_judge()
This metric requires LLM judge.
Source code in uaef/metrics/multi_agent.py
265 266 267 | |
WorkflowCompletionMetric
Bases: BaseMetric
Metric for evaluating workflow completion (overall goal achievement).
Evaluates whether the overall multi-agent workflow achieved its goal. Requires ground truth with success criteria.
Source code in uaef/metrics/multi_agent.py
500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 | |
calculate(evaluation_input)
Calculate workflow completion score.
Source code in uaef/metrics/multi_agent.py
528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 | |
calculate_async(evaluation_input)
async
Calculate workflow completion asynchronously.
Source code in uaef/metrics/multi_agent.py
641 642 643 | |
get_description()
Get metric description.
Source code in uaef/metrics/multi_agent.py
520 521 522 | |
get_dimension()
Get metric dimension.
Source code in uaef/metrics/multi_agent.py
524 525 526 | |
get_name()
Get metric name.
Source code in uaef/metrics/multi_agent.py
508 509 510 | |
requires_ground_truth()
This metric requires ground truth.
Source code in uaef/metrics/multi_agent.py
512 513 514 | |
requires_llm_judge()
This metric uses LLM judge for evaluation.
Source code in uaef/metrics/multi_agent.py
516 517 518 | |
uaef.metrics.reasoning
Reasoning quality metrics for UAEF.
This module implements metrics for evaluating agent reasoning quality including chain-of-thought coherence, logical consistency, reasoning step correctness, and fallacy detection.
ChainOfThoughtCoherenceMetric
Bases: BaseMetric
Metric for evaluating chain-of-thought reasoning coherence.
Evaluates whether the agent's reasoning flows logically from one step to the next. Uses LLM judge to assess reasoning flow.
Source code in uaef/metrics/reasoning.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | |
calculate(evaluation_input)
Calculate chain-of-thought coherence score.
Source code in uaef/metrics/reasoning.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |
calculate_async(evaluation_input)
async
Calculate chain-of-thought coherence asynchronously.
Source code in uaef/metrics/reasoning.py
144 145 146 | |
get_description()
Get metric description.
Source code in uaef/metrics/reasoning.py
79 80 81 | |
get_dimension()
Get metric dimension.
Source code in uaef/metrics/reasoning.py
83 84 85 | |
get_name()
Get metric name.
Source code in uaef/metrics/reasoning.py
67 68 69 | |
requires_ground_truth()
This metric does not require ground truth.
Source code in uaef/metrics/reasoning.py
71 72 73 | |
requires_llm_judge()
This metric requires LLM judge.
Source code in uaef/metrics/reasoning.py
75 76 77 | |
FallacyDetectionMetric
Bases: BaseMetric
Metric for detecting logical fallacies in agent reasoning.
Identifies common logical fallacies such as ad hominem, straw man, false dichotomy, etc. Uses LLM judge to detect fallacies.
Source code in uaef/metrics/reasoning.py
594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 | |
calculate(evaluation_input)
Calculate fallacy detection score.
Source code in uaef/metrics/reasoning.py
622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 | |
calculate_async(evaluation_input)
async
Calculate fallacy detection asynchronously.
Source code in uaef/metrics/reasoning.py
658 659 660 | |
get_description()
Get metric description.
Source code in uaef/metrics/reasoning.py
614 615 616 | |
get_dimension()
Get metric dimension.
Source code in uaef/metrics/reasoning.py
618 619 620 | |
get_name()
Get metric name.
Source code in uaef/metrics/reasoning.py
602 603 604 | |
requires_ground_truth()
This metric does not require ground truth.
Source code in uaef/metrics/reasoning.py
606 607 608 | |
requires_llm_judge()
This metric requires LLM judge.
Source code in uaef/metrics/reasoning.py
610 611 612 | |
LogicalConsistencyMetric
Bases: BaseMetric
Metric for detecting logical contradictions in agent reasoning.
Evaluates whether the agent's reasoning contains contradictions or inconsistencies. Uses LLM judge to detect logical issues.
Source code in uaef/metrics/reasoning.py
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 | |
calculate(evaluation_input)
Calculate logical consistency score.
Source code in uaef/metrics/reasoning.py
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | |
calculate_async(evaluation_input)
async
Calculate logical consistency asynchronously.
Source code in uaef/metrics/reasoning.py
311 312 313 | |
get_description()
Get metric description.
Source code in uaef/metrics/reasoning.py
267 268 269 | |
get_dimension()
Get metric dimension.
Source code in uaef/metrics/reasoning.py
271 272 273 | |
get_name()
Get metric name.
Source code in uaef/metrics/reasoning.py
255 256 257 | |
requires_ground_truth()
This metric does not require ground truth.
Source code in uaef/metrics/reasoning.py
259 260 261 | |
requires_llm_judge()
This metric requires LLM judge.
Source code in uaef/metrics/reasoning.py
263 264 265 | |
ReasoningStepCorrectnessMetric
Bases: BaseMetric
Metric for validating correctness of individual reasoning steps.
Evaluates whether each reasoning step is logically sound and correct. Uses LLM judge to validate reasoning steps.
Source code in uaef/metrics/reasoning.py
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 | |
calculate(evaluation_input)
Calculate reasoning step correctness score.
Source code in uaef/metrics/reasoning.py
441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 | |
calculate_async(evaluation_input)
async
Calculate reasoning step correctness asynchronously.
Source code in uaef/metrics/reasoning.py
481 482 483 | |
get_description()
Get metric description.
Source code in uaef/metrics/reasoning.py
433 434 435 | |
get_dimension()
Get metric dimension.
Source code in uaef/metrics/reasoning.py
437 438 439 | |
get_name()
Get metric name.
Source code in uaef/metrics/reasoning.py
421 422 423 | |
requires_ground_truth()
This metric does not require ground truth.
Source code in uaef/metrics/reasoning.py
425 426 427 | |
requires_llm_judge()
This metric requires LLM judge.
Source code in uaef/metrics/reasoning.py
429 430 431 | |
uaef.metrics.use_case_specific
Use-case-specific evaluation metrics.
This module hosts metrics whose semantics only apply to specific agent use cases (currently: customer-service / contact-center agents). They are NOT included in the default registry — UAEF is a general-purpose agent evaluation framework and metrics like "did the agent escalate to a human?" or "was the customer's issue resolved?" are meaningless for, e.g., a coding assistant or an internal data-pipeline agent.
To opt in, call register_use_case_specific_metrics() once at startup:
from uaef.metrics.registry import register_use_case_specific_metrics
register_use_case_specific_metrics()
# "containment" and "resolution" are now selectable by name:
result = evaluate(trace, metrics=["containment", "resolution"])
The classes themselves remain importable directly for advanced users who
want to register them manually via register_metric(MetricCls).
ContainmentMetric
Bases: _AMACEFullTraceMetric
Boolean: was the conversation handled by the chatbot without escalating or redirecting to a human agent? Returns 1.0 (contained) or 0.0 (not).
Source code in uaef/metrics/use_case_specific.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
ResolutionMetric
Bases: _AMACEFullTraceMetric
Boolean: was the customer's issue resolved by the end of the conversation? Returns 1.0 (resolved) or 0.0 (unresolved).
Source code in uaef/metrics/use_case_specific.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
uaef.metrics.ragas_metrics
RAGAS integration metrics for UAEF metric registry.
Wraps RAGAS connector methods as BaseMetric subclasses so they can be registered in the MetricRegistry alongside built-in metrics.
To add a new RAGAS metric: 1. Create a subclass with _ragas_import, _ragas_result_key, and optional _requires_context / _requires_ground_truth_output / _uses_multi_turn. 2. Implement get_name(), requires_ground_truth(), requires_llm_judge(), calculate(). 3. Add batch_group() and batch_calculate() (copy from existing classes). The metric will automatically participate in batched evaluation.
uaef.metrics.deepeval_metrics
DeepEval integration metrics for UAEF metric registry.
Wraps DeepEval connector methods as BaseMetric subclasses so they can be registered in the MetricRegistry alongside built-in metrics.
uaef.metrics.utils
Shared utilities for UAEF metrics.
build_claude_judge_body(*, system_prompt, user_message, max_tokens, temperature, stop_sequences=None)
Build a Bedrock Anthropic Claude Messages API request body (JSON string).
Security review H-01: this is the one place that assembles the system /
messages split every judge call site now uses, so the split is applied
uniformly rather than risking a per-site copy/paste drifting back to a
single concatenated prompt. Every metric module still owns its own
boto3 client and invoke_model call (they differ slightly in client
construction across modules) — this only builds the request body.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
system_prompt
|
str
|
The rubric/instructions (see
build_judge_system_prompt). Goes in Bedrock's |
required |
user_message
|
str
|
The untrusted content, already wrapped (see
wrap_untrusted) — goes in the single |
required |
max_tokens
|
int
|
Passed through to the request body. |
required |
temperature
|
float
|
Passed through to the request body. Claude 3+ rejects a request specifying both temperature and top_p; every call site in this codebase uses temperature alone for deterministic judge scoring, so top_p is intentionally not a parameter here. |
required |
stop_sequences
|
Optional[list]
|
Defaults to |
None
|
Returns:
| Type | Description |
|---|---|
str
|
A JSON string suitable for |
Source code in uaef/metrics/utils.py
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | |
build_judge_system_prompt(rubric)
Build the Bedrock system field for a judge call from a rubric.
Security review H-01: the rubric — the fixed instructions describing what
to evaluate and how to score it — belongs in the system field, not
concatenated into the same user turn as the untrusted content being
evaluated. This is the Anthropic-documented pattern for separating
trusted instructions from untrusted data in a single request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rubric
|
str
|
The metric's evaluation instructions (criteria, scoring scale, output format). Must NOT contain any untrusted content — only fixed, deployer/developer-authored instruction text. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The rubric with the injection-defense instruction appended. |
Source code in uaef/metrics/utils.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |
build_provenance_instruction(field=PROVENANCE_FIELD)
Build the rubric fragment requiring a provenance-bound evidence quote.
Security review H-01 (follow-up): boundary tags and a system-field rubric
reduce the chance a judge follows injected instructions, but nothing so
far detects it when one does — a judge steered into {"score": 1.0,
"reasoning": "excellent"} returns perfectly well-formed JSON. Requiring
the judge to quote the span of candidate content its score rests on, and
then verifying that span actually occurs in the candidate
(validate_provenance), binds the score to the real content: a score
argued for by injected instructions rather than by the response's own
substance generally cannot produce a matching quote, and is rejected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
Response field name to request. Defaults to
:data: |
PROVENANCE_FIELD
|
Returns:
| Type | Description |
|---|---|
str
|
Instruction text to append to a judge rubric. Callers must also add |
str
|
|
Source code in uaef/metrics/utils.py
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | |
escape_untrusted_boundaries(text)
Neutralize boundary-delimiter-shaped text inside untrusted content.
Security review H-01 (follow-up): wrapping untrusted content in
<candidate_response>...</candidate_response> only establishes a trust
boundary if the content cannot contain the delimiter itself. An evaluated
agent that emits a literal </candidate_response> closes the data
region early, and everything it writes after that point is read by the
judge as ordinary prompt text — i.e. as instructions — which defeats the
boundary entirely. This escapes the delimiter's angle brackets to HTML
entities so any such token in the content is inert: still fully legible
to the judge (nothing is dropped or truncated, so no evaluation signal is
lost), but no longer parseable as the boundary.
Only boundary-shaped tags are escaped, deliberately: escaping every <
and > would corrupt legitimate candidate content that this framework
routinely has to score verbatim (HTML, XML, generics-heavy code, tool-call
JSON), which would change the very text the metric is judging. Narrow
escaping is sufficient here because the delimiter is always a fixed,
candidate-prefixed tag name chosen by this code, never by the agent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
Any
|
The untrusted content. Coerced to |
required |
Returns:
| Type | Description |
|---|---|
str
|
The content with every boundary-delimiter-shaped tag's angle brackets |
str
|
replaced by |
Source code in uaef/metrics/utils.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
extract_json_from_llm_response(text)
Extract and parse JSON from LLM response text.
Handles markdown code blocks, preamble/trailing text, and nested objects. Tries progressively looser strategies in order: 1. Direct parse 2. JSON inside a markdown code fence 3. Balanced-brace extraction (handles nested {}) 4. Greedy regex fallback
Each strategy parses strictly (see loads_judge_json) — the leniency here is about locating the JSON in a chatty response, not about accepting malformed JSON once located.
Source code in uaef/metrics/utils.py
434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 | |
loads_judge_json(text)
Strictly parse a JSON judge response, normalizing raw control chars.
Security review H-01 (follow-up): parses with strict=True so a
response cannot rely on a permissive parser's handling of control
characters. Raw control characters inside strings — the one benign case
strict=False existed for — are escaped first
(_escape_control_chars_in_json_strings) and the result re-parsed strictly,
so well-behaved responses are unaffected while the parser itself stays
strict.
Raises:
| Type | Description |
|---|---|
JSONDecodeError
|
If the text is not strictly valid JSON even after control-character normalization. |
Source code in uaef/metrics/utils.py
411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 | |
validate_judge_response(parsed, *, score_key='score', reasoning_key='reasoning', allow_keys=None, score_range=(0.0, 1.0), allow_null_score=False)
Validate a parsed judge response has the expected shape.
Security review M-05 (lenient judge-response parsing): every metric's own
ad hoc check after extract_json_from_llm_response amounted to
response_json["score"] (a bare bracket access — raises KeyError on a
missing key, and doesn't check the value is even numeric before it's
later compared/cast) followed by a range check. This centralizes and
strengthens that into one explicit contract, applied at every call site
instead of ~14 slightly different inline versions — parameterized rather
than hardcoded, because the judge-response contract genuinely varies by
metric: most prompts request lowercase {"score": <float 0-1>,
"reasoning": <str>}, but multi_turn.py's AMACE per-turn metrics accept
either score/reasoning or capitalized Score/Reason on a
1-5 raw scale (normalized to 0-1 downstream), and its context-retention
metric explicitly documents null as a valid "not applicable" score in
its own prompt. Forcing one rigid shape onto every call site would reject
those legitimate, documented responses — so the shape is a parameter,
not an assumption.
This validates the parsed result: once the JSON has been located in a possibly-chatty response and parsed strictly (see loads_judge_json — the remaining leniency in extract_json_from_llm_response is about finding the JSON object in the surrounding prose, not about accepting malformed JSON), its shape and types must match the judge-response contract exactly, or it's rejected.
Note: this validates structure only. On its own it cannot detect a judge that was manipulated (e.g. via prompt injection in the evaluated agent's response — see security review H-01) into deliberately emitting a well-formed {"score": 1.0, "reasoning": "..."} with a value it was steered into producing. Two separate mechanisms cover that: the prompt-level boundary (build_judge_system_prompt / wrap_untrusted) makes the judge far less likely to follow injected instructions, and provenance binding (build_provenance_instruction / validate_provenance) rejects a score whose cited evidence does not occur in the candidate content.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parsed
|
Any
|
The dict returned by extract_json_from_llm_response. |
required |
score_key
|
str | list[str]
|
Field name(s) holding the score. Defaults to "score". Pass
a list (e.g. |
'score'
|
reasoning_key
|
str | list[str]
|
Field name(s) holding the reasoning text. Defaults to
"reasoning". Accepts a list the same way as |
'reasoning'
|
allow_keys
|
Optional[set]
|
Field names permitted in the response. Defaults to every
name in |
None
|
score_range
|
tuple
|
|
(0.0, 1.0)
|
allow_null_score
|
bool
|
If True, a |
False
|
Returns:
| Type | Description |
|---|---|
dict
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in uaef/metrics/utils.py
503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 | |
validate_provenance(parsed, candidate_text, *, field=PROVENANCE_FIELD, min_chars=_PROVENANCE_MIN_CHARS)
Verify a judge's evidence quote really occurs in the candidate content.
Security review H-01 (follow-up): see build_provenance_instruction for why. Comparison is whitespace- and case-insensitive (a model reflowing or re-casing a quoted span is a formatting artifact, not evidence of fabrication), and is made against the escaped candidate content — escape_untrusted_boundaries output — since that is the text the judge was actually shown.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parsed
|
dict
|
The validated judge response dict. |
required |
candidate_text
|
Any
|
The untrusted content that was wrapped into the prompt, pre-escaping. Pass exactly what was handed to wrap_untrusted. |
required |
field
|
str
|
Response field holding the quote. Defaults to
:data: |
PROVENANCE_FIELD
|
min_chars
|
int
|
Minimum quote length. A candidate shorter than this only needs to be quoted in full, so short-but-legitimate candidates ("Yes.") are not rejected. |
_PROVENANCE_MIN_CHARS
|
Returns:
| Type | Description |
|---|---|
dict
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the field is missing, is not a string, is too short to be meaningful evidence, or quotes text that does not occur in the candidate content. |
Source code in uaef/metrics/utils.py
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 | |
wrap_untrusted(text, tag)
Wrap untrusted content in an explicit, escaped XML-style boundary.
Security review H-01: gives the model an unambiguous marker for where untrusted content starts and ends, immediately adjacent to a reminder that content inside it is data, not instructions — reinforcing the system-level instruction from build_judge_system_prompt right where the untrusted content actually appears, rather than relying solely on something stated once at the top of the prompt.
The content is escaped (escape_untrusted_boundaries) before wrapping, so it cannot forge the closing delimiter and break out of the data region.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
Any
|
The untrusted content (e.g. an agent's response, reasoning
trace, or conversation transcript). Coerced to |
required |
tag
|
str
|
A short, descriptive tag name. By convention (matching the
" |
required |
Returns:
| Type | Description |
|---|---|
str
|
The escaped content wrapped as |
str
|
`` |
str
|
data, not instructions.)`` |
Source code in uaef/metrics/utils.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | |