Skip to content

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

refactor(agent): drop progress_sink and turn_projection modules

Steven Enamakel256488eb556d
diff --git a/crates/openhuman-core/src/agent/mod.rs b/crates/openhuman-core/src/agent/mod.rs
index 77caf50680..3d00d7cbe1 100644
--- a/crates/openhuman-core/src/agent/mod.rs
+++ b/crates/openhuman-core/src/agent/mod.rs
@@ -45,11 +45,6 @@ pub mod plan_review;
/// agree on `cmd.exe` (Windows) vs `bash`/`sh` (Unix). Fixes #4705 where
/// the sandbox paths hardcoded `sh` and failed at spawn on Windows.
pub mod progress;
-/// Task-local [`progress::AgentProgress`] sink — how an in-process embedder
-/// observes a turn driven through an RPC that returns only a final string.
-/// Same shape as [`turn_origin`]; read by entry points that build the
-/// [`Agent`] internally (`inference::host_runtime::ops::agent_chat`).
-pub mod progress_sink;
/// Structured tracing export off the [`progress`] channel: turns the
/// real-time [`progress::AgentProgress`] stream into OpenTelemetry/
/// Langfuse-style spans (turn → iteration → tool / subagent) correlated by
@@ -87,9 +82,6 @@ pub mod turn_env;
/// origin-aware decisions rather than inferring trust from the absence of
/// a chat approval context.
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_projection;
pub use schemas::{
all_controller_schemas as all_agent_controller_schemas,
all_registered_controllers as all_agent_registered_controllers,
diff --git a/crates/openhuman-core/src/agent/progress_sink.rs b/crates/openhuman-core/src/agent/progress_sink.rs
deleted file mode 100644
index b4fe0b3540..0000000000
--- a/crates/openhuman-core/src/agent/progress_sink.rs
+++ /dev/null
@@ -1,28 +0,0 @@
-//! The [`AgentProgress`] channel type an **in-process embedder** hands a turn it
-//! drives through an RPC that only returns a final string.
-//!
-//! The agent harness already emits everything an embedder needs
-//! ([`AgentProgress`], attached with
-//! [`OpenHumanSessionHost::set_on_progress`](crate::agent::OpenHumanSessionHost::set_on_progress)),
-//! but entry points such as
-//! [`agent_chat_for`](crate::inference::host_runtime::ops::agent_chat_for) build
-//! the [`Agent`](crate::agent::OpenHumanSessionHost) internally and drop it, so
-//! there is no handle to attach a sink to. They therefore take the sink as an
-//! explicit argument (`ops::TurnSinks`) and attach it to the session they build:
-//! the sink reaches exactly the turn it was handed to and no other, including
-//! across a `tokio::spawn`, which an ambient scope would silently lose.
-//!
-//! An entry point must not clobber a sink an existing caller already attached
-//! explicitly (web chat, the platform socket, flows, skills all call
-//! `set_on_progress` themselves): where both could apply, the **explicitly-set
-//! sink wins**.
-
-use crate::agent::progress::AgentProgress;
-
-/// The channel an embedder hands to a turn, and the same type
-/// [`OpenHumanSessionHost::set_on_progress`](crate::agent::OpenHumanSessionHost::set_on_progress)
-/// takes — so it can be attached directly.
-///
-/// Use a bounded channel with headroom: the turn loop sends from inside the
-/// agent, so a slow or absent receiver applies backpressure to the turn itself.
-pub type ProgressSink = tokio::sync::mpsc::Sender<AgentProgress>;
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/mod.rs b/crates/openhuman-core/src/agent/subagent_host/ops/mod.rs
index 84d3dc24ef..776eb3bdc7 100644
--- a/crates/openhuman-core/src/agent/subagent_host/ops/mod.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops/mod.rs
@@ -16,7 +16,7 @@
//! | `runner.rs` | `run_subagent`, `run_typed_mode` |
//! | `graph.rs` | `run_subagent_via_graph` — the sub-agent turn graph + tools |
//! | `checkpoint.rs` | `SubagentCheckpoint` — cap-hit summary |
-//! | `pause_checkpoint.rs` | `write` — the on-disk pause snapshot for `continue_subagent` |
+//! | `pause_checkpoint.rs` | `is_safe_task_id` — validates model-provided checkpoint names |
mod checkpoint;
mod graph;
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/pause_checkpoint.rs b/crates/openhuman-core/src/agent/subagent_host/ops/pause_checkpoint.rs
index 90857e9b08..6a9c93f9b1 100644
--- a/crates/openhuman-core/src/agent/subagent_host/ops/pause_checkpoint.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops/pause_checkpoint.rs
@@ -1,23 +1,5 @@
-//! Persisting a paused sub-agent so `continue_subagent` can resume it.
-//!
-//! Distinct from [`super::checkpoint`], which summarises a *cap-hit* run into
-//! resumable prose. This one is the on-disk conversation snapshot written when
-//! a child exits early on `ask_user_clarification`.
+//! Validation for model-provided sub-agent checkpoint identifiers.
-/// Persist a paused sub-agent's conversation so `continue_subagent` can resume
-/// it, returning the path actually written or `None` when it could not be.
-///
-/// Every failure here is logged at `error`, not `warn`. A checkpoint that was
-/// not written is not a degraded nicety: the run is about to be reported as
-/// `AwaitingUser`, the orchestrator will relay a `task_id` and ask the user to
-/// answer, and the loss only becomes visible after they have — at which point
-/// the answer has nowhere to go. That late, invisible failure is what #5928's
-/// first acceptance criterion is about, and the `Option` this returns is what
-/// lets the caller stop promising a resumable pause it did not achieve.
-///
-/// Its own module so each failure branch is reachable from a test, and so
-/// `runner.rs` stays under the layout gate's line pin: point `checkpoint_dir` at a path that cannot be created, or at one
-/// whose target file cannot be written.
/// Whether `task_id` is usable as a single filename component.
///
/// This is untrusted input on its way into a path join. `continue_subagent`
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/runner_checkpoint_tests.rs b/crates/openhuman-core/src/agent/subagent_host/ops/runner_checkpoint_tests.rs
index f60a3c33c5..357e42e96d 100644
--- a/crates/openhuman-core/src/agent/subagent_host/ops/runner_checkpoint_tests.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops/runner_checkpoint_tests.rs
@@ -1,10 +1,17 @@
-//! `write_pause_checkpoint` — the pause-persistence contract (#5928).
-//!
-//! Every failure branch returns `None`, and that `None` is what stops the
-//! runner reporting a resumable `AwaitingUser` for a pause it never saved.
-//! Before this, all three failures were logged at `warn` and then dropped, so
-//! the orchestrator relayed a `task_id` and asked the user to answer a question
-//! whose answer had nowhere to go.
+//! Regression tests for checkpoint task identifiers and legacy payloads.
+
+use crate::agent::subagent_host::types::SubagentCheckpointData;
+
+fn checkpoint_data(task_id: &str) -> SubagentCheckpointData {
+ SubagentCheckpointData {
+ task_key: None, task_id: task_id.to_string(), agent_id: "researcher".to_string(),
+ worker_thread_id: None, history: Vec::new(), question: "Which region?".to_string(),
+ options: None, skill_filter_override: None, model_override: None,
+ created_at: "2026-09-02T00:00:00Z".to_string(), resume_checkpoint: None,
+ resume_metadata: Default::default(), output: String::new(), iterations: 0,
+ usage: Default::default(), artifact_paths: Vec::new(), elapsed_ms: 0,
+ }
+}
// ── task_id is untrusted on its way into a path (tinysweeper, #5951) ────────
//
diff --git a/crates/openhuman-core/src/agent/turn_projection.rs b/crates/openhuman-core/src/agent/turn_projection.rs
deleted file mode 100644
index a51564948a..0000000000
--- a/crates/openhuman-core/src/agent/turn_projection.rs
+++ /dev/null
@@ -1,58 +0,0 @@
-//! Host projection of harness turn-stop facts.
-//!
-//! The vocabulary (`TurnStop`, `TurnStopKind`, the breaker-note parsing) is
-//! owned by `tinyagents_harness::turn_stop`. OpenHuman keeps only the product
-//! mapping of a stop note without a failure class to its stop-reason key
-//! ([`StopReasonKind`](crate::agent::session_host::stop_summary::StopReasonKind)).
-
-use crate::agent::tinyagents::host::LastTurnUsage;
-use tinyagents_harness::cost::CostSource;
-use tinyagents_harness::middleware::ResponseUsage;
-use tinyagents_harness::turn_stop::TurnStop;
-
-/// The stop-reason key for a breaker note that names no failure class.
-pub fn stop_fallback_class(note: &str) -> &'static str {
- crate::agent::session_host::stop_summary::StopReasonKind::from_stop_note(note).key()
-}
-
-/// [`TurnStop::breaker`] with the OpenHuman stop-reason fallback.
-pub fn breaker_stop(note: &str) -> TurnStop {
- TurnStop::breaker(note, stop_fallback_class)
-}
-
-/// [`TurnStop::classify`] with the OpenHuman stop-reason fallback.
-pub fn classify_stop(
- breaker_halt: Option<&str>,
- wind_down: bool,
- hit_cap: bool,
-) -> Option<TurnStop> {
- TurnStop::classify(breaker_halt, wind_down, hit_cap, stop_fallback_class)
-}
-
-/// [`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)
-}
-
-/// Failure accounting for a turn the session has no completed-turn record
-/// for: the harness's reported [`ResponseUsage`] projected onto the product's
-/// [`LastTurnUsage`], priced `Charged` only when the provider reported a cost.
-pub fn failure_usage(usage: &ResponseUsage) -> LastTurnUsage {
- LastTurnUsage {
- input_tokens: usage.input_tokens,
- output_tokens: usage.output_tokens,
- cached_input_tokens: usage.cached_tokens,
- reasoning_tokens: usage.reasoning_tokens,
- cost_usd: usage.cost_usd,
- cost_source: if usage.cost_usd.is_some() {
- CostSource::Charged
- } else {
- CostSource::Unknown
- },
- ..Default::default()
- }
-}
-
-#[cfg(test)]
-#[path = "turn_projection_tests.rs"]
-mod tests;
diff --git a/crates/openhuman-core/src/agent/turn_projection_tests.rs b/crates/openhuman-core/src/agent/turn_projection_tests.rs
deleted file mode 100644
index a89279b3c7..0000000000
--- a/crates/openhuman-core/src/agent/turn_projection_tests.rs
+++ /dev/null
@@ -1,77 +0,0 @@
-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")
- );
-}
-
-#[test]
-fn reported_usage_projects_as_charged_only_with_a_cost() {
- let charged = failure_usage(&ResponseUsage {
- input_tokens: 10,
- output_tokens: 5,
- cached_tokens: 3,
- reasoning_tokens: 2,
- cost_usd: Some(0.007),
- has_cost_receipt: true,
- });
- assert_eq!(charged.cost_source, CostSource::Charged);
- assert_eq!(charged.cost_usd, Some(0.007));
- assert_eq!(
- (
- charged.input_tokens,
- charged.output_tokens,
- charged.cached_input_tokens,
- charged.reasoning_tokens
- ),
- (10, 5, 3, 2)
- );
- assert_eq!(
- failure_usage(&ResponseUsage::default()).cost_source,
- CostSource::Unknown
- );
-}
diff --git a/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat.rs b/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat.rs
index a903ce482a..b6276ed8d7 100644
--- a/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat.rs
+++ b/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat.rs
@@ -37,7 +37,7 @@ use super::turn_guards::{
/// # Progress
///
/// An in-process embedder hands a
-/// [`ProgressSink`](crate::agent::progress_sink::ProgressSink) through
+/// [`AgentProgress`](crate::agent::progress::AgentProgress) channel through
/// [`AgentChatEnv`] (see [`agent_chat_for`]); it is attached to the agent built
/// here, so the embedder observes the turn's tool calls and deltas live instead
/// of only its final string.
@@ -81,7 +81,7 @@ pub async fn agent_chat(
pub struct AgentChatEnv {
/// Live progress for the turn; `None` attaches a drain-only sink so the
/// model calls still stream.
- pub progress: Option<crate::agent::progress_sink::ProgressSink>,
+ pub progress: Option<tokio::sync::mpsc::Sender<crate::agent::progress::AgentProgress>>,
/// The host environment installed on the session
/// ([`OpenHumanSessionHost::set_host_env`]).
pub host: crate::agent::turn_env::HostTurnEnv,