Skip to content

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

feat(agent): track turn stop reasons in progress and run logs

Steven Enamakel13021ad9ad2b
diff --git a/crates/openhuman-core/src/agent/mod.rs b/crates/openhuman-core/src/agent/mod.rs
index a469bb45b1..2086308a81 100644
--- a/crates/openhuman-core/src/agent/mod.rs
+++ b/crates/openhuman-core/src/agent/mod.rs
@@ -92,7 +92,7 @@ pub mod turn_deadline;
pub mod turn_origin;
/// How a turn that reached the completion path was stopped early (breaker,
/// deadline wind-down, iteration cap), carried to traces and parent tools.
-pub mod turn_stop;
+pub mod turn_projection;
/// Turn-workspace task-local — the per-turn filesystem root an embedder binds
/// a single agent turn to. Read by the session builder (as the turn's default
/// cwd) and by the path policy (as a read/write trusted root), so a host that
diff --git a/crates/openhuman-core/src/agent/orchestration/spawn_parallel/collect.rs b/crates/openhuman-core/src/agent/orchestration/spawn_parallel/collect.rs
index 1f2dbc5316..d32f818835 100644
--- a/crates/openhuman-core/src/agent/orchestration/spawn_parallel/collect.rs
+++ b/crates/openhuman-core/src/agent/orchestration/spawn_parallel/collect.rs
@@ -6,7 +6,7 @@ use serde_json::json;
use tokio::sync::mpsc::Sender;
use crate::agent::progress::AgentProgress;
-use crate::agent::turn_stop::TurnStop;
+use tinyagents_harness::turn_stop::TurnStop;
use tinyagents_orchestration::parallel::{BranchReport, Collected};
use tinytools_std::file_state;
@@ -118,7 +118,7 @@ pub(crate) async fn project_spawn_parallel_result(
// An incomplete worker was stopped early (breaker /
// cap); its span closes at WARNING with that stop.
stop: matches!(result.status, ParallelAgentStatus::Incomplete).then(|| {
- TurnStop::from_incomplete_reason(error.as_deref().unwrap_or(""))
+ crate::agent::turn_projection::stop_from_incomplete(error.as_deref().unwrap_or(""))
}),
})
.await
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/dispatch_outcomes.rs b/crates/openhuman-core/src/agent/orchestration/tools/dispatch_outcomes.rs
index 1015612399..193674b87b 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/dispatch_outcomes.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/dispatch_outcomes.rs
@@ -77,8 +77,8 @@ pub(crate) fn incomplete_envelope(
/// How a sub-agent handed back as `Incomplete { reason }` was stopped
/// (iteration cap or failure breaker), for its `SubagentCompleted` event.
-pub(crate) fn incomplete_stop(reason: &str) -> Option<crate::agent::turn_stop::TurnStop> {
- Some(crate::agent::turn_stop::TurnStop::from_incomplete_reason(
+pub(crate) fn incomplete_stop(reason: &str) -> Option<tinyagents_harness::turn_stop::TurnStop> {
+ Some(crate::agent::turn_projection::stop_from_incomplete(
reason,
))
}
@@ -95,7 +95,7 @@ pub(crate) fn stopped_subagent_result(
reason: &str,
envelope: String,
) -> ToolResult {
- let stop = crate::agent::turn_stop::TurnStop::from_incomplete_reason(reason);
+ let stop = crate::agent::turn_projection::stop_from_incomplete(reason);
log::debug!(
"[subagent] {tool_name} child stopped early agent_id={agent_id} task_id={task_id} \
{}; returning a failed tool result",
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_tests.rs
index 027a5bc5ce..d8f5aecec6 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_tests.rs
@@ -108,8 +108,8 @@ async fn spawn_subagent_reports_a_stopped_child_as_a_failed_tool_result() {
.expect("SubagentCompleted carries the child's stop");
assert!(matches!(
stop.kind,
- crate::agent::turn_stop::TurnStopKind::Breaker
- | crate::agent::turn_stop::TurnStopKind::IterationCap
+ tinyagents_harness::turn_stop::TurnStopKind::Breaker
+ | tinyagents_harness::turn_stop::TurnStopKind::IterationCap
));
}
diff --git a/crates/openhuman-core/src/agent/progress.rs b/crates/openhuman-core/src/agent/progress.rs
index 40deed680a..c0e23b6ed4 100644
--- a/crates/openhuman-core/src/agent/progress.rs
+++ b/crates/openhuman-core/src/agent/progress.rs
@@ -181,7 +181,7 @@ pub enum AgentProgress {
/// breaker or iteration cap) and handed back as incomplete. The trace
/// collector closes the subagent span at `WARNING` with it. `None` for
/// a sub-agent that finished normally.
- stop: Option<crate::agent::turn_stop::TurnStop>,
+ stop: Option<tinyagents_harness::turn_stop::TurnStop>,
},
/// A sub-agent failed.
@@ -422,7 +422,7 @@ pub enum AgentProgress {
/// completion path. Content-free; the trace collector closes the turn
/// span at `WARNING` with it. `None` for a turn that finished on its
/// own.
- stop: Option<crate::agent::turn_stop::TurnStop>,
+ stop: Option<tinyagents_harness::turn_stop::TurnStop>,
},
/// The turn's content: the user's prompt and the model's final reply.
diff --git a/crates/openhuman-core/src/agent/progress_tracing/collector/finish.rs b/crates/openhuman-core/src/agent/progress_tracing/collector/finish.rs
index 5e63787510..fc0f3bd5a4 100644
--- a/crates/openhuman-core/src/agent/progress_tracing/collector/finish.rs
+++ b/crates/openhuman-core/src/agent/progress_tracing/collector/finish.rs
@@ -147,7 +147,7 @@ impl SpanCollector {
/// Langfuse statusMessage; it is safe ungated because it holds only the
/// stop kind, a failure class and a tool name.
pub(super) fn insert_stop_attrs(
- stop: &crate::agent::turn_stop::TurnStop,
+ stop: &tinyagents_harness::turn_stop::TurnStop,
extra: &mut BTreeMap<String, serde_json::Value>,
) {
let message = stop.status_message();
diff --git a/crates/openhuman-core/src/agent/progress_tracing/collector/state.rs b/crates/openhuman-core/src/agent/progress_tracing/collector/state.rs
index 1d06c3a10e..4421bda805 100644
--- a/crates/openhuman-core/src/agent/progress_tracing/collector/state.rs
+++ b/crates/openhuman-core/src/agent/progress_tracing/collector/state.rs
@@ -109,7 +109,7 @@ pub enum TurnOutcome {
/// The harness stopped the turn early (failure breaker, deadline
/// wind-down, iteration cap) and it reached the completion path anyway.
Stopped {
- stop: crate::agent::turn_stop::TurnStop,
+ stop: tinyagents_harness::turn_stop::TurnStop,
},
}
diff --git a/crates/openhuman-core/src/agent/progress_tracing/progress_tracing_stop_tests.rs b/crates/openhuman-core/src/agent/progress_tracing/progress_tracing_stop_tests.rs
index b9a88a3b6f..3004968152 100644
--- a/crates/openhuman-core/src/agent/progress_tracing/progress_tracing_stop_tests.rs
+++ b/crates/openhuman-core/src/agent/progress_tracing/progress_tracing_stop_tests.rs
@@ -5,7 +5,7 @@
use super::*;
-use crate::agent::turn_stop::TurnStop;
+use tinyagents_harness::turn_stop::TurnStop;
use tinyagents_harness::observability::trace_export::otlp::otlp_requests;
use tinyagents_harness::observability::trace_export::SpanStatus;
@@ -57,7 +57,7 @@ fn a_breaker_stopped_turn_closes_at_warning_with_stop_attributes() {
(
AgentProgress::TurnCompleted {
iterations: 4,
- stop: Some(TurnStop::breaker(BREAKER_NOTE)),
+ stop: Some(crate::agent::turn_projection::breaker_stop(BREAKER_NOTE)),
},
50,
),
@@ -167,7 +167,7 @@ fn a_stopped_subagent_span_closes_at_warning_with_stop_attributes() {
(AgentProgress::TurnStarted, 0),
(spawn("t-stop", "Research"), 5),
(
- subagent_completed("t-stop", Some(TurnStop::breaker(BREAKER_NOTE))),
+ subagent_completed("t-stop", Some(crate::agent::turn_projection::breaker_stop(BREAKER_NOTE))),
40,
),
]);
diff --git a/crates/openhuman-core/src/agent/session_host/driver.rs b/crates/openhuman-core/src/agent/session_host/driver.rs
index 869f643e7c..efb8fcd20e 100644
--- a/crates/openhuman-core/src/agent/session_host/driver.rs
+++ b/crates/openhuman-core/src/agent/session_host/driver.rs
@@ -468,7 +468,7 @@ impl SessionDriver<OpenHumanRunContext> for OpenHumanSessionDriver {
observed.wrap_up_injected = outcome.wrap_up_injected;
// How the harness stopped the turn, if it did. The wind-down
// middleware marked the sidecar during the run.
- observed.stop = crate::agent::turn_stop::TurnStop::classify(
+ observed.stop = crate::agent::turn_projection::classify_stop(
outcome.breaker_halt.as_deref(),
observed.wind_down,
outcome.hit_cap,
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session_progress.rs b/crates/openhuman-core/src/agent/session_host/runtime_session_progress.rs
index 3eb0f56c24..3f76e876a0 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session_progress.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session_progress.rs
@@ -2,7 +2,7 @@
use crate::agent::progress::AgentProgress;
use crate::agent::tinyagents::host::OpenHumanRunContext;
-use crate::agent::turn_stop::TurnStop;
+use tinyagents_harness::turn_stop::TurnStop;
use tinyagents_runtime::CommitReceipt;
/// Preserve the response path if a progress receiver stays open but stops
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 d0770b76e4..fe8aa417c4 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
@@ -62,7 +62,7 @@ async fn committed_progress_uses_each_turns_receipt_sender() {
#[tokio::test]
async fn committed_progress_carries_the_sidecar_stop_on_turn_completed() {
use crate::agent::progress::AgentProgress;
- use crate::agent::turn_stop::{TurnStop, TurnStopKind};
+ use tinyagents_harness::turn_stop::{TurnStop, TurnStopKind};
use tinyagents_runtime::{
CommitReceipt, ResumeMode, SessionTurnOutcome, TranscriptTurnOptions,
};
@@ -70,7 +70,7 @@ async fn committed_progress_carries_the_sidecar_stop_on_turn_completed() {
let (tx, mut rx) = tokio::sync::mpsc::channel(4);
let mut context = crate::agent::tinyagents::host::OpenHumanRunContext::new();
context.progress = Some(tx);
- context.session_sidecar.lock().unwrap().stop = Some(TurnStop::breaker(
+ context.session_sidecar.lock().unwrap().stop = Some(crate::agent::turn_projection::breaker_stop(
"Stopping after 2 attempt(s): failure class `uncertain_side_effect` still blocks \
operation `web_answer_tool` on `x`. Resolve this blocker before retrying.",
));
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs b/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs
index 9203c72101..cd919a466a 100644
--- a/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs
@@ -989,7 +989,7 @@ async fn run_typed_mode(
// result + blocker instead of treating the summary as a finished answer
// or re-spinning the identical delegation (#4096).
crate::agent::subagent_host::types::SubagentRunStatus::Incomplete {
- reason: crate::agent::turn_stop::SUBAGENT_ITERATION_CAP_REASON.into(),
+ reason: tinyagents_harness::turn_stop::SUBAGENT_ITERATION_CAP_REASON.into(),
}
} else {
// A clean final response. (An `ask_user_clarification` early-exit is
diff --git a/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs b/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs
index 23e43890f9..01c1d34c4c 100644
--- a/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs
@@ -149,7 +149,7 @@ pub(crate) struct SessionTurnSidecar {
/// How the turn was stopped early, if it was (breaker, wind-down,
/// iteration cap). The driver classifies it; `after_commit` carries it on
/// `TurnCompleted` so the trace shows a stopped turn at `WARNING`.
- pub stop: Option<crate::agent::turn_stop::TurnStop>,
+ pub stop: Option<tinyagents_harness::turn_stop::TurnStop>,
}
/// Immutable inputs to the host's pre-dispatch policy.
diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_run_finalize.rs b/crates/openhuman-core/src/agent/tinyagents/turn_run_finalize.rs
index afdc7b1e8a..7c3ee5aad7 100644
--- a/crates/openhuman-core/src/agent/tinyagents/turn_run_finalize.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/turn_run_finalize.rs
@@ -198,7 +198,7 @@ pub(super) async fn finalize_turn_outcome(
// A run the harness stopped (breaker / cap) is traced as stopped, not as a
// clean completion. No deadline wind-down on this path: only the session
// turn carries one, and it records the stop through its sidecar.
- let stop = crate::agent::turn_stop::TurnStop::classify(breaker_halt.as_deref(), false, hit_cap);
+ let stop = crate::agent::turn_projection::classify_stop(breaker_halt.as_deref(), false, hit_cap);
if let Some(stop) = stop.as_ref().filter(|_| turn_completed_sink.is_some()) {
tracing::debug!(
model,
diff --git a/crates/openhuman-core/src/agent/turn_projection.rs b/crates/openhuman-core/src/agent/turn_projection.rs
index bcf618d01a..92913f057e 100644
--- a/crates/openhuman-core/src/agent/turn_projection.rs
+++ b/crates/openhuman-core/src/agent/turn_projection.rs
@@ -14,7 +14,7 @@ pub fn stop_fallback_class(note: &str) -> &'static str {
/// [`TurnStop::breaker`] with the OpenHuman stop-reason fallback.
pub fn breaker_stop(note: &str) -> TurnStop {
- TurnStop::breaker(note, stop_fallback_class)
+ crate::agent::turn_projection::breaker_stop(note, stop_fallback_class)
}
/// [`TurnStop::classify`] with the OpenHuman stop-reason fallback.
@@ -28,7 +28,7 @@ pub fn classify_stop(
/// [`TurnStop::from_incomplete_reason`] with the OpenHuman stop-reason fallback.
pub fn stop_from_incomplete(reason: &str) -> TurnStop {
- TurnStop::from_incomplete_reason(reason, stop_fallback_class)
+ crate::agent::turn_projection::stop_from_incomplete(reason, stop_fallback_class)
}
#[cfg(test)]
diff --git a/crates/openhuman-core/src/agent/turn_projection_tests.rs b/crates/openhuman-core/src/agent/turn_projection_tests.rs
new file mode 100644
index 0000000000..f81b686a4f
--- /dev/null
+++ b/crates/openhuman-core/src/agent/turn_projection_tests.rs
@@ -0,0 +1,48 @@
+use super::*;
+use tinyagents_harness::turn_stop::{TurnStopKind, SUBAGENT_ITERATION_CAP_REASON};
+
+const CLASSIFIED_NOTE: &str = "Stopping after 2 attempt(s): failure class \
+ `uncertain_side_effect` still blocks operation `web_answer_tool` on \
+ `https://example.com/private?q=secret`. Resolve this blocker before retrying.";
+
+#[test]
+fn a_classified_breaker_note_keeps_its_class_and_drops_its_scope() {
+ let stop = breaker_stop(CLASSIFIED_NOTE);
+ assert_eq!(stop.kind, TurnStopKind::Breaker);
+ assert_eq!(stop.failure_class.as_deref(), Some("uncertain_side_effect"));
+ assert_eq!(stop.operation.as_deref(), Some("web_answer_tool"));
+ assert!(!stop.status_message().contains("example.com"));
+}
+
+#[test]
+fn an_unclassified_breaker_note_falls_back_to_its_stop_reason_kind() {
+ let stop = breaker_stop("The last 6 tool calls in a row failed. Last error: token sk-live-123 rejected");
+ assert_eq!(stop.kind, TurnStopKind::Breaker);
+ assert_eq!(stop.failure_class.as_deref(), Some("varied_failures"));
+ assert_eq!(stop.status_message(), "stopped: breaker varied_failures");
+}
+
+#[test]
+fn classify_prefers_breaker_then_wind_down_then_cap() {
+ assert_eq!(classify_stop(None, false, false), None);
+ assert_eq!(
+ classify_stop(None, true, true).map(|s| s.kind),
+ Some(TurnStopKind::WindDown)
+ );
+ assert_eq!(
+ classify_stop(Some(CLASSIFIED_NOTE), true, true).map(|s| s.kind),
+ Some(TurnStopKind::Breaker)
+ );
+}
+
+#[test]
+fn an_incomplete_reason_maps_to_cap_or_breaker() {
+ assert_eq!(
+ stop_from_incomplete(SUBAGENT_ITERATION_CAP_REASON).kind,
+ TurnStopKind::IterationCap
+ );
+ assert_eq!(
+ stop_from_incomplete(CLASSIFIED_NOTE).operation.as_deref(),
+ Some("web_answer_tool")
+ );
+}
diff --git a/crates/openhuman-core/src/agent/turn_stop.rs b/crates/openhuman-core/src/agent/turn_stop.rs
deleted file mode 100644
index 1c94f6865f..0000000000
--- a/crates/openhuman-core/src/agent/turn_stop.rs
+++ /dev/null
@@ -1,165 +0,0 @@
-//! How a turn that "completed" was actually stopped by the harness.
-//!
-//! Three host-side mechanisms end a turn early while it still reaches the
-//! normal completion path (`TurnCompleted` / `SubagentCompleted`), so without
-//! this they read as clean completions in traces and to a delegating parent:
-//!
-//! * the repeated-failure **breaker** (`tinyagents::middleware::repeated_failure`)
-//! halts the run with a stop note;
-//! * the **wind-down** at the turn deadline
-//! (`tinyagents::deadline_wind_down`) pauses the run before the backstop;
-//! * the **iteration cap** stops a run whose last response still asked for
-//! tools.
-//!
-//! [`TurnStop`] carries that fact from where it is decided to the progress
-//! events, the trace collector and the parent tool result. It is
-//! content-free by construction: the failure class and operation are read
-//! from the breaker's fixed note template and reduced to identifier
-//! characters, never the quoted tool output or target.
-
-/// Which mechanism stopped the turn.
-#[derive(Debug, Clone, Copy, PartialEq, Eq)]
-pub enum TurnStopKind {
- /// The repeated-failure / classified-failure breaker halted the run.
- Breaker,
- /// The turn deadline's wind-down paused the run before the backstop.
- WindDown,
- /// The run reached its model-call cap with work still pending.
- IterationCap,
-}
-
-impl TurnStopKind {
- /// Stable wire / trace label.
- pub fn as_str(self) -> &'static str {
- match self {
- Self::Breaker => "breaker",
- Self::WindDown => "wind_down",
- Self::IterationCap => "iteration_cap",
- }
- }
-}
-
-/// A content-free description of how a turn was stopped.
-#[derive(Debug, Clone, PartialEq, Eq)]
-pub struct TurnStop {
- pub kind: TurnStopKind,
- /// Breaker only: the failure class (`uncertain_side_effect`,
- /// `permission`, …), or the stop-reason kind for notes without one
- /// (`repeated_failure`, `transient`, …).
- pub failure_class: Option<String>,
- /// Breaker only: the blocked operation (a tool name), when the note names
- /// one.
- pub operation: Option<String>,
-}
-
-/// The `Incomplete` reason the sub-agent runner reports for an iteration-cap
-/// stop. Shared so the parent can tell a cap from a breaker note.
-pub const SUBAGENT_ITERATION_CAP_REASON: &str = "reached its tool-call limit before finishing";
-
-/// Longest identifier kept from a stop note.
-const MAX_IDENT_CHARS: usize = 64;
-
-impl TurnStop {
- /// A wind-down stop.
- pub fn wind_down() -> Self {
- Self {
- kind: TurnStopKind::WindDown,
- failure_class: None,
- operation: None,
- }
- }
-
- /// An iteration-cap stop.
- pub fn iteration_cap() -> Self {
- Self {
- kind: TurnStopKind::IterationCap,
- failure_class: None,
- operation: None,
- }
- }
-
- /// A breaker stop, with the class and operation read from its `note`.
- ///
- /// The classified template is `Stopping after N attempt(s): failure class
- /// `X` still blocks operation `Y` on `Z`.`; only `X` and `Y` are kept
- /// (the scope `Z` can be a URL or path). Other notes get the stop-reason
- /// kind as their class and no operation.
- pub fn breaker(note: &str) -> Self {
- let lead = note.split("Last error").next().unwrap_or(note);
- let failure_class = backticked_after(lead, "failure class `")
- .and_then(ident)
- .or_else(|| {
- let key =
- crate::agent::session_host::stop_summary::StopReasonKind::from_stop_note(note)
- .key();
- ident(key.strip_prefix("turn_stop.").unwrap_or(key))
- });
- let operation = backticked_after(lead, "still blocks operation `").and_then(ident);
- Self {
- kind: TurnStopKind::Breaker,
- failure_class,
- operation,
- }
- }
-
- /// How a top-level run ended, from the outcome's flags. The breaker is the
- /// explicit cause and wins; a wind-down pause can also leave the run
- /// without a final response (which reads as a cap), so it beats the cap.
- pub fn classify(breaker_halt: Option<&str>, wind_down: bool, hit_cap: bool) -> Option<Self> {
- if let Some(note) = breaker_halt {
- return Some(Self::breaker(note));
- }
- if wind_down {
- return Some(Self::wind_down());
- }
- hit_cap.then(Self::iteration_cap)
- }
-
- /// The stop behind a sub-agent's `Incomplete { reason }`: the runner's
- /// cap reason, else the breaker note it carries verbatim.
- pub fn from_incomplete_reason(reason: &str) -> Self {
- if reason == SUBAGENT_ITERATION_CAP_REASON {
- Self::iteration_cap()
- } else {
- Self::breaker(reason)
- }
- }
-
- /// Content-free one-line summary, e.g.
- /// `stopped: breaker uncertain_side_effect on web_answer_tool`.
- pub fn status_message(&self) -> String {
- let mut out = format!("stopped: {}", self.kind.as_str());
- if let Some(class) = &self.failure_class {
- out.push(' ');
- out.push_str(class);
- }
- if let Some(operation) = &self.operation {
- out.push_str(" on ");
- out.push_str(operation);
- }
- out
- }
-}
-
-/// The text between `marker` and the next backtick.
-fn backticked_after<'a>(text: &'a str, marker: &str) -> Option<&'a str> {
- text.split_once(marker)
- .and_then(|(_, rest)| rest.split_once('`'))
- .map(|(value, _)| value)
-}
-
-/// `value` when it is a bounded identifier (`[A-Za-z0-9_.:-]`), else `None`,
-/// so nothing but a class or tool name can reach a trace attribute.
-fn ident(value: &str) -> Option<String> {
- let value = value.trim();
- let ok = !value.is_empty()
- && value.chars().count() <= MAX_IDENT_CHARS
- && value
- .chars()
- .all(|c| c.is_ascii_alphanumeric() || matches!(c, '_' | '.' | ':' | '-'));
- ok.then(|| value.to_string())
-}
-
-#[cfg(test)]
-#[path = "turn_stop_tests.rs"]
-mod tests;
diff --git a/crates/openhuman-core/src/agent/turn_stop_tests.rs b/crates/openhuman-core/src/agent/turn_stop_tests.rs
deleted file mode 100644
index 13510cc551..0000000000
--- a/crates/openhuman-core/src/agent/turn_stop_tests.rs
+++ /dev/null
@@ -1,77 +0,0 @@
-use super::*;
-
-const CLASSIFIED_NOTE: &str = "Stopping after 2 attempt(s): failure class \
- `uncertain_side_effect` still blocks operation `web_answer_tool` on \
- `https://example.com/private?q=secret`. Resolve this blocker before retrying.";
-
-#[test]
-fn a_classified_breaker_note_yields_its_class_and_operation_but_not_its_scope() {
- let stop = TurnStop::breaker(CLASSIFIED_NOTE);
- assert_eq!(stop.kind, TurnStopKind::Breaker);
- assert_eq!(stop.failure_class.as_deref(), Some("uncertain_side_effect"));
- assert_eq!(stop.operation.as_deref(), Some("web_answer_tool"));
- let message = stop.status_message();
- assert_eq!(
- message,
- "stopped: breaker uncertain_side_effect on web_answer_tool"
- );
- assert!(!message.contains("example.com"), "the scope never leaks");
-}
-
-#[test]
-fn an_unclassified_breaker_note_falls_back_to_its_stop_reason_kind() {
- let stop = TurnStop::breaker(
- "The last 6 tool calls in a row failed. Last error: token sk-live-123 rejected",
- );
- assert_eq!(stop.kind, TurnStopKind::Breaker);
- assert_eq!(stop.failure_class.as_deref(), Some("varied_failures"));
- assert_eq!(stop.operation, None);
- assert_eq!(stop.status_message(), "stopped: breaker varied_failures");
-}
-
-#[test]
-fn identifiers_that_are_not_plain_names_are_dropped() {
- let stop = TurnStop::breaker(
- "Stopping after 1 attempt(s): failure class `permission` still blocks operation \
- `rm -rf /home/alice` on `x`.",
- );
- assert_eq!(stop.failure_class.as_deref(), Some("permission"));
- assert_eq!(stop.operation, None, "free text must not reach a trace");
-}
-
-#[test]
-fn classify_prefers_breaker_then_wind_down_then_cap() {
- assert_eq!(TurnStop::classify(None, false, false), None);
- assert_eq!(
- TurnStop::classify(None, false, true),
- Some(TurnStop::iteration_cap())
- );
- assert_eq!(
- TurnStop::classify(None, true, true),
- Some(TurnStop::wind_down()),
- "a wind-down pause can read as a cap; the wind-down is the cause"
- );
- assert_eq!(
- TurnStop::classify(Some(CLASSIFIED_NOTE), true, true).map(|s| s.kind),
- Some(TurnStopKind::Breaker)
- );
-}
-
-#[test]
-fn an_incomplete_reason_maps_to_cap_or_breaker() {
- assert_eq!(
- TurnStop::from_incomplete_reason(SUBAGENT_ITERATION_CAP_REASON),
- TurnStop::iteration_cap()
- );
- assert_eq!(
- TurnStop::from_incomplete_reason(CLASSIFIED_NOTE)
- .operation
- .as_deref(),
- Some("web_answer_tool")
- );
- assert_eq!(TurnStop::wind_down().status_message(), "stopped: wind_down");
- assert_eq!(
- TurnStop::iteration_cap().status_message(),
- "stopped: iteration_cap"
- );
-}
diff --git a/crates/openhuman-core/src/skills/run_log.rs b/crates/openhuman-core/src/skills/run_log.rs
index 7a2525969b..96bbdc359d 100644
--- a/crates/openhuman-core/src/skills/run_log.rs
+++ b/crates/openhuman-core/src/skills/run_log.rs
@@ -206,7 +206,7 @@ pub fn format_event(ev: &AgentProgress) -> Option<String> {
pub async fn drain_to_log(
mut rx: Receiver<AgentProgress>,
path: PathBuf,
-) -> Option<crate::agent::turn_stop::TurnStop> {
+) -> Option<tinyagents_harness::turn_stop::TurnStop> {
let mut stop = None;
while let Some(ev) = rx.recv().await {
if let Some(line) = format_event(&ev) {
diff --git a/crates/openhuman-core/src/skills/run_log_tests.rs b/crates/openhuman-core/src/skills/run_log_tests.rs
index 21d97459ff..1fcf6e0b4c 100644
--- a/crates/openhuman-core/src/skills/run_log_tests.rs
+++ b/crates/openhuman-core/src/skills/run_log_tests.rs
@@ -50,7 +50,7 @@ async fn drain_to_log_returns_the_turns_stop() {
let (tx, rx) = tokio::sync::mpsc::channel(4);
tx.send(AgentProgress::TurnCompleted {
iterations: 5,
- stop: Some(crate::agent::turn_stop::TurnStop::iteration_cap()),
+ stop: Some(tinyagents_harness::turn_stop::TurnStop::iteration_cap()),
})
.await
.unwrap();
@@ -58,7 +58,7 @@ async fn drain_to_log_returns_the_turns_stop() {
let stop = drain_to_log(rx, path.clone()).await;
assert_eq!(
stop,
- Some(crate::agent::turn_stop::TurnStop::iteration_cap())
+ Some(tinyagents_harness::turn_stop::TurnStop::iteration_cap())
);
let log = std::fs::read_to_string(&path).expect("log written");
assert!(log.contains("stopped: iteration_cap"), "{log}");