Skip to content

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

test(agent): assert the resumed head decodes the orphans as Tool rows

M3gA-Minde0ba21759500
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rs b/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rs
index 1302700817..ea93b83dc5 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rs
@@ -720,6 +720,32 @@ async fn resumed_orphaned_tool_head_is_repaired_before_the_request() {
let mut host = new_host();
host.set_thread_id(Some("thread-orphaned-head"));
+ // Self-proving fixture: the real codec must decode the orphans as `Tool`
+ // rows right after the system prefix, or the request assertions below
+ // would pass without the repair ever having anything to drop.
+ assert!(host.resume_bound_session().await.unwrap());
+ let decoded: Vec<Message> = host
+ .runtime_session
+ .as_ref()
+ .expect("resumed runtime session")
+ .history()
+ .to_vec();
+ let prefix = decoded
+ .iter()
+ .take_while(|m| matches!(m, Message::System(_)))
+ .count();
+ let orphan_ids: Vec<&str> = decoded[prefix..]
+ .iter()
+ .map_while(|m| match m {
+ Message::Tool(t) => Some(t.tool_call_id.as_str()),
+ _ => None,
+ })
+ .collect();
+ assert_eq!(
+ orphan_ids,
+ ["call_orphan_a", "call_orphan_b"],
+ "the resumed head must decode the two orphans as leading Tool rows"
+ );
assert_eq!(host.turn("second message").await.unwrap(), "second reply");
let requests = model.requests();