The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(threads): correct mirror state handling for artifact offload and progress bridge
Steven Enamakele0a03e6b93a8
diff --git a/crates/openhuman-core/src/agent/harness/artifact_offload/artifact_offload_tests.rs b/crates/openhuman-core/src/agent/harness/artifact_offload/artifact_offload_tests.rsindex 126c532e9f..e4f6af35f6 100644--- a/crates/openhuman-core/src/agent/harness/artifact_offload/artifact_offload_tests.rs+++ b/crates/openhuman-core/src/agent/harness/artifact_offload/artifact_offload_tests.rs@@ -11,7 +11,6 @@//! redacting writer, since the whole point of `new_artifact_offload` is that//! no call site can construct one without both.-use std::collections::HashSet;use std::path::PathBuf;use std::sync::Arc;diff --git a/crates/openhuman-core/src/threads/turn_state/mirror/observe.rs b/crates/openhuman-core/src/threads/turn_state/mirror/observe.rsindex 0f7d8bd8f2..0e82d86dde 100644--- a/crates/openhuman-core/src/threads/turn_state/mirror/observe.rs+++ b/crates/openhuman-core/src/threads/turn_state/mirror/observe.rs@@ -10,7 +10,7 @@ use crate::agent::progress::AgentProgress;use tinyagents_session::turn_state::mirror::caps::{cap_persisted_args, cap_persisted_output};use tinyagents_session::turn_state::types::{PersistedToolFailure, SubagentActivity, SubagentToolCall, SubagentTranscriptItem,- ToolTimelineEntry, ToolTimelineStatus, TurnLifecycle, TurnPhase, TurnState,+ ToolTimelineEntry, ToolTimelineStatus, TurnLifecycle, TurnPhase,};use tinyagents_session::turn_state::TurnStateMirror;diff --git a/crates/openhuman-core/src/threads/turn_state/mirror_finish_and_subagent_args_tests.rs b/crates/openhuman-core/src/threads/turn_state/mirror_finish_and_subagent_args_tests.rsindex 380682516b..7dd17d6f8b 100644--- a/crates/openhuman-core/src/threads/turn_state/mirror_finish_and_subagent_args_tests.rs+++ b/crates/openhuman-core/src/threads/turn_state/mirror_finish_and_subagent_args_tests.rs@@ -111,109 +111,6 @@ fn subagent_transcript_persists_interleaved_prose_and_tools() {);}-/// When a streaming turn is interrupted and a root transcript already exists,-/// `finish()` appends the partial streamed answer (display-only) to the file.-#[test]-fn finish_appends_interrupted_partial_to_existing_transcript() {- let dir = tempdir().expect("tempdir");- let thread_id = "thr_abc";- let path = seed_root_transcript(dir.path(), thread_id);-- let store = TurnStateStore::new(dir.path().to_path_buf());- let mut m = TurnStateMirror::new(store, thread_id, "req-9");- m.observe(&AgentProgress::IterationStarted {- iteration: 2,- max_iterations: 25,- });- m.observe(&AgentProgress::ThinkingDelta {- delta: "hmm".into(),- iteration: 2,- });- m.observe(&AgentProgress::TextDelta {- delta: "half an ".into(),- iteration: 2,- });- m.observe(&AgentProgress::TextDelta {- delta: "answer".into(),- iteration: 2,- });- // No TurnCompleted — the bridge exits, marking the turn interrupted.- m.finish();-- // Model context must NOT carry the partial.- let model = read_transcript(&path).expect("read model context");- assert!(- !model- .messages- .iter()- .any(|msg| msg.content.contains("half an answer")),- "interrupted partial must be excluded from the model context"- );-- // Display projection carries the flagged partial with request_id + thinking.- let display = read_transcript_display(&path).expect("read display");- let partial = display- .records- .iter()- .find_map(|r| match r {- DisplayRecord::Message(msg) if msg.interrupted => Some(msg),- _ => None,- })- .expect("display must include the interrupted partial");- assert_eq!(partial.message.content, "half an answer");- assert_eq!(partial.request_id.as_deref(), Some("req-9"));- assert_eq!(partial.iteration, Some(2));- assert_eq!(partial.reasoning_content.as_deref(), Some("hmm"));-}--/// A completed turn never writes an interrupted partial.-#[test]-fn finish_after_completion_writes_no_partial() {- let dir = tempdir().expect("tempdir");- let thread_id = "thr_done";- let path = seed_root_transcript(dir.path(), thread_id);-- let store = TurnStateStore::new(dir.path().to_path_buf());- let mut m = TurnStateMirror::new(store, thread_id, "req-done");- m.observe(&AgentProgress::TextDelta {- delta: "final answer".into(),- iteration: 1,- });- m.observe(&AgentProgress::TurnCompleted { iterations: 1 });- m.finish();-- let display = read_transcript_display(&path).expect("read display");- assert!(- !display- .records- .iter()- .any(|r| matches!(r, DisplayRecord::Message(msg) if msg.interrupted)),- "a completed turn must not append an interrupted partial"- );-}--/// An interrupted FIRST turn (no root transcript file yet) is a no-op — the-/// partial stays in the turn_state snapshot only, and finish() does not panic.-#[test]-fn finish_first_turn_without_transcript_is_noop() {- let dir = tempdir().expect("tempdir");- let store = TurnStateStore::new(dir.path().to_path_buf());- let mut m = TurnStateMirror::new(store, "thr_new", "req-first");- m.observe(&AgentProgress::TextDelta {- delta: "orphan partial".into(),- iteration: 1,- });- // Must not panic even though no session_raw transcript exists.- m.finish();- // The snapshot itself still records the interrupted turn.- let listed = TurnStateStore::new(dir.path().to_path_buf())- .get("thr_new")- .expect("get")- .expect("snapshot present");- assert_eq!(listed.lifecycle, TurnLifecycle::Interrupted);- assert_eq!(listed.streaming_text, "orphan partial");-}-/// A sub-agent's child tool call must persist the arguments it was invoked/// with. Live, the `subagent_tool_call` socket event carries them; before/// #5987 the snapshot did not, so a reloaded child row came back with nodiff --git a/crates/openhuman-core/src/threads/turn_state/mirror_tests.rs b/crates/openhuman-core/src/threads/turn_state/mirror_tests.rsindex 7605d0e0b4..d5b6830cdb 100644--- a/crates/openhuman-core/src/threads/turn_state/mirror_tests.rs+++ b/crates/openhuman-core/src/threads/turn_state/mirror_tests.rs@@ -11,46 +11,6 @@ fn fresh(thread_id: &str) -> (tempfile::TempDir, TurnStateMirror) {(dir, mirror)}-// ── Interrupted-partial → session transcript wiring (Task 1) ──────────--use tinyagents_session::transcript::{- self, read_transcript, read_transcript_display, DisplayRecord, TranscriptMessage,- TranscriptMeta,-};--fn seed_root_transcript(workspace: &std::path::Path, thread_id: &str) -> std::path::PathBuf {- let stem = "100_orchestrator".to_string();- let path = transcript::resolve_keyed_transcript_path(workspace, &stem).expect("resolve path");- let meta = TranscriptMeta {- session_id: None,- parent_session_id: None,- agent_name: "orchestrator".into(),- agent_id: None,- agent_type: Some("root".into()),- dispatcher: "native".into(),- provider: None,- model: None,- created: "2026-07-21T00:00:00Z".into(),- updated: "2026-07-21T00:00:00Z".into(),- turn_count: 1,- prefix_message_count: None,- input_tokens: 0,- output_tokens: 0,- cached_input_tokens: 0,- charged_amount_usd: 0.0,- thread_id: Some(thread_id.to_string()),- task_id: None,- };- transcript::write_transcript(- &path,- &[TranscriptMessage::new("user", "hello there")],- &meta,- None,- )- .expect("seed transcript");- path-}-#[path = "mirror_finish_and_subagent_args_tests.rs"]mod finish_and_subagent_args_tests;#[path = "mirror_observe_tests.rs"]diff --git a/crates/openhuman-core/src/web_chat/progress_bridge.rs b/crates/openhuman-core/src/web_chat/progress_bridge.rsindex 370791cf70..552a68c759 100644--- a/crates/openhuman-core/src/web_chat/progress_bridge.rs+++ b/crates/openhuman-core/src/web_chat/progress_bridge.rs@@ -5,9 +5,9 @@use serde_json::json;-use crate::threads::turn_state::TurnStateMirror;+use crate::threads::turn_state::mirror::ObserveProgress;use crate::web_chat::{SubagentProgressDetail, WebChannelEvent};-use tinyagents_session::turn_state::TurnStateStore;+use tinyagents_session::turn_state::{TurnStateMirror, TurnStateStore};use super::event_bus::publish_web_channel_event;use super::types::ChatRequestMetadata;