use crate::error::{MojenticError, Result};
use crate::llm::gateway::ReasoningEffort;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ReasoningProfile {
pub name: String,
pub supported_efforts: Vec<ReasoningEffort>,
pub supports_reasoning_history: bool,
}
impl ReasoningProfile {
pub fn qwen3_8() -> Self {
Self {
name: "qwen3.8".into(),
supported_efforts: vec![
ReasoningEffort::Disabled,
ReasoningEffort::Low,
ReasoningEffort::Medium,
ReasoningEffort::XHigh,
],
supports_reasoning_history: true,
}
}
pub fn validate(&self, effort: Option<ReasoningEffort>, preserve_history: bool) -> Result<()> {
if let Some(effort) = effort {
if !self.supported_efforts.contains(&effort) {
return Err(MojenticError::ConfigError(format!(
"reasoning effort {effort:?} is unsupported by profile {}; supported: {:?}",
self.name, self.supported_efforts
)));
}
}
if preserve_history && !self.supports_reasoning_history {
return Err(MojenticError::ConfigError(format!(
"profile {} does not support native reasoning history",
self.name
)));
}
Ok(())
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn qwen_accepts_exact_controls_without_inventing_a_default() {
let profile = ReasoningProfile::qwen3_8();
for effort in [
None,
Some(ReasoningEffort::Disabled),
Some(ReasoningEffort::Low),
Some(ReasoningEffort::Medium),
Some(ReasoningEffort::XHigh),
] {
assert!(profile.validate(effort, true).is_ok());
}
assert!(profile.validate(Some(ReasoningEffort::High), false).is_err());
assert!(profile.validate(Some(ReasoningEffort::Enabled), false).is_err());
}
#[test]
fn boolean_model_profile_rejects_named_effort_and_native_history() {
let profile = ReasoningProfile {
name: "boolean-only".into(),
supported_efforts: vec![ReasoningEffort::Disabled, ReasoningEffort::Enabled],
supports_reasoning_history: false,
};
assert!(profile.validate(Some(ReasoningEffort::Enabled), false).is_ok());
assert!(profile.validate(Some(ReasoningEffort::Low), false).is_err());
assert!(profile.validate(None, true).is_err());
}
}