Skip to content

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

chore: files changed crates/openhuman-core/src/threads/turn_state/mirror.rs,crates/openhuman-core/sr

Steven Enamakel9f40e6b1de70
diff --git a/crates/openhuman-core/src/threads/turn_state/mirror.rs b/crates/openhuman-core/src/threads/turn_state/mirror.rs
index f50af4ae98..6d5f30d927 100644
--- a/crates/openhuman-core/src/threads/turn_state/mirror.rs
+++ b/crates/openhuman-core/src/threads/turn_state/mirror.rs
@@ -13,21 +13,19 @@
//! replay the finished turn. If the bridge exits without ever observing
//! `TurnCompleted` (for example because the agent loop returned an error),
//! the snapshot is flagged [`TurnLifecycle::Interrupted`] and persisted so
-//! the UI can surface a retry affordance.
+//! the UI can surface a retry affordance. The mirror type and that
+//! finalization live in `tinyagents_session::turn_state::TurnStateMirror`.
#[cfg(test)]
#[path = "mirror_tests.rs"]
mod tests;
-mod caps;
-mod lifecycle;
mod observe;
-mod state;
-pub use state::TurnStateMirror;
+pub use observe::ObserveProgress;
#[cfg(test)]
-pub(crate) use caps::MAX_PERSISTED_TRANSCRIPT_ITEM;
+use tinyagents_session::turn_state::mirror::MAX_PERSISTED_TRANSCRIPT_ITEM;
#[cfg(test)]
use tinyagents_session::turn_state::store::TurnStateStore;
#[cfg(test)]
@@ -35,3 +33,5 @@ use tinyagents_session::turn_state::types::{
SubagentToolCall, SubagentTranscriptItem, ToolTimelineStatus, TranscriptItem, TurnLifecycle,
TurnPhase,
};
+#[cfg(test)]
+use tinyagents_session::turn_state::TurnStateMirror;
diff --git a/crates/openhuman-core/src/threads/turn_state/mirror/observe.rs b/crates/openhuman-core/src/threads/turn_state/mirror/observe.rs
index 7e1c2164ef..0f7d8bd8f2 100644
--- a/crates/openhuman-core/src/threads/turn_state/mirror/observe.rs
+++ b/crates/openhuman-core/src/threads/turn_state/mirror/observe.rs
@@ -1,19 +1,29 @@
-//! Translating one [`AgentProgress`] event into a [`TurnState`] mutation,
-//! plus the transcript/tool-timeline bookkeeping helpers `observe` relies on.
+//! Translating one [`AgentProgress`] event into a [`TurnState`] mutation.
+//!
+//! The mirror itself (snapshot, flush, caps, transcript bookkeeping,
+//! interrupted-turn finalization) is
+//! `tinyagents_session::turn_state::TurnStateMirror`; this is the host-side
+//! progress projection over it.
use crate::agent::progress::AgentProgress;
-use super::caps::{append_capped_transcript_text, cap_persisted_args, cap_persisted_output};
-use super::state::TurnStateMirror;
+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, TranscriptItem, TurnLifecycle, TurnPhase,
+ ToolTimelineEntry, ToolTimelineStatus, TurnLifecycle, TurnPhase, TurnState,
};
+use tinyagents_session::turn_state::TurnStateMirror;
-impl TurnStateMirror {
+/// Host extension of the upstream mirror: fold one [`AgentProgress`] event into
+/// the snapshot.
+pub trait ObserveProgress {
/// Apply one progress event to the in-memory snapshot. Returns `true`
/// if the event triggered a disk flush.
- pub fn observe(&mut self, event: &AgentProgress) -> bool {
+ fn observe(&mut self, event: &AgentProgress) -> bool;
+}
+
+impl ObserveProgress for TurnStateMirror {
+ fn observe(&mut self, event: &AgentProgress) -> bool {
self.state.updated_at = chrono::Utc::now().to_rfc3339();
match event {
AgentProgress::TurnStarted => {
diff --git a/crates/openhuman-core/src/threads/turn_state/mod.rs b/crates/openhuman-core/src/threads/turn_state/mod.rs
index b0e7b314ac..877fce3f78 100644
--- a/crates/openhuman-core/src/threads/turn_state/mod.rs
+++ b/crates/openhuman-core/src/threads/turn_state/mod.rs
@@ -4,7 +4,8 @@
//! turn under the workspace, written atomically and serialized through a
//! process-wide mutex; `mark_all_interrupted` flags any non-terminal
//! snapshot left over from an unclean shutdown at cold boot.
-//! [`mirror::TurnStateMirror`] is the writer — it translates
+//! `tinyagents_session::turn_state::TurnStateMirror` is the writer — it is driven by
+//! [`mirror::ObserveProgress`], which translates
//! [`crate::agent::progress::AgentProgress`] events into [`types::TurnState`]
//! mutations and flushes to the store at iteration / tool boundaries (not on
//! every streaming delta), keeping `Completed` snapshots so the UI can replay
@@ -21,7 +22,6 @@
pub mod mirror;
pub mod rpc_types;
-pub use mirror::TurnStateMirror;
pub use rpc_types::{
ClearTurnStateRequest, ClearTurnStateResponse, GetTurnStateForRequestRequest,
GetTurnStateRequest, GetTurnStateResponse, ListTurnStatesResponse,