pub struct ChatBotHarness { /* private fields */ }Expand description
Runs the real chat stack — real MindsetOperator, real system
prompt, real tool loop with argument validation — against an in-RAM
memory and a scriptable adapter.
The point is that a test exercises production code paths. Anything the harness reimplemented would be a second implementation free to drift from the one that ships.
let harness = ChatBotHarness::builder(Arc::new(MyMindset))
.tools(OrderTools::register_tools(&container))
.container(container)
.build();
harness.adapter().call_tool("read_order", json!({ "id": 7 }));
harness.adapter().reply("It shipped yesterday.");
let turn = harness.send("where is order 7?").await.unwrap();
assert_eq!(turn.text(), "It shipped yesterday.");
assert!(turn.called("read_order"));Implementations§
Source§impl ChatBotHarness
impl ChatBotHarness
Sourcepub fn new(mindset: Arc<dyn Mindset>) -> Self
pub fn new(mindset: Arc<dyn Mindset>) -> Self
A harness with a mock adapter, an in-RAM memory and no tools.
pub fn builder(mindset: Arc<dyn Mindset>) -> ChatBotHarnessBuilder
Sourcepub fn adapter(&self) -> &Arc<MockChatAdapter>
pub fn adapter(&self) -> &Arc<MockChatAdapter>
The scripted adapter — queue turns and assert on requests.
Sourcepub fn operator(&self) -> &Arc<MindsetOperator>
pub fn operator(&self) -> &Arc<MindsetOperator>
The operator the bot uses, for asserting on the real prompt and tool schema.
Sourcepub async fn send(
&self,
message: impl IntoChatMessage,
) -> Result<ChatTurn, ChatBotError>
pub async fn send( &self, message: impl IntoChatMessage, ) -> Result<ChatTurn, ChatBotError>
Send a human message and collect what the bot did.
Sourcepub async fn call_tool(
&self,
name: &str,
arguments: impl ToArguments,
) -> Result<String, ToolError>
pub async fn call_tool( &self, name: &str, arguments: impl ToArguments, ) -> Result<String, ToolError>
Run one tool directly — real validation, real dispatch — without scripting a conversation around it. Returns the string the model would have received.
Sourcepub async fn system_prompt(&self) -> String
pub async fn system_prompt(&self) -> String
The real system prompt this mindset produces.
Sourcepub fn tools(&self) -> Result<Vec<MindsetTool>, ToolError>
pub fn tools(&self) -> Result<Vec<MindsetTool>, ToolError>
The real tool schema the model would be given.