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/memory/tools.rs

Steven Enamakeld86dfdff2c58
diff --git a/crates/openhuman-core/src/memory/tools.rs b/crates/openhuman-core/src/memory/tools.rs
index bfc9c6d78e..ce19a90762 100644
--- a/crates/openhuman-core/src/memory/tools.rs
+++ b/crates/openhuman-core/src/memory/tools.rs
@@ -6,16 +6,16 @@
//!
//! - `workspace` — the agent's working folder (`action_dir`, or the turn's
//! isolated workspace when one is scoped);
-//! - `thread_id` and `agent_id`;
-//! - `namespace` — the acting agent's memory node ([`super::scope`]), or,
-//! for `learn` with `share: true`, the nearest shared node above it (its
-//! team's, else the root);
+//! - `thread_id` and `agent_id` (the memory agent id the turn runs as,
+//! [`super::scope`]);
+//! - `namespace` — the layout's learnings node: the root of the acting
+//! identity's layout, which every agent under that root shares;
//! - `tool_call` — this call's name and provider-assigned id;
//! - `source.kind = agent`.
//!
-//! `recall`, `fetch` and `forget` are confined to the agent's reach: its own
-//! node and the nodes it inherits, never a sibling agent's. A `reach` in the
-//! model's filter is overwritten.
+//! `recall`, `fetch` and `forget` are confined to the identity's layout:
+//! everything under its root, never another root's (another tenant's or
+//! team's). A `reach` in the model's filter is overwritten.
use std::collections::HashMap;
use std::sync::{Arc, LazyLock, Mutex};
@@ -97,11 +97,9 @@ pub struct CallFacts {
pub agent_id: Option<String>,
/// The provider-assigned tool-call id.
pub tool_call_id: Option<String>,
- /// The calling agent's memory node.
+ /// Where the agent's learnings go: its layout's learnings node.
pub namespace: Namespace,
- /// Where the agent's shared learnings go.
- pub shared_namespace: Namespace,
- /// What the agent may read.
+ /// What the agent may read and forget: its whole layout.
pub reach: Reach,
}
@@ -137,26 +135,20 @@ impl CallFacts {
/// context.
#[must_use]
pub fn of(config: &Config, identity: &super::scope::MemoryIdentity) -> Self {
- let namespace = identity.namespace(config);
+ let resolved = identity.resolve(config);
Self {
- agent_id: identity.agent_id.clone(),
- shared_namespace: namespace.shared_ancestor(),
- reach: identity.reach(config),
- namespace,
+ agent_id: Some(resolved.agent_id.clone()),
+ namespace: resolved.layout.learnings().clone(),
+ reach: Reach::subtree(resolved.root().clone()),
..Self::default()
}
}
- /// The metadata `learn` stamps on the stored item: at the agent's own
- /// node, or at its shared node when `share`.
+ /// The metadata `learn` stamps on the stored item.
#[must_use]
- pub fn learn_meta(&self, share: bool) -> MemoryMeta {
+ pub fn learn_meta(&self) -> MemoryMeta {
MemoryMeta {
- namespace: if share {
- self.shared_namespace.clone()
- } else {
- self.namespace.clone()
- },
+ namespace: self.namespace.clone(),
workspace: self.workspace.clone(),
thread_id: self.thread_id.clone(),
agent_id: self.agent_id.clone(),
@@ -225,8 +217,7 @@ pub async fn run_action(config: &Config, args: &Value, facts: &CallFacts) -> Too
Ok(mut params) => {
params.meta = None;
let kind = params.kind.unwrap_or(tinymemory_api::LearningKind::Fact);
- let share = args.get("share").and_then(Value::as_bool) == Some(true);
- ops::learn(config, params, Some(facts.learn_meta(share)))
+ ops::learn(config, params, Some(facts.learn_meta()))
.await
.map(|view| {
BUS.publish(DomainEvent::MemoryStored {
@@ -280,10 +271,11 @@ impl Tool for MemoryTool {
`recall` answers a question from memory with citations; `fetch` returns raw \
matching items (filter by metadata such as workspace, repo, file_path, kinds); \
`learn` stores a durable fact, preference, procedure or correction about the \
- user or their work — in your own memory, or with `share: true` in the memory \
- your team or every agent shares; `forget` removes items by id. You read your own \
- memory plus what is shared with you. Recall before asking the user something they \
- may already have told you; learn things worth remembering next time."
+ user or their work, shared with every agent working alongside you; `forget` \
+ removes items by id. Relevant memory is already added to each turn as \
+ <memory-context>; use `recall` or `fetch` to look further. Recall before asking \
+ the user something they may already have told you; learn things worth \
+ remembering next time."
}
fn parameters_schema(&self) -> Value {
@@ -304,7 +296,6 @@ impl Tool for MemoryTool {
"text": {"type": "string", "description": "learn: the learning, one self-contained sentence."},
"kind": {"type": "string", "enum": ["preference", "fact", "procedure", "correction", "other"], "description": "learn: what kind of learning (default fact)."},
"confidence": {"type": "number", "minimum": 0, "maximum": 1, "description": "learn: confidence (default 0.8)."},
- "share": {"type": "boolean", "description": "learn: store in shared memory every agent (or your team) reads, instead of your own (default false)."},
"ids": {"type": "array", "items": {"type": "string"}, "description": "forget: item ids to remove."}
},
"required": ["action"]