Skip to content

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

feat(learning): add MEMORY_TOOL to the memory write tools list

Steven Enamakelf190f7b44d9e
diff --git a/crates/openhuman-core/src/agent/learning/mod.rs b/crates/openhuman-core/src/agent/learning/mod.rs
index addc33eae4..7f94162621 100644
--- a/crates/openhuman-core/src/agent/learning/mod.rs
+++ b/crates/openhuman-core/src/agent/learning/mod.rs
@@ -48,8 +48,8 @@ pub use profile_md_renderer::ProfileMdRenderer;
pub use prompt_sections::{
any_tool_offered, load_learned_from_cache, memory_write_instruction, LearnedContextSection,
MemoryAccessSection, MemoryWriteSection, UserProfileSection, MEMORY_ACCESS_INSTRUCTION,
- MEMORY_READ_TOOLS, MEMORY_STORE_TOOL, MEMORY_WRITE_DELEGATE_TOOL, MEMORY_WRITE_TOOLS,
- SAVE_PREFERENCE_TOOL,
+ MEMORY_READ_TOOLS, MEMORY_STORE_TOOL, MEMORY_TOOL, MEMORY_WRITE_DELEGATE_TOOL,
+ MEMORY_WRITE_TOOLS, SAVE_PREFERENCE_TOOL,
};
pub use reflection::ReflectionHook;
pub use schemas::{
diff --git a/crates/openhuman-core/src/agent/learning/prompt_sections.rs b/crates/openhuman-core/src/agent/learning/prompt_sections.rs
index b4ffa85dbe..b5b3632042 100644
--- a/crates/openhuman-core/src/agent/learning/prompt_sections.rs
+++ b/crates/openhuman-core/src/agent/learning/prompt_sections.rs
@@ -209,7 +209,9 @@ fn memory_write_instruction_via(
fact_route: &str,
) -> String {
let route = match (preferences, facts) {
- (true, true) => format!("— `save_preference` for preferences, {fact_route} for everything else"),
+ (true, true) => {
+ format!("— `save_preference` for preferences, {fact_route} for everything else")
+ }
(true, false) => "with `save_preference`".to_string(),
(false, true) => format!("with {fact_route}"),
// Only when neither direct tool is held, so an agent that has one
@@ -224,9 +226,11 @@ fn memory_write_instruction_via(
// which is the #6048 bug arriving by a new route. The argument is
// advertised on the tool's own schema, so this is a demand the model
// can actually satisfy.
- (false, false) if delegate => "with `manage_profile_memory` (pass `blocking: true` so the write \
+ (false, false) if delegate => {
+ "with `manage_profile_memory` (pass `blocking: true` so the write \
gates your reply)"
- .to_string(),
+ .to_string()
+ }
(false, false) => return String::new(),
};
format!(
@@ -308,8 +312,9 @@ pub const MEMORY_WRITE_DELEGATE_TOOL: &str = "manage_profile_memory";
/// section names the route it found, so it cannot treat them interchangeably —
/// but a reader reaching for "what does the write section care about" should get
/// the whole answer here (#6200 review).
-pub const MEMORY_WRITE_TOOLS: [&str; 3] = [
+pub const MEMORY_WRITE_TOOLS: [&str; 4] = [
MEMORY_STORE_TOOL,
+ MEMORY_TOOL,
SAVE_PREFERENCE_TOOL,
MEMORY_WRITE_DELEGATE_TOOL,
];
diff --git a/crates/openhuman-core/src/agent/session_host/builder/helpers.rs b/crates/openhuman-core/src/agent/session_host/builder/helpers.rs
index a439f1cc36..3169212b24 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/helpers.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/helpers.rs
@@ -112,7 +112,7 @@ pub(super) fn add_memory_prompt_sections(
) -> SystemPromptBuilder {
use crate::agent::learning::{
any_tool_offered, MemoryAccessSection, MemoryWriteSection, MEMORY_READ_TOOLS,
- MEMORY_STORE_TOOL, MEMORY_WRITE_DELEGATE_TOOL, SAVE_PREFERENCE_TOOL,
+ MEMORY_STORE_TOOL, MEMORY_TOOL, MEMORY_WRITE_DELEGATE_TOOL, SAVE_PREFERENCE_TOOL,
};
let mut prompt_builder = prompt_builder;
// Gate on the set the model will actually see: packs are stripped from
diff --git a/crates/openhuman-core/src/memory/tools/collapsed_tests.rs b/crates/openhuman-core/src/memory/tools/collapsed_tests.rs
index ca94da27c1..aadfb16931 100644
--- a/crates/openhuman-core/src/memory/tools/collapsed_tests.rs
+++ b/crates/openhuman-core/src/memory/tools/collapsed_tests.rs
@@ -110,15 +110,24 @@ fn the_memory_tree_tool_is_not_a_member() {
fn each_action_maps_text_onto_its_members_arguments() {
let ask = member_args(ACTION_ASK, &serde_json::json!({"text": " who is Ana? "})).unwrap();
assert_eq!(ask["query"], "who is Ana?");
- assert!(ask["namespace"].is_string(), "hybrid search needs a namespace");
+ assert!(
+ ask["namespace"].is_string(),
+ "hybrid search needs a namespace"
+ );
- let keywords = member_args(ACTION_KEYWORD_SEARCH, &serde_json::json!({"text": "ana", "limit": 3}))
- .unwrap();
+ let keywords = member_args(
+ ACTION_KEYWORD_SEARCH,
+ &serde_json::json!({"text": "ana", "limit": 3}),
+ )
+ .unwrap();
assert_eq!(keywords["query"], "ana");
assert_eq!(keywords["limit"], 3);
- let learn = member_args(ACTION_LEARN, &serde_json::json!({"text": "Ana prefers email", "limit": 9}))
- .unwrap();
+ let learn = member_args(
+ ACTION_LEARN,
+ &serde_json::json!({"text": "Ana prefers email", "limit": 9}),
+ )
+ .unwrap();
assert_eq!(learn["content"], "Ana prefers email");
assert!(learn.get("limit").is_none(), "a write takes no limit");
}