Skip to content

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

chore(core): remove unused imports across runtime and web chat

Steven Enamakela5b6e4957832
diff --git a/crates/openhuman-core/src/core/runtime/bootstrap.rs b/crates/openhuman-core/src/core/runtime/bootstrap.rs
index d7c78e057b..bd0de7e726 100644
--- a/crates/openhuman-core/src/core/runtime/bootstrap.rs
+++ b/crates/openhuman-core/src/core/runtime/bootstrap.rs
@@ -94,8 +94,8 @@ pub(crate) async fn bootstrap_core_runtime(
// Stamp them as `Interrupted` so the UI can offer a retry without
// confusing a stale `Streaming` lifecycle for an in-flight turn.
//
- // A host session store holds turn snapshots and runs per agent, not under
- // this workspace, so it does its own repair, once, instead of both sweeps.
+ // An installed host session store repairs itself, once; with none, the
+ // workspace default store is swept.
let host_store = crate::agent::session_store::installed();
if let Some(provider) = &host_store {
match provider.recover() {
@@ -105,10 +105,9 @@ pub(crate) async fn bootstrap_core_runtime(
}
if host_store.is_none() {
let now = chrono::Utc::now().to_rfc3339();
- match tinyagents_session::turn_state::store::mark_all_interrupted(
- workspace_dir.clone(),
- &now,
- ) {
+ match crate::agent::session_store::default_turn_states_for(&workspace_dir)
+ .mark_all_interrupted(&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 c4dff0f347..7be0aeacb2 100644
--- a/crates/openhuman-core/src/flows/ops/streaming.rs
+++ b/crates/openhuman-core/src/flows/ops/streaming.rs
@@ -50,7 +50,7 @@ impl FlowStreamTarget {
/// Attach the web-channel progress bridge to `agent` for a builder/scout turn.
/// Wires an mpsc channel into the agent's progress sink and spawns the bridge
/// task that translates each [`AgentProgress`] into a socket event keyed by the
-/// target thread (and mirrors a `TurnStateStore` so the tool timeline replays
+/// target thread (and mirrors the `TurnStates` port so the tool timeline replays
/// on reopen). The bridge task lives until the agent drops its progress sender
/// (turn end). `source` is a short trace-attribution label (e.g.
/// `"flows_build"`).
@@ -74,7 +74,7 @@ pub(super) fn attach_flow_progress_bridge(
"system".to_string(),
target.thread_id.clone(),
target.request_id.clone(),
- tinyagents_session::turn_state::TurnStateStore::new(config.workspace_dir.clone()),
+ crate::agent::session_store::turn_states_for(&config.workspace_dir),
crate::web_chat::ChatRequestMetadata {
source: Some(source.to_string()),
..Default::default()
@@ -148,7 +148,7 @@ pub(super) async fn finalize_flow_stream(
};
let now = chrono::Utc::now().to_rfc3339();
if let Err(err) =
- tinyagents_session::turn_state::TurnStateStore::new(config.workspace_dir.clone())
+ crate::agent::session_store::turn_states_for(&config.workspace_dir)
.settle_turn(&target.thread_id, &target.request_id, lifecycle, &now)
{
tracing::warn!(
diff --git a/crates/openhuman-core/src/profiles/recovery.rs b/crates/openhuman-core/src/profiles/recovery.rs
index 688bf76a5d..d0fb08b9e1 100644
--- a/crates/openhuman-core/src/profiles/recovery.rs
+++ b/crates/openhuman-core/src/profiles/recovery.rs
@@ -16,10 +16,9 @@ use crate::core::runtime::CoreContext;
/// opens.
pub(crate) fn recover_workspace(id: &ProfileId, workspace_dir: &std::path::Path) {
let now = chrono::Utc::now().to_rfc3339();
- match tinyagents_session::turn_state::store::mark_all_interrupted(
- workspace_dir.to_path_buf(),
- &now,
- ) {
+ match crate::agent::session_store::default_turn_states_for(workspace_dir)
+ .mark_all_interrupted(&now)
+ {
Ok(0) => {}
Ok(turns) => log::info!("[profiles] profile={id} recovered {turns} interrupted turn(s)"),
Err(error) => log::warn!("[profiles] profile={id} turn recovery failed: {error}"),
diff --git a/crates/openhuman-core/src/threads/ops/edit.rs b/crates/openhuman-core/src/threads/ops/edit.rs
index 0e23442cc4..e3d7fed953 100644
--- a/crates/openhuman-core/src/threads/ops/edit.rs
+++ b/crates/openhuman-core/src/threads/ops/edit.rs
@@ -373,12 +373,13 @@ async fn clear_dropped_turn_states(
thread_id: &str,
cut_request_id: &str,
) {
- let dir = workspace_dir.to_path_buf();
+ // Resolved here, not in the blocking task: the tenant is task-local.
+ let store = crate::agent::session_store::turn_states_for(workspace_dir);
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 =
- tinyagents_session::turn_state::store::list_thread(dir.clone(), &thread_id_owned)?;
+ store.list_thread(&thread_id_owned)?;
let Some(cut_started_at) = turns
.iter()
.find(|t| t.request_id == cut_request_id_owned)
@@ -386,20 +387,13 @@ 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 tinyagents_session::turn_state::store::delete_turn(
- dir,
- &thread_id_owned,
- &cut_request_id_owned,
- );
+ return store.delete_turn(&thread_id_owned, &cut_request_id_owned);
};
let mut removed_any = false;
for turn in turns.into_iter().filter(|t| t.started_at >= cut_started_at) {
- if tinyagents_session::turn_state::store::delete_turn(
- dir.clone(),
- &thread_id_owned,
- &turn.request_id,
- )
- .unwrap_or(false)
+ if store
+ .delete_turn(&thread_id_owned, &turn.request_id)
+ .unwrap_or(false)
{
removed_any = true;
}
diff --git a/crates/openhuman-core/src/web_chat/progress_bridge.rs b/crates/openhuman-core/src/web_chat/progress_bridge.rs
index 4fbdf78a2f..40df766103 100644
--- a/crates/openhuman-core/src/web_chat/progress_bridge.rs
+++ b/crates/openhuman-core/src/web_chat/progress_bridge.rs
@@ -1,5 +1,5 @@
//! Forwards a running turn's `AgentProgress` stream into `WebChannelEvent`
-//! socket events and mirrors it into `TurnStateStore`. Also emits the
+//! socket events and mirrors it into the `TurnStates` port. Also emits the
//! `inference_heartbeat` liveness beat (see [`INFERENCE_HEARTBEAT_SECS`])
//! so a long silent prefill can't trip the frontend's ~120s silence timeout.
@@ -7,7 +7,8 @@ use serde_json::json;
use crate::threads::turn_state::mirror::ObserveProgress;
use crate::web_chat::{SubagentProgressDetail, WebChannelEvent};
-use tinyagents_session::turn_state::{TurnStateMirror, TurnStateStore};
+use tinyagents_session::port::TurnStates;
+use tinyagents_session::turn_state::TurnStateMirror;
use super::event_bus::publish_web_channel_event;
use super::types::ChatRequestMetadata;
@@ -272,7 +273,7 @@ pub(crate) fn spawn_progress_bridge(
client_id: String,
thread_id: String,
request_id: String,
- turn_state_store: TurnStateStore,
+ turn_state_store: Arc<dyn TurnStates>,
metadata: ChatRequestMetadata,
config: crate::config::Config,
) -> ProgressBridgeHandle {
diff --git a/crates/openhuman-core/src/web_chat/run_task.rs b/crates/openhuman-core/src/web_chat/run_task.rs
index f3c8051754..c9d37dd7ba 100644
--- a/crates/openhuman-core/src/web_chat/run_task.rs
+++ b/crates/openhuman-core/src/web_chat/run_task.rs
@@ -9,7 +9,6 @@ use tinyagents_harness::run_queue::RunQueue;
use crate::agent::progress::AgentProgress;
use crate::config::rpc as config_rpc;
-use tinyagents_session::turn_state::TurnStateStore;
use super::ops::BudgetCorrelation;
use super::progress_bridge::spawn_progress_bridge;
@@ -158,7 +157,7 @@ pub(crate) async fn run_chat_task(
agent.set_on_progress(Some(progress_tx));
agent.set_run_queue(Some(run_queue));
agent.set_thread_id(Some(thread_id));
- let turn_state_store = TurnStateStore::new(config.workspace_dir.clone());
+ let turn_state_store = crate::agent::session_store::turn_states_for(&config.workspace_dir);
// Stamp the resolved agent onto the bridge metadata so the trace exporter
// can attribute the run (`agent.id` attr / `agent.turn:<id>` trace name).
let mut bridge_metadata = metadata.clone();
@@ -358,7 +357,7 @@ pub(crate) async fn run_chat_task(
tinyagents_session::turn_state::TurnLifecycle::Interrupted
};
let now = chrono::Utc::now().to_rfc3339();
- if let Err(err) = TurnStateStore::new(config.workspace_dir.clone())
+ if let Err(err) = crate::agent::session_store::turn_states_for(&config.workspace_dir)
.settle_turn(thread_id, request_id, lifecycle, &now)
{
log::warn!(