Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(embed): extend tool_results helper to match folded tool results

Steven Enamakel0bc3483848da
diff --git a/crates/openhuman-embed/tests/common/mod.rs b/crates/openhuman-embed/tests/common/mod.rs
index 0634d35153..40f20c0521 100644
--- a/crates/openhuman-embed/tests/common/mod.rs
+++ b/crates/openhuman-embed/tests/common/mod.rs
@@ -101,7 +101,10 @@ pub fn tool_call_completion(tool: &str, arguments: &str) -> serde_json::Value {
})
}
-/// The concatenated `tool`-role message contents of a recorded request.
+/// The concatenated tool-result contents of a recorded request.
+///
+/// OpenAI-compatible transports may preserve native `tool` messages or fold
+/// them into the provider-neutral `[Tool results]` user-message form.
pub fn tool_results(request: &wiremock::Request) -> String {
let body: serde_json::Value = serde_json::from_slice(&request.body).unwrap_or_default();
body.get("messages")
@@ -109,7 +112,14 @@ pub fn tool_results(request: &wiremock::Request) -> String {
.map(|messages| {
messages
.iter()
- .filter(|m| m.get("role").and_then(|r| r.as_str()) == Some("tool"))
+ .filter(|m| {
+ let role = m.get("role").and_then(|r| r.as_str());
+ let folded = m
+ .get("content")
+ .and_then(|content| content.as_str())
+ .is_some_and(|content| content.starts_with("[Tool results]\n"));
+ role == Some("tool") || (role == Some("user") && folded)
+ })
.filter_map(|m| m.get("content"))
.map(|c| match c {
serde_json::Value::String(s) => s.clone(),