use crate::brain::agent::service::helpers::{assistant_reasoning_stub, empty_reasoning_nudge};
use crate::brain::provider::{ContentBlock, Role};
#[test]
fn no_tools_yet_nudge_encourages_a_tool_call_never_suppresses_it() {
for attempt in 1..=5 {
let n = empty_reasoning_nudge(true, attempt).to_lowercase();
assert!(
n.contains("tool"),
"no-tools nudge must reference calling a tool (attempt {attempt}): {n}"
);
assert!(
!n.contains("do not call more tools")
&& !n.contains("no tool calls")
&& !n.contains("tool results above are sufficient"),
"no-tools nudge must NOT suppress tool calls (attempt {attempt}): {n}"
);
}
}
#[test]
fn tools_ran_nudge_steers_to_writing_the_answer() {
let n = empty_reasoning_nudge(false, 1).to_lowercase();
assert!(n.contains("tool results above are sufficient") || n.contains("write the answer"));
}
#[test]
fn stub_carries_reasoning_as_thinking_block() {
let msg = assistant_reasoning_stub(Some("The user wants the pricing table. I have the data."));
assert_eq!(msg.role, Role::Assistant);
match msg.content.first() {
Some(ContentBlock::Thinking { thinking, .. }) => {
assert!(thinking.contains("pricing table"));
}
other => panic!("expected a leading Thinking block, got {other:?}"),
}
}
#[test]
fn stub_is_empty_when_no_reasoning() {
for reasoning in [None, Some(""), Some(" \n ")] {
let msg = assistant_reasoning_stub(reasoning);
assert!(
!msg.content
.iter()
.any(|b| matches!(b, ContentBlock::Thinking { .. })),
"no Thinking block when reasoning is absent/blank: {reasoning:?}"
);
}
}