Skip to content

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

test(agent): move the hit-cap regression tests into post_commit_tests

M3gA-Mind4b3bfa4b7425
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session/post_commit_tests.rs b/crates/openhuman-core/src/agent/session_host/runtime_session/post_commit_tests.rs
index 5be38099f2..4968f784c4 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session/post_commit_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session/post_commit_tests.rs
@@ -1,5 +1,7 @@
use super::*;
+use crate::agent::session_host::runtime_session::OpenHumanSessionState;
use crate::progress::AgentProgress;
+use tinyagents_runtime::{CommitReceipt, ResumeMode, SessionTurnOutcome, TranscriptTurnOptions};
fn user(text: &str) -> Message {
Message::user(text)
@@ -118,3 +120,56 @@ async fn deferred_tail_runs_under_the_handed_context_not_the_active_one() {
.expect("tail has a context");
assert!(std::sync::Arc::ptr_eq(&seen, &handed));
}
+
+// `finalize_committed_turn` reports the iteration cap only when the turn hit it.
+
+/// Commits one turn whose outcome is `interrupted` and returns the
+/// `last_turn_hit_cap` it leaves on the session.
+async fn hit_cap_after_interrupted_turn(sidecar_hit_cap: bool) -> bool {
+ let context = crate::agent::tinyagents::host::OpenHumanRunContext::new();
+ context.session_sidecar.lock().unwrap().hit_cap = sidecar_hit_cap;
+ let receipt = CommitReceipt {
+ outcome: SessionTurnOutcome {
+ history: Vec::new(),
+ output: Some("Which city do you mean?".into()),
+ // The driver marks a turn interrupted on an early-exit tool
+ // (`ask_user_clarification`) as well as on the cap.
+ interrupted: true,
+ },
+ options: TranscriptTurnOptions {
+ request_id: None,
+ thread_id: None,
+ stream: true,
+ resume: ResumeMode::Never,
+ context,
+ },
+ transcript: None,
+ };
+ let state = std::sync::Mutex::new(OpenHumanSessionState::default());
+ finalize_committed_turn(
+ &state,
+ &[],
+ TurnIdentity {
+ session_id: "post-commit-hit-cap".into(),
+ agent_id: "orchestrator".into(),
+ channel: "web".into(),
+ },
+ receipt,
+ )
+ .await;
+ let hit_cap = state.lock().unwrap().last_turn_hit_cap;
+ hit_cap
+}
+
+#[tokio::test]
+async fn a_clarification_early_exit_is_not_reported_as_hitting_the_cap() {
+ assert!(
+ !hit_cap_after_interrupted_turn(false).await,
+ "a turn that ended by asking the user a question was reported as an iteration-cap pause"
+ );
+}
+
+#[tokio::test]
+async fn a_turn_that_hit_the_cap_is_reported_as_hitting_it() {
+ assert!(hit_cap_after_interrupted_turn(true).await);
+}
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session_post_commit_tests.rs b/crates/openhuman-core/src/agent/session_host/runtime_session_post_commit_tests.rs
deleted file mode 100644
index 53e2c35e98..0000000000
--- a/crates/openhuman-core/src/agent/session_host/runtime_session_post_commit_tests.rs
+++ /dev/null
@@ -1,59 +0,0 @@
-//! `finalize_committed_turn` reports the iteration cap only when the turn hit it.
-
-use tinyagents_runtime::{CommitReceipt, ResumeMode, SessionTurnOutcome, TranscriptTurnOptions};
-
-use crate::agent::session_host::runtime_session::post_commit::{
- finalize_committed_turn, TurnIdentity,
-};
-use crate::agent::session_host::runtime_session::OpenHumanSessionState;
-
-/// Commits one turn whose outcome is `interrupted` and returns the
-/// `last_turn_hit_cap` it leaves on the session.
-async fn hit_cap_after_interrupted_turn(sidecar_hit_cap: bool) -> bool {
- let context = crate::agent::tinyagents::host::OpenHumanRunContext::new();
- context.session_sidecar.lock().unwrap().hit_cap = sidecar_hit_cap;
- let receipt = CommitReceipt {
- outcome: SessionTurnOutcome {
- history: Vec::new(),
- output: Some("Which city do you mean?".into()),
- // The driver marks a turn interrupted on an early-exit tool
- // (`ask_user_clarification`) as well as on the cap.
- interrupted: true,
- },
- options: TranscriptTurnOptions {
- request_id: None,
- thread_id: None,
- stream: true,
- resume: ResumeMode::Never,
- context,
- },
- transcript: None,
- };
- let state = std::sync::Mutex::new(OpenHumanSessionState::default());
- finalize_committed_turn(
- &state,
- &[],
- TurnIdentity {
- session_id: "post-commit-hit-cap".into(),
- agent_id: "orchestrator".into(),
- channel: "web".into(),
- },
- receipt,
- )
- .await;
- let hit_cap = state.lock().unwrap().last_turn_hit_cap;
- hit_cap
-}
-
-#[tokio::test]
-async fn a_clarification_early_exit_is_not_reported_as_hitting_the_cap() {
- assert!(
- !hit_cap_after_interrupted_turn(false).await,
- "a turn that ended by asking the user a question was reported as an iteration-cap pause"
- );
-}
-
-#[tokio::test]
-async fn a_turn_that_hit_the_cap_is_reported_as_hitting_it() {
- assert!(hit_cap_after_interrupted_turn(true).await);
-}
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session_tests.rs b/crates/openhuman-core/src/agent/session_host/runtime_session_tests.rs
index 1db988173f..b1a5adfbfd 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session_tests.rs
@@ -10,8 +10,6 @@ use tinytools::ToolSpec;
mod flow_prompt_tests;
#[path = "runtime_session_terminal_tests.rs"]
mod terminal_tests;
-#[path = "runtime_session_post_commit_tests.rs"]
-mod post_commit_tests;
fn synthesized_tool_names(
prelude: &super::OpenHumanTurnPrelude,