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/storage/import/sessions.rs

Steven Enamakel3ff8b22374cc
diff --git a/crates/openhuman-core/src/storage/import/sessions.rs b/crates/openhuman-core/src/storage/import/sessions.rs
index f320444154..1724df9f60 100644
--- a/crates/openhuman-core/src/storage/import/sessions.rs
+++ b/crates/openhuman-core/src/storage/import/sessions.rs
@@ -33,7 +33,8 @@ use std::sync::Arc;
use anyhow::{Context, Result};
use tinyagents_session::legacy::{
- import_transcripts, import_turn_states, QuiescentSource, SourceOwner,
+ import_transcripts, import_turn_states, ImportCounts, LegacyDatabaseReport, QuiescentSource,
+ SourceOwner,
};
use tinyagents_session::transcript::{session_stem, SessionRef};
use tinyagents_session::DriverSessionStores;
@@ -88,23 +89,9 @@ fn import(backend: &Arc<dyn StorageBackend>, config: &Config) -> Result<Outcome>
Ok(ledger.import_legacy_database(&source).await)
})?
.context("[sessions] import sessions.db")?;
- for counts in [
- report.sessions,
- report.messages,
- report.tool_calls,
- report.agent_runs,
- report.telemetry,
- report.events,
- report.workflow_runs,
- report.teams,
- report.members,
- report.tasks,
- report.tool_effects,
- report.entries,
- ] {
- found += counts.read;
- written += counts.imported;
- }
+ let (database_found, database_written) = database_totals(&report);
+ found += database_found;
+ written += database_written;
}
if raw.is_dir() {
@@ -128,6 +115,28 @@ fn import(backend: &Arc<dyn StorageBackend>, config: &Config) -> Result<Outcome>
})
}
+/// The native importer reports source rows per stored family. FTS rows are a
+/// derived index and do not represent additional legacy records.
+fn database_totals(report: &LegacyDatabaseReport) -> (usize, usize) {
+ [
+ report.sessions,
+ report.messages,
+ report.tool_calls,
+ report.agent_runs,
+ report.telemetry,
+ report.events,
+ report.workflow_runs,
+ report.teams,
+ report.members,
+ report.tasks,
+ report.tool_effects,
+ ]
+ .into_iter()
+ .fold((0, 0), |(found, written), ImportCounts { read, imported, .. }| {
+ (found + read, written + imported)
+ })
+}
+
/// The agent definitions a stem may belong to, by the component their ids
/// encode to in a stem.
fn known_agents() -> HashMap<String, String> {