The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
feat(memory): stamp agent call facts on the memory tool
Steven Enamakel189048da7848
diff --git a/crates/openhuman-cli/Cargo.toml b/crates/openhuman-cli/Cargo.tomlindex 9faf6e1148..645cfe9271 100644--- a/crates/openhuman-cli/Cargo.toml+++ b/crates/openhuman-cli/Cargo.toml@@ -344,6 +344,7 @@ uuid = { version = "1", features = ["v4"] }openhuman-core = { path = "../openhuman-core", package = "openhuman", default-features = false }openhuman-embed = { workspace = true }openhuman-tinyhumans = { workspace = true }+tinymemory-tools = { path = "../../vendor/tinymemory/crates/tinymemory-tools" }aes-gcm = "0.10"async-trait = "0.1"chrono = { version = "0.4", features = ["serde"] }diff --git a/crates/openhuman-core/src/memory/README.md b/crates/openhuman-core/src/memory/README.mdindex d2735efe7f..94c98d5481 100644--- a/crates/openhuman-core/src/memory/README.md+++ b/crates/openhuman-core/src/memory/README.md@@ -70,7 +70,7 @@ its team. It is explicit, never ambient: a turn's`OpenHumanRunContext::memory_identity` carries it (`Identity::child` for eachsub-agent, `team_member` from the team runtime through`HostTurnEnv::memory_identity`), and RPC/embed entry points construct-`Identity::root()`. OpenHuman projects its config once into upstream+`Identity::root()`. OpenHuman projects its config into upstream`IdentityPins` in [`scope.rs`](./scope.rs); `Identity::resolve(&pins)` returnsthe upstream `ResolvedIdentity` (layout root plus memory agent id), with thisfirst-match precedence:@@ -274,8 +274,8 @@ The `memory_*` RPC handlers apply TinyMemory `Confinement` with`Policy::Refuse`: an unset `reach` becomes the root identity's subtree, widerreaches return `INVALID_REQUEST`, and a `learn` with no namespace uses theidentity's learnings node. SaaS operations use `Policy::Clamp` selected from-the configured profile root in `ops.rs`. The agent `memory` tool keeps its-existing trusted reach and applies the same upstream confinement methods.+the configured profile root in `ops.rs`. The agent `memory` tool stamps its+trusted call facts; queued writes retain that call's narrower reach.## Layoutdiff --git a/crates/openhuman-core/src/memory/ops.rs b/crates/openhuman-core/src/memory/ops.rsindex f127ed1f08..fae3d18e72 100644--- a/crates/openhuman-core/src/memory/ops.rs+++ b/crates/openhuman-core/src/memory/ops.rs@@ -213,11 +213,10 @@ pub async fn recall_with(mode: RecallMode,exclude_thread: Option<ThreadWindow>,) -> Result<RecallView> {- let filter = confine_filter(config, params.filter.unwrap_or_default())?;let bound = bound(config)?;let request = RecallRequest {question: params.question,- filter,+ filter: confine_filter(config, params.filter.unwrap_or_default())?,limit: clamp_limit(params.limit),instructions: None,refers_to: time_hint(config, params.refers_to)?,@@ -251,7 +250,6 @@ pub async fn fetch_with(params: FetchParams,exclude_thread: Option<ThreadWindow>,) -> Result<FetchView> {- let filter = confine_filter(config, params.filter.unwrap_or_default())?;let bound = bound(config)?;let descriptor = bound.engine.descriptor();let mode = match params.mode {@@ -267,7 +265,7 @@ pub async fn fetch_with(let request = FetchRequest {query: params.query,mode,- filter,+ filter: confine_filter(config, params.filter.unwrap_or_default())?,limit: clamp_limit(params.limit),cursor: params.cursor,beliefs: 0,@@ -412,12 +410,12 @@ pub async fn forget(config: &Config, params: ForgetParams) -> Result<ForgetView>("forget needs at least one id").into(),));}+ let bound = bound(config)?;// A SaaS user forgets only what lies in their own tree.let reach = match saas_confinement(config, Policy::Clamp)? {Some(confinement) => Some(confinement.reach(params.reach)?),None => params.reach,};- let bound = bound(config)?;let report = match reach {// With a reach the engine forgets by id inside it: `forget_within`// never looks beyond the reach for an id, where `ForgetTarget::Ids`@@ -507,6 +505,7 @@ async fn within_reach(/// `memory_items_list`.pub async fn items_list(config: &Config, params: ItemsListParams) -> Result<ItemsListView> {+ let bound = bound(config)?;let request = ListRequest {filter: confine_filter(config,@@ -516,7 +515,6 @@ pub async fn items_list(config: &Config, params: ItemsListParams) -> Result<Itemcursor: params.cursor,};request.validate()?;- let bound = bound(config)?;let page = if params.preview {bound.engine.list_preview(request).await?} else {diff --git a/crates/openhuman-core/src/profiles/README.md b/crates/openhuman-core/src/profiles/README.mdindex 0f1ce659b0..6f4a1d04c0 100644--- a/crates/openhuman-core/src/profiles/README.md+++ b/crates/openhuman-core/src/profiles/README.md@@ -228,7 +228,8 @@ A profile holds one thread per conversation, whatever interface it came in on:- Memory is bound to the profile (`[memory] agent_id`, `root = user:<id>`).That binding wins over definition pins and team roots.- The memory layout is pinned to the legacy tree (confined to that root by- upstream `Confinement` with `Policy::Clamp`, selected by `memory::ops`). Layout v3 would bind the engine below+ upstream `Confinement` with `Policy::Clamp`, selected by `memory::ops`).+ Layout v3 would bind the engine below`memory::scope::user_root`, which reads `users/<id>` from the config pathand would answer `org:<id>` or a minted local root instead.- The autonomy policy is on and supervised, with no auto-approval, no tooldiff --git a/docs/specs/memory-v2.md b/docs/specs/memory-v2.mdindex 22ffe81b44..12a8890310 100644--- a/docs/specs/memory-v2.md+++ b/docs/specs/memory-v2.md@@ -39,7 +39,7 @@ is carried explicitly on every turn's run contextdispatch for top-level agents, derived with `child` by the sub-agent runnerfor children, and handed down by the team runtime for members. RPC handlersand the embed facade act as the root identity. OpenHuman adapts its config to-`IdentityPins` once in `memory::scope`; callers resolve the identity against+`IdentityPins` in `memory::scope`; callers resolve the identity againstthose pins, first match wins:| | memory agent id | layout root |diff --git a/tests/memory_v2_e2e.rs b/tests/memory_v2_e2e.rsindex 65a79f1f34..dad8c1ca90 100644--- a/tests/memory_v2_e2e.rs+++ b/tests/memory_v2_e2e.rs@@ -915,7 +915,10 @@ async fn the_agent_learn_returns_on_accept_and_recall_finds_it() {let config = openhuman_core::config::load_config_with_timeout().await.expect("the signed-in config");- let facts = openhuman_core::memory::tools::CallFacts::of(&config, &Default::default());+ let facts = openhuman_core::memory::tools::CallFacts::of(+ &config,+ &tinymemory_tools::layout::identity::Identity::agent("orchestrator"),+ );// Control: `memory_learn` over RPC returns once the write is readable, so// the hosted engine reads the store back after its write.diff --git a/tests/saas_mode/mock_memory.rs b/tests/saas_mode/mock_memory.rsindex 646f4ab157..d49e9076cc 100644--- a/tests/saas_mode/mock_memory.rs+++ b/tests/saas_mode/mock_memory.rs@@ -8,8 +8,8 @@//! backend keeps each credential's memory apart, which would hide a core//! that read or wrote outside a profile's `user:<id>` root. Here the only//! thing keeping profiles apart is the core's upstream `Policy::Clamp`, the-//! worst case `memory::ops` defends (users sharing one engine). Every request is-//! recorded with its bearer and the scopes it names, so a test can check+//! worst case `memory::ops` defends (users sharing one engine). Every request+//! is recorded with its bearer and the scopes it names, so a test can check//! both what each profile read back and what it asked the backend for.//!//! Anything outside `/memory/*` answers `500` at once, so a profile's other