1use serde::{Deserialize, Serialize};
4
5use agent_sdk_core::{EntityRef, RunId, SessionId, TurnId};
6
7#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
8#[serde(tag = "scope", rename_all = "snake_case")]
9pub enum EvaluationScope {
11 Run {
13 run_id: RunId,
15 },
16 Turn {
18 session_id: Option<SessionId>,
20 turn_id: TurnId,
22 },
23 Session {
25 session_id: SessionId,
27 },
28 Custom {
30 scope_ref: EntityRef,
32 },
33}
34
35#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
36#[serde(rename_all = "snake_case")]
37pub enum EvaluationSubjectRole {
39 Primary,
41 CandidateEvidence,
43 Baseline,
45 Comparator,
47 Constraint,
49}
50
51#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
52pub struct EvaluationSubject {
54 pub subject_ref: EntityRef,
56 pub role: EvaluationSubjectRole,
58 pub redacted_summary: Option<String>,
60}
61
62impl EvaluationSubject {
63 pub fn primary(subject_ref: EntityRef) -> Self {
65 Self {
66 subject_ref,
67 role: EvaluationSubjectRole::Primary,
68 redacted_summary: None,
69 }
70 }
71
72 pub fn with_redacted_summary(mut self, redacted_summary: impl Into<String>) -> Self {
74 self.redacted_summary = Some(redacted_summary.into());
75 self
76 }
77}
78
79#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
80pub struct EvaluationCriterion {
82 pub criterion_id: String,
84 pub redacted_summary: String,
86 pub weight: Option<String>,
88}
89
90impl EvaluationCriterion {
91 pub fn new(criterion_id: impl Into<String>, redacted_summary: impl Into<String>) -> Self {
93 Self {
94 criterion_id: criterion_id.into(),
95 redacted_summary: redacted_summary.into(),
96 weight: None,
97 }
98 }
99
100 pub fn with_weight(mut self, weight: impl Into<String>) -> Self {
102 self.weight = Some(weight.into());
103 self
104 }
105}
106
107#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
108pub struct ExpectedOutcome {
110 pub outcome_ref: Option<EntityRef>,
112 pub criteria: Vec<EvaluationCriterion>,
114 pub redacted_summary: String,
116}
117
118impl ExpectedOutcome {
119 pub fn new(redacted_summary: impl Into<String>) -> Self {
121 Self {
122 outcome_ref: None,
123 criteria: Vec::new(),
124 redacted_summary: redacted_summary.into(),
125 }
126 }
127
128 pub fn completed() -> Self {
130 Self::new("agent completed the requested task").with_criterion(EvaluationCriterion::new(
131 "criterion.completed",
132 "run completed",
133 ))
134 }
135
136 pub fn with_outcome_ref(mut self, outcome_ref: EntityRef) -> Self {
138 self.outcome_ref = Some(outcome_ref);
139 self
140 }
141
142 pub fn with_criterion(mut self, criterion: EvaluationCriterion) -> Self {
144 self.criteria.push(criterion);
145 self
146 }
147}