Skip to content

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

test(agent): add missing test files for agent and thread modules

Steven Enamakelcfd0db251523
diff --git a/crates/openhuman-core/src/agent/agent_tests.rs b/crates/openhuman-core/src/agent/agent_tests.rs
index 5c4fb9a1a1..73bf2b45d1 100644
--- a/crates/openhuman-core/src/agent/agent_tests.rs
+++ b/crates/openhuman-core/src/agent/agent_tests.rs
@@ -345,5 +345,3 @@ mod agent_turn_loop_nudge_tests;
mod agent_turn_loop_packed_tool_tests;
#[path = "agent_turn_loop_tests.rs"]
mod agent_turn_loop_tests;
-#[path = "messages_tests.rs"]
-mod messages_tests;
diff --git a/crates/openhuman-core/src/agent/agent_turn_loop_nudge_tests.rs b/crates/openhuman-core/src/agent/agent_turn_loop_nudge_tests.rs
index c7af8f2402..8e10e2cbf2 100644
--- a/crates/openhuman-core/src/agent/agent_turn_loop_nudge_tests.rs
+++ b/crates/openhuman-core/src/agent/agent_turn_loop_nudge_tests.rs
@@ -136,8 +136,8 @@ fn committed_system_rows_past_prefix(history: &[TranscriptEntry]) -> Vec<String>
TranscriptEntry::Chat(chat) => Some(chat),
_ => None,
})
- .skip_while(|chat| chat.role == "system")
- .filter(|chat| chat.role == "system")
+ .skip_while(|chat| chat.role.as_str() == "system")
+ .filter(|chat| chat.role.as_str() == "system")
.map(|chat| chat.content.clone())
.collect()
}
@@ -161,7 +161,7 @@ async fn validation_nudge_reaches_the_retry_but_is_not_committed() {
assert!(
history.iter().any(|m| matches!(
m,
- TranscriptEntry::Chat(chat) if chat.role == "tool" && chat.content.contains("422")
+ TranscriptEntry::Chat(chat) if chat.role.as_str() == "tool" && chat.content.contains("422")
)) || history
.iter()
.any(|m| matches!(m, TranscriptEntry::ToolResults(r) if r.iter().any(|r| r.content.contains("422")))),
diff --git a/crates/openhuman-core/src/agent/agent_turn_loop_packed_tool_tests.rs b/crates/openhuman-core/src/agent/agent_turn_loop_packed_tool_tests.rs
index b5f82de4e6..240575f545 100644
--- a/crates/openhuman-core/src/agent/agent_turn_loop_packed_tool_tests.rs
+++ b/crates/openhuman-core/src/agent/agent_turn_loop_packed_tool_tests.rs
@@ -73,7 +73,7 @@ async fn turn_routes_a_bare_packed_tool_call_through_use_skill() {
.map(|r| r.content.clone())
.collect::<Vec<_>>(),
),
- TranscriptEntry::Chat(message) if message.role == "tool" => {
+ TranscriptEntry::Chat(message) if message.role.as_str() == "tool" => {
Some(vec![message.content.clone()])
}
_ => None,
@@ -152,7 +152,7 @@ async fn turn_does_not_route_a_bare_call_the_session_would_refuse() {
.iter()
.any(|r| r.content.contains("unknown tool `skill_registry_install`")),
TranscriptEntry::Chat(message) => {
- message.role == "tool"
+ message.role.as_str() == "tool"
&& message
.content
.contains("unknown tool `skill_registry_install`")
diff --git a/crates/openhuman-core/src/agent/agent_turn_loop_tests.rs b/crates/openhuman-core/src/agent/agent_turn_loop_tests.rs
index e5e78ec59b..7c7a58dc12 100644
--- a/crates/openhuman-core/src/agent/agent_turn_loop_tests.rs
+++ b/crates/openhuman-core/src/agent/agent_turn_loop_tests.rs
@@ -137,7 +137,7 @@ async fn turn_emits_checkpoint_at_max_iterations() {
matches!(
agent.history().last(),
Some(TranscriptEntry::Chat(msg))
- if msg.role == "assistant" && msg.content.contains("tool-call limit")
+ if msg.role.as_str() == "assistant" && msg.content.contains("tool-call limit")
),
"history should end on the assistant checkpoint, got: {:?}",
agent.history().last()
@@ -178,7 +178,7 @@ async fn turn_handles_unknown_tool_gracefully() {
.iter()
.any(|r| r.content.contains("unknown tool") && r.content.contains("nonexistent_tool")),
TranscriptEntry::Chat(message) => {
- message.role == "tool"
+ message.role.as_str() == "tool"
&& message.content.contains("unknown tool")
&& message.content.contains("nonexistent_tool")
}
@@ -286,7 +286,7 @@ async fn history_is_not_trimmed_by_message_count() {
let history = agent.history();
// System prompt should always be preserved.
- assert!(matches!(&history[0], TranscriptEntry::Chat(c) if c.role == "system"));
+ assert!(matches!(&history[0], TranscriptEntry::Chat(c) if c.role.as_str() == "system"));
// Every turn's user message is still there, and the first one still opens
// the conversation right after the system prompt.
assert!(
@@ -297,7 +297,7 @@ async fn history_is_not_trimmed_by_message_count() {
let first_user = history
.iter()
.find_map(|m| match m {
- TranscriptEntry::Chat(c) if c.role == "user" => Some(c.content.clone()),
+ TranscriptEntry::Chat(c) if c.role.as_str() == "user" => Some(c.content.clone()),
_ => None,
})
.expect("a user message");
@@ -521,7 +521,7 @@ async fn turn_preserves_text_alongside_tool_calls() {
// that accompanied the tool call (the unified tinyagents representation
// keeps the preface text on the tool-call turn).
let has_intermediate = agent.history().iter().any(|msg| match msg {
- TranscriptEntry::Chat(c) => c.role == "assistant" && c.content.contains("Let me check"),
+ TranscriptEntry::Chat(c) => c.role.as_str() == "assistant" && c.content.contains("Let me check"),
TranscriptEntry::AssistantToolCalls { text, .. } => {
text.as_deref().is_some_and(|t| t.contains("Let me check"))
}
@@ -607,7 +607,7 @@ async fn e2e_native_loop_executes_text_fallback_tool_calls_and_persists_history(
.iter()
.any(|call| call.name == "echo" && call.arguments.contains("from-fallback")),
TranscriptEntry::Chat(message)
- if message.role == "assistant"
+ if message.role.as_str() == "assistant"
&& message.content.contains("\"tool_calls\"")
&& message.content.contains("\"echo\"") =>
{
@@ -620,7 +620,7 @@ async fn e2e_native_loop_executes_text_fallback_tool_calls_and_persists_history(
.iter()
.any(|result| result.content.contains("from-fallback")),
TranscriptEntry::Chat(message) => {
- message.role == "tool" && message.content.contains("from-fallback")
+ message.role.as_str() == "tool" && message.content.contains("from-fallback")
}
_ => false,
});
@@ -648,7 +648,7 @@ async fn system_prompt_injected_on_first_turn() {
// First message should be the system prompt
let first = &agent.history()[0];
assert!(
- matches!(first, TranscriptEntry::Chat(c) if c.role == "system"),
+ matches!(first, TranscriptEntry::Chat(c) if c.role.as_str() == "system"),
"First history entry should be system prompt"
);
}
diff --git a/crates/openhuman-core/src/agent/messages_tests.rs b/crates/openhuman-core/src/agent/messages_tests.rs
index c914869814..9027c402cf 100644
--- a/crates/openhuman-core/src/agent/messages_tests.rs
+++ b/crates/openhuman-core/src/agent/messages_tests.rs
@@ -1,4 +1,5 @@
use super::*;
+use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
struct Holder {
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_parallel_agents_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_parallel_agents_tests.rs
index cc61a49cbb..8b8dd7d203 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_parallel_agents_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_parallel_agents_tests.rs
@@ -645,12 +645,12 @@ async fn agent_turn_runs_long_parallel_subagent_flow_with_many_nested_tool_calls
}
}
}
- TranscriptEntry::Chat(message) if message.role == "assistant" => {
+ TranscriptEntry::Chat(message) if message.role.as_str() == "assistant" => {
if message.content.contains("spawn_parallel_agents") {
saw_parallel_call = true;
}
}
- TranscriptEntry::Chat(message) if message.role == "tool" => {
+ TranscriptEntry::Chat(message) if message.role.as_str() == "tool" => {
let content = serde_json::from_str::<serde_json::Value>(&message.content)
.ok()
.and_then(|envelope| {
diff --git a/crates/openhuman-core/src/threads/transcript_host_tests.rs b/crates/openhuman-core/src/threads/transcript_host_tests.rs
index 42e92f145b..915b4bf694 100644
--- a/crates/openhuman-core/src/threads/transcript_host_tests.rs
+++ b/crates/openhuman-core/src/threads/transcript_host_tests.rs
@@ -143,7 +143,7 @@ fn text_dialect_tool_turn_projects_calls_on_their_issuing_row_as_settled() {
.unwrap();
let failed_result = rows
.iter()
- .find(|row| row.role == "user" && row.content.starts_with("[Tool results]"))
+ .find(|row| row.role.as_str() == "user" && row.content.starts_with("[Tool results]"))
.expect("text dialect result row");
assert_eq!(
failed_result
@@ -184,7 +184,7 @@ fn text_dialect_tool_turn_projects_calls_on_their_issuing_row_as_settled() {
let assistants: Vec<_> = persisted
.messages
.iter()
- .filter(|m| m.role == "assistant")
+ .filter(|m| m.role.as_str() == "assistant")
.collect();
assert_eq!(assistants.len(), 2);
let issued: Vec<String> = assistants[0]
@@ -374,7 +374,7 @@ fn tool_failure_metadata_round_trips_write_to_display_line() {
.records
.iter()
.find_map(|r| match r {
- transcript::DisplayRecord::Message(m) if m.message.role == "tool" => Some(m),
+ transcript::DisplayRecord::Message(m) if m.message.role.as_str() == "tool" => Some(m),
_ => None,
})
.expect("tool display message present");