Skip to content

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

docs(storage): update session import module documentation

Steven Enamakelf99c2af97817
diff --git a/crates/openhuman-core/src/storage/import/sessions.rs b/crates/openhuman-core/src/storage/import/sessions.rs
index dfb7507ccb..64f636401e 100644
--- a/crates/openhuman-core/src/storage/import/sessions.rs
+++ b/crates/openhuman-core/src/storage/import/sessions.rs
@@ -3,10 +3,10 @@
//! Before the storage ports a workspace kept its conversation state in three
//! shapes: a SQLite `session_db/sessions.db` (session history, the run ledger,
//! entry trees), JSONL transcripts under `session_raw/`, and per-turn
-//! snapshots as JSON under `memory/conversations/turn_states/`. TinyAgents owns
-//! those formats and the importer that reads them
-//! (`tinyagents_session::legacy`): read-only, id-preserving, only-if-absent.
-//! This module is the host's side of it:
+//! snapshots as JSON under `memory/conversations/turn_states/`. OpenHuman owns
+//! the historical file readers and imports their decoded public records into
+//! TinyAgents' current storage ports. The readers are read-only, id-preserving,
+//! and only-if-absent. This module handles:
//!
//! - **Quiescence.** The importer refuses a database with a WAL or journal
//! sidecar, so `sessions.db` is first copied to a consistent scratch
diff --git a/crates/openhuman-core/src/storage/import/sessions_tests.rs b/crates/openhuman-core/src/storage/import/sessions_tests.rs
index 9953e4340a..74b984a6a2 100644
--- a/crates/openhuman-core/src/storage/import/sessions_tests.rs
+++ b/crates/openhuman-core/src/storage/import/sessions_tests.rs
@@ -21,6 +21,38 @@ fn backend() -> Arc<dyn StorageBackend> {
Arc::new(MemoryStorage::new())
}
+#[test]
+fn host_jsonl_reader_preserves_meta_usage_typed_rows_and_tool_state() {
+ use tinyagents_session::transcript::DisplayRecord;
+
+ let dir = TempDir::new().unwrap();
+ let path = dir.path().join("thread.orchestrator.jsonl");
+ std::fs::write(
+ &path,
+ concat!(
+ "{\"_meta\":{\"agent\":\"Orchestrator\",\"agent_id\":\"orchestrator\",\"dispatcher\":\"native\",\"created\":\"2026-01-01T00:00:00Z\",\"updated\":\"2026-01-02T00:00:00Z\",\"turn_count\":2,\"input_tokens\":7,\"output_tokens\":3,\"cached_input_tokens\":1,\"charged_amount_usd\":0.25,\"thread_id\":\"thread\"}}\n",
+ "{\"kind\":\"tools\",\"tools\":[{\"name\":\"lookup\"}]}\n",
+ "{\"role\":\"assistant\",\"content\":\"answer\",\"provider\":\"local\",\"model\":\"m1\",\"usage\":{\"input\":7,\"output\":3,\"cost_usd\":0.25},\"ts\":\"2026-01-02T00:00:00Z\",\"request_id\":\"r1\",\"iteration\":2}\n",
+ "{\"role\":\"user\",\"content\":\"old envelope\",\"tool_call_id\":\"call-1\"}\n"
+ ),
+ )
+ .unwrap();
+
+ let (meta, tools, records) = super::decode_transcript(&path).unwrap();
+ assert_eq!(meta.agent_name, "Orchestrator");
+ assert_eq!(meta.input_tokens, 7);
+ assert_eq!(tools.unwrap()[0]["name"], "lookup");
+ let DisplayRecord::Message(answer) = &records[0] else {
+ panic!("expected message record");
+ };
+ assert_eq!(answer.message.request_id.as_deref(), Some("r1"));
+ assert_eq!(answer.message.turn_usage.as_ref().unwrap().iteration, 2);
+ let DisplayRecord::Message(row) = &records[1] else {
+ panic!("expected typed row");
+ };
+ assert_eq!(row.message.tool_call_id.as_deref(), Some("call-1"));
+}
+
/// Every file under `root` with a digest of its bytes.
fn tree(root: &Path) -> BTreeMap<String, String> {
fn walk(dir: &Path, root: &Path, out: &mut BTreeMap<String, String>) {