Package com.tnsai.annotations
Annotation Interface EvalMetric
Marks a method or class for evaluation metric collection.
When applied to agent methods, this annotation enables automatic metric collection for evaluation purposes. Metrics are captured during execution and can be used for:
- Goal completion tracking
- Tool selection analysis
- Latency measurements
- Quality assessments
- Regression detection
Usage on Methods
@EvalMetric(name = "goal_completion", category = MetricCategory.GOAL)
public void onGoalCompleted(String goalId, boolean success) {
// Method will be tracked for goal completion metrics
}
Usage on Classes
@EvalMetric(name = "research_agent", category = MetricCategory.AGENT)
public class ResearchAgent extends Agent {
// All agent interactions will be tracked
}
Metric Categories
| Category | Description | Example Metrics |
|---|---|---|
| GOAL | Goal completion | success_rate, completion_time |
| TOOL | Tool usage | selection_accuracy, call_count |
| LATENCY | Performance | response_time, processing_time |
| QUALITY | Output quality | relevance, accuracy, coherence |
| COST | Resource usage | token_count, api_calls |
| AGENT | Overall agent | session_success, efficiency |
- Author:
- TnsAI Team
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumCategories for evaluation metrics. -
Required Element Summary
Required Elements -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionThe category of this metric.booleanWhether this metric is critical for pass/fail determination.Human-readable description of what this metric measures.booleanWhether to track this metric in real-time.String[]Tags for grouping and filtering metrics.doubleMinimum acceptable value for this metric (0.0 to 1.0).
-
Element Details
-
name
String nameThe name of the metric. Used as identifier in evaluation reports.- Returns:
- metric name
-
category
EvalMetric.MetricCategory categoryThe category of this metric.- Returns:
- metric category
- Default:
CUSTOM
-
description
String descriptionHuman-readable description of what this metric measures.- Returns:
- metric description
- Default:
""
-
critical
boolean criticalWhether this metric is critical for pass/fail determination. Critical metrics cause evaluation failure if below threshold.- Returns:
- true if critical
- Default:
false
-
threshold
double thresholdMinimum acceptable value for this metric (0.0 to 1.0). Values below this threshold are considered failures.- Returns:
- threshold value
- Default:
0.7
-
realtime
boolean realtimeWhether to track this metric in real-time. Real-time metrics are streamed as they are collected.- Returns:
- true if real-time tracking is enabled
- Default:
false
-
tags
String[] tagsTags for grouping and filtering metrics.- Returns:
- array of tags
- Default:
{}
-