pub fn tool_choice_for(is_zen: bool, tools_enabled: bool) -> Option<String> {
if is_zen && !tools_enabled {
Some("none".to_string())
} else {
None
}
}
pub fn needs_fallback_tools(is_zen: bool, tools_enabled: bool) -> bool {
is_zen && !tools_enabled
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn tool_choice_none_only_on_zen_text_only_calls() {
assert_eq!(
tool_choice_for(true, false).as_deref(),
Some("none"),
"compaction/tools-off round on zen must pin none (P8)"
);
assert_eq!(tool_choice_for(true, true), None, "real tools keep auto");
assert_eq!(
tool_choice_for(false, false),
None,
"non-zen providers untouched (deepseek summarization unchanged)"
);
}
#[test]
fn fallback_tools_only_on_zen_text_only_calls() {
assert!(needs_fallback_tools(true, false));
assert!(!needs_fallback_tools(true, true));
assert!(
!needs_fallback_tools(false, false),
"non-zen never falls back"
);
assert!(!needs_fallback_tools(false, true));
}
}