Skip to content

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

refactor: replace in-tree turn state references with tinyagents_session crate

Steven Enamakel388064891f2c
diff --git a/crates/openhuman-core/src/core/runtime/bootstrap.rs b/crates/openhuman-core/src/core/runtime/bootstrap.rs
index d1d938546e..647307d1d7 100644
--- a/crates/openhuman-core/src/core/runtime/bootstrap.rs
+++ b/crates/openhuman-core/src/core/runtime/bootstrap.rs
@@ -81,7 +81,7 @@ pub(crate) async fn bootstrap_core_runtime(
// confusing a stale `Streaming` lifecycle for an in-flight turn.
{
let now = chrono::Utc::now().to_rfc3339();
- match crate::threads::turn_state::store::mark_all_interrupted(workspace_dir.clone(), &now) {
+ match tinyagents_session::turn_state::store::mark_all_interrupted(workspace_dir.clone(), &now) {
Ok(0) => {}
Ok(count) => {
log::info!("[runtime] marked {count} stale turn snapshot(s) as interrupted")
diff --git a/crates/openhuman-core/src/flows/ops/streaming.rs b/crates/openhuman-core/src/flows/ops/streaming.rs
index 97a4ffd8fb..c4dff0f347 100644
--- a/crates/openhuman-core/src/flows/ops/streaming.rs
+++ b/crates/openhuman-core/src/flows/ops/streaming.rs
@@ -74,7 +74,7 @@ pub(super) fn attach_flow_progress_bridge(
"system".to_string(),
target.thread_id.clone(),
target.request_id.clone(),
- crate::threads::turn_state::TurnStateStore::new(config.workspace_dir.clone()),
+ tinyagents_session::turn_state::TurnStateStore::new(config.workspace_dir.clone()),
crate::web_chat::ChatRequestMetadata {
source: Some(source.to_string()),
..Default::default()
@@ -142,13 +142,13 @@ pub(super) async fn finalize_flow_stream(
// indicator under a reply that already landed.
if let Ok(config) = crate::config::rpc::load_config_with_timeout().await {
let lifecycle = if result.is_ok() {
- crate::threads::turn_state::TurnLifecycle::Completed
+ tinyagents_session::turn_state::TurnLifecycle::Completed
} else {
- crate::threads::turn_state::TurnLifecycle::Interrupted
+ tinyagents_session::turn_state::TurnLifecycle::Interrupted
};
let now = chrono::Utc::now().to_rfc3339();
if let Err(err) =
- crate::threads::turn_state::TurnStateStore::new(config.workspace_dir.clone())
+ tinyagents_session::turn_state::TurnStateStore::new(config.workspace_dir.clone())
.settle_turn(&target.thread_id, &target.request_id, lifecycle, &now)
{
tracing::warn!(
diff --git a/crates/openhuman-core/src/threads/ops/edit.rs b/crates/openhuman-core/src/threads/ops/edit.rs
index 6fc4791249..adec95db94 100644
--- a/crates/openhuman-core/src/threads/ops/edit.rs
+++ b/crates/openhuman-core/src/threads/ops/edit.rs
@@ -361,7 +361,7 @@ async fn clear_dropped_turn_states(
let thread_id_owned = thread_id.to_string();
let cut_request_id_owned = cut_request_id.to_string();
let result = tokio::task::spawn_blocking(move || {
- let turns = crate::threads::turn_state::store::list_thread(dir.clone(), &thread_id_owned)?;
+ let turns = tinyagents_session::turn_state::store::list_thread(dir.clone(), &thread_id_owned)?;
let Some(cut_started_at) = turns
.iter()
.find(|t| t.request_id == cut_request_id_owned)
@@ -369,7 +369,7 @@ async fn clear_dropped_turn_states(
else {
// Never got a snapshot (e.g. a turn that errored before its
// first progress event) — nothing to drop but itself.
- return crate::threads::turn_state::store::delete_turn(
+ return tinyagents_session::turn_state::store::delete_turn(
dir,
&thread_id_owned,
&cut_request_id_owned,
@@ -377,7 +377,7 @@ async fn clear_dropped_turn_states(
};
let mut removed_any = false;
for turn in turns.into_iter().filter(|t| t.started_at >= cut_started_at) {
- if crate::threads::turn_state::store::delete_turn(
+ if tinyagents_session::turn_state::store::delete_turn(
dir.clone(),
&thread_id_owned,
&turn.request_id,
diff --git a/crates/openhuman-core/src/threads/ops/edit_turn_state_tests.rs b/crates/openhuman-core/src/threads/ops/edit_turn_state_tests.rs
index 69841611f6..8388d4fddb 100644
--- a/crates/openhuman-core/src/threads/ops/edit_turn_state_tests.rs
+++ b/crates/openhuman-core/src/threads/ops/edit_turn_state_tests.rs
@@ -7,8 +7,8 @@
use super::*;
use crate::memory::conversations::{self, run_reply_message_id, ConversationMessage};
-use crate::threads::turn_state::store as turn_state_store;
-use crate::threads::turn_state::types::TurnState;
+use tinyagents_session::turn_state::store as turn_state_store;
+use tinyagents_session::turn_state::types::TurnState;
use serde_json::json;
use tempfile::TempDir;
diff --git a/crates/openhuman-core/src/web_chat/run_task.rs b/crates/openhuman-core/src/web_chat/run_task.rs
index 4e2d008761..140e1dc27c 100644
--- a/crates/openhuman-core/src/web_chat/run_task.rs
+++ b/crates/openhuman-core/src/web_chat/run_task.rs
@@ -9,7 +9,7 @@ use tinyagents_harness::run_queue::RunQueue;
use crate::agent::progress::AgentProgress;
use crate::config::rpc as config_rpc;
-use crate::threads::turn_state::TurnStateStore;
+use tinyagents_session::turn_state::TurnStateStore;
use super::ops::BudgetCorrelation;
use super::progress_bridge::spawn_progress_bridge;
@@ -302,9 +302,9 @@ pub(crate) async fn run_chat_task(
// `TurnCompleted` overwrites this with `Completed`, terminal either way.
{
let lifecycle = if result.is_ok() {
- crate::threads::turn_state::TurnLifecycle::Completed
+ tinyagents_session::turn_state::TurnLifecycle::Completed
} else {
- crate::threads::turn_state::TurnLifecycle::Interrupted
+ tinyagents_session::turn_state::TurnLifecycle::Interrupted
};
let now = chrono::Utc::now().to_rfc3339();
if let Err(err) = TurnStateStore::new(config.workspace_dir.clone())
diff --git a/tests/json_rpc_e2e.rs b/tests/json_rpc_e2e.rs
index 548fd4e489..db493a27e0 100644
--- a/tests/json_rpc_e2e.rs
+++ b/tests/json_rpc_e2e.rs
@@ -3036,16 +3036,16 @@ async fn json_rpc_thread_turn_state_lifecycle() {
.expect("load config");
cfg.workspace_dir
};
- let mut state = openhuman_core::threads::turn_state::TurnState::started(
+ let mut state = tinyagents_session::turn_state::TurnState::started(
"thread-turn-1",
"req-turn-1",
25,
chrono::Utc::now().to_rfc3339(),
);
- state.lifecycle = openhuman_core::threads::turn_state::TurnLifecycle::Streaming;
+ state.lifecycle = tinyagents_session::turn_state::TurnLifecycle::Streaming;
state.iteration = 2;
state.streaming_text = "partial".into();
- openhuman_core::threads::turn_state::store::put(workspace_dir.clone(), &state)
+ tinyagents_session::turn_state::store::put(workspace_dir.clone(), &state)
.expect("seed snapshot");
// get → present
@@ -3095,15 +3095,15 @@ async fn json_rpc_thread_turn_state_lifecycle() {
// both instead of overwriting.
// Far-future started_at guarantees turn-2 is the newest (turn-1 was seeded
// with the real `now()`), so history ordering is deterministic.
- let mut state2 = openhuman_core::threads::turn_state::TurnState::started(
+ let mut state2 = tinyagents_session::turn_state::TurnState::started(
"thread-turn-1",
"req-turn-2",
25,
"2999-01-01T00:00:00Z",
);
- state2.lifecycle = openhuman_core::threads::turn_state::TurnLifecycle::Completed;
+ state2.lifecycle = tinyagents_session::turn_state::TurnLifecycle::Completed;
state2.updated_at = "2999-01-01T00:00:00Z".into();
- openhuman_core::threads::turn_state::store::put(workspace_dir.clone(), &state2)
+ tinyagents_session::turn_state::store::put(workspace_dir.clone(), &state2)
.expect("seed snapshot 2");
// history → both turns, newest first.