use agent_client_protocol::schema::v1::StopReason;
#[derive(Debug, Clone, PartialEq, Eq)]
pub(super) enum TurnClassification {
Success,
Failure { subtype: &'static str },
Stopped,
Invalid,
}
pub(super) fn classify_stop(stop: &StopReason, cancelled_by_us: bool) -> TurnClassification {
if cancelled_by_us {
return TurnClassification::Stopped;
}
match stop {
StopReason::EndTurn => TurnClassification::Success,
StopReason::MaxTokens => TurnClassification::Failure {
subtype: "max_tokens",
},
StopReason::MaxTurnRequests => TurnClassification::Failure {
subtype: "max_turn_requests",
},
StopReason::Refusal => TurnClassification::Failure { subtype: "refusal" },
StopReason::Cancelled => TurnClassification::Failure {
subtype: "cancelled",
},
_ => TurnClassification::Invalid,
}
}
#[cfg(test)]
#[path = "turn_tests.rs"]
mod tests;