Skip to content

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

feat(embed): add agent build module and runtime wiring

Steven Enamakelccf747760437
diff --git a/crates/openhuman-embed/Cargo.toml b/crates/openhuman-embed/Cargo.toml
index 178e54dabd..1f3ff54b4b 100644
--- a/crates/openhuman-embed/Cargo.toml
+++ b/crates/openhuman-embed/Cargo.toml
@@ -43,6 +43,10 @@ tinymemory-api = { path = "../../vendor/tinymemory/crates/tinymemory-api" }
tinymemory-tools = { path = "../../vendor/tinymemory/crates/tinymemory-tools" }
# Construct the owned wire config directly; core adds host disclosure policy.
tinymcp-bus = { path = "../../vendor/tinymcp/crates/tinymcp-bus" }
+# The session store port (`SessionStoreProvider`) a host implements to keep
+# conversations in its own database, and the in-memory provider; same path as
+# the core's so one copy resolves.
+tinyagents-session = { path = "../../vendor/tinyagents/crates/tinyagents-session" }
tokio = { version = "1", features = ["macros", "rt-multi-thread", "sync", "time"] }
url = "2"
uuid = { version = "1", features = ["v4"] }
diff --git a/crates/openhuman-embed/src/agent/build.rs b/crates/openhuman-embed/src/agent/build.rs
index aaa859e67e..307fb323c9 100644
--- a/crates/openhuman-embed/src/agent/build.rs
+++ b/crates/openhuman-embed/src/agent/build.rs
@@ -162,6 +162,8 @@ pub(crate) fn instantiate(runtime: &Runtime, spec: AgentSpec) -> Result<AgentInn
domains,
tool_groups,
user_skill_roots: parts.include_user_skills,
+ // A host session store keeps each agent's conversations apart by id.
+ session_agent: Some(id.to_string()),
};
let ctx = runtime.core_runtime().context().derive_with(overlay);
diff --git a/crates/openhuman-embed/src/runtime/mod.rs b/crates/openhuman-embed/src/runtime/mod.rs
index f52e1a93c0..c2262ebfbe 100644
--- a/crates/openhuman-embed/src/runtime/mod.rs
+++ b/crates/openhuman-embed/src/runtime/mod.rs
@@ -126,6 +126,13 @@ pub enum RuntimeError {
/// [`RuntimeBuilder::api_key`] was given a blank key.
#[error("the TinyHumans API key is blank")]
BlankApiKey,
+
+ /// [`Workspace::Stateless`](crate::Workspace::Stateless) was asked for
+ /// without a [`RuntimeBuilder::session_store`] to keep conversations in.
+ #[error(
+ "a stateless workspace keeps no conversations on disk; give the runtime a session store"
+ )]
+ NoSessionStore,
}
/// The process-scoped state a [`Runtime`] and every [`Agent`](crate::Agent)
@@ -146,6 +153,9 @@ pub(crate) struct CoreGuard {
/// Held for its `Drop`: an ephemeral workspace lives exactly as long as
/// the last owner of this guard.
workspace: ResolvedWorkspace,
+ /// Whether this runtime installed the process's session store, which is
+ /// removed with it.
+ session_store: bool,
}
impl Drop for CoreGuard {
@@ -154,6 +164,9 @@ impl Drop for CoreGuard {
// first lets another builder initialize process-scoped state while
// this runtime's keyring, bearer, event bus and subscribers are live.
drop(self.core.take());
+ if self.session_store {
+ openhuman_core::agent::session_store::clear();
+ }
// For an ephemeral workspace, take ownership of the temp path and
// remove it with a short retry. The core's memory/session writers keep
// running a moment after a turn returns and can recreate workspace
@@ -350,10 +363,12 @@ impl Runtime {
&self.access
}
+ #[allow(clippy::too_many_arguments)]
#[allow(clippy::too_many_arguments)]
pub(crate) fn new(
core: Core,
workspace: ResolvedWorkspace,
+ session_store: bool,
base_config: Config,
inherited: bool,
domains: DomainSet,
@@ -366,6 +381,7 @@ impl Runtime {
guard: Arc::new(CoreGuard {
core: Some(core),
workspace,
+ session_store,
}),
base_config,
inherited,