Skip to content

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

feat(embed): add workspace harness and runtime module

Steven Enamakelef1deda4cac2
diff --git a/crates/openhuman-embed/src/harness/workspace.rs b/crates/openhuman-embed/src/harness/workspace.rs
index 8e669a8184..7cfac8ee19 100644
--- a/crates/openhuman-embed/src/harness/workspace.rs
+++ b/crates/openhuman-embed/src/harness/workspace.rs
@@ -1,12 +1,16 @@
//! Where the harness keeps its state.
//!
-//! Session history, memory, attachments and skills all live beneath one
-//! directory, and `tinyagents::session` keys its SQLite database on it
-//! (`{workspace}/session_db/sessions.db`). There is no storage trait to swap and
-//! the in-memory database variant is `#[cfg(test)]`, so **the workspace
-//! directory is the only storage axis an embedder has** — which is precisely why
-//! it is a first-class builder input rather than something discovered from the
+//! By default session history, memory, attachments and skills all live
+//! beneath one directory, and `tinyagents::session` keys its SQLite database on
+//! it (`{workspace}/session_db/sessions.db`), which is why the workspace is a
+//! first-class builder input rather than something discovered from the
//! environment.
+//!
+//! A host that keeps conversations in its own database instead gives the
+//! runtime a session store
+//! ([`RuntimeBuilder::session_store`](crate::RuntimeBuilder::session_store))
+//! and picks [`Workspace::Stateless`]: then nothing that must outlive the
+//! process is written to disk at all.
use std::path::{Path, PathBuf};
@@ -26,6 +30,17 @@ pub enum Workspace {
Ephemeral,
/// A caller-owned directory. Created if absent; persists across runs.
Dir(PathBuf),
+ /// No durable state on disk: every agent's transcripts, journal, goals and
+ /// todos go through the runtime's session store
+ /// ([`RuntimeBuilder::session_store`](crate::RuntimeBuilder::session_store)),
+ /// which is required.
+ ///
+ /// For a cloud host serving many users from one process, where a pod can
+ /// be replaced at any moment. A private scratch directory still backs the
+ /// core's process-local caches (cost log, app state, migration markers);
+ /// it is created like [`Workspace::Ephemeral`]'s and removed with the
+ /// runtime, so losing it loses nothing.
+ Stateless,
/// The machine's configured OpenHuman workspace — the one the desktop app
/// and CLI use, resolved the usual way (`OPENHUMAN_WORKSPACE`,
/// `active_user.toml`, `~/.openhuman/...`).
@@ -41,6 +56,11 @@ impl Workspace {
Self::Ephemeral
}
+ /// A workspace with no durable state on disk; see [`Workspace::Stateless`].
+ pub fn stateless() -> Self {
+ Self::Stateless
+ }
+
/// A caller-owned workspace directory.
pub fn dir(path: impl Into<PathBuf>) -> Self {
Self::Dir(path.into())
@@ -95,9 +115,13 @@ impl ResolvedWorkspace {
action_dir_override: Option<&Path>,
) -> Result<Self, HarnessError> {
match workspace {
- Workspace::Ephemeral => {
+ Workspace::Ephemeral | Workspace::Stateless => {
let temp = tempfile::Builder::new()
- .prefix("openhuman-harness-")
+ .prefix(if matches!(workspace, Workspace::Stateless) {
+ "openhuman-scratch-"
+ } else {
+ "openhuman-harness-"
+ })
.tempdir()
.map_err(|source| HarnessError::Workspace {
what: "create a temporary workspace",
diff --git a/crates/openhuman-embed/src/runtime/mod.rs b/crates/openhuman-embed/src/runtime/mod.rs
index c2262ebfbe..fec83e2cc8 100644
--- a/crates/openhuman-embed/src/runtime/mod.rs
+++ b/crates/openhuman-embed/src/runtime/mod.rs
@@ -363,7 +363,6 @@ impl Runtime {
&self.access
}
- #[allow(clippy::too_many_arguments)]
#[allow(clippy::too_many_arguments)]
pub(crate) fn new(
core: Core,