Skip to content

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

feat(memory): add optional per-turn recall timeout to memory binding

Steven Enamakelc66709746b34
diff --git a/crates/openhuman-core/src/agent/tinyagents/context_wiring_tests.rs b/crates/openhuman-core/src/agent/tinyagents/context_wiring_tests.rs
index eca0963169..bf529c72f2 100644
--- a/crates/openhuman-core/src/agent/tinyagents/context_wiring_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/context_wiring_tests.rs
@@ -106,7 +106,10 @@ async fn a_compaction_records_the_summarizer_model_it_called() {
let mut history = vec![Message::system("system")];
for round in 0..6 {
- history.push(Message::user(format!("ask {round}: {}", "detail ".repeat(60))));
+ history.push(Message::user(format!(
+ "ask {round}: {}",
+ "detail ".repeat(60)
+ )));
history.push(Message::assistant(format!(
"answer {round}: {}",
"result ".repeat(60)
@@ -114,7 +117,11 @@ async fn a_compaction_records_the_summarizer_model_it_called() {
}
history.push(Message::user("continue"));
harness
- .invoke_in_context(&(), RunContext::new(RunConfig::new("compaction"), ()), history)
+ .invoke_in_context(
+ &(),
+ RunContext::new(RunConfig::new("compaction"), ()),
+ history,
+ )
.await
.expect("the turn runs");
diff --git a/crates/openhuman-core/src/config/schema/memory_tests.rs b/crates/openhuman-core/src/config/schema/memory_tests.rs
index 67e5f04e70..7bbedc4476 100644
--- a/crates/openhuman-core/src/config/schema/memory_tests.rs
+++ b/crates/openhuman-core/src/config/schema/memory_tests.rs
@@ -402,3 +402,16 @@ fn observed_actor_is_off_by_default_and_unwritten_until_set() {
let on: MemoryConfig = toml::from_str("observed_actor = true").unwrap();
assert!(on.observed_actor);
}
+
+#[test]
+fn recall_each_turn_is_an_optional_host_binding_in_milliseconds() {
+ assert_eq!(MemoryConfig::default().recall_each_turn_ms, None);
+ let unset = toml::to_string(&MemoryConfig::default()).expect("serializes");
+ assert!(!unset.contains("recall_each_turn_ms"), "{unset}");
+
+ let config: MemoryConfig =
+ toml::from_str("recall_each_turn_ms = 1500").expect("the binding parses");
+ assert_eq!(config.recall_each_turn_ms, Some(1_500));
+ let written = toml::to_string(&config).expect("serializes");
+ assert!(written.contains("recall_each_turn_ms = 1500"), "{written}");
+}
diff --git a/crates/openhuman-embed/src/agent/README.md b/crates/openhuman-embed/src/agent/README.md
index 01d50142ec..659b680915 100644
--- a/crates/openhuman-embed/src/agent/README.md
+++ b/crates/openhuman-embed/src/agent/README.md
@@ -31,7 +31,7 @@ with the same id cannot both pass the duplicate check), then calls
5. provider model route stays per turn, never written to config
6. MCP servers appended to mcp_client.servers (mcp feature)
7. Composio credential pinned for this agent only
- 8. memory binding memory.agent_id and memory.root
+ 8. memory binding memory.agent_id, memory.root, memory.recall_each_turn_ms
9. config escape hatch then config_path is reset to the runtime's
10. create dirs action_dir, agents/<id>/, agents/<id>/skills/
11. copy skills (skills feature)
@@ -90,7 +90,10 @@ directories; transcripts and memory persist with the workspace.
`sandbox` (`None`, `ReadOnly`, `Sandboxed`), `max_iterations`,
`temperature`, `display_name` and `when_to_use`.
- `MemoryBinding` (`spec.rs`): the memory agent id the turns are logged
- under, and optionally a layout root such as `team:acme`.
+ under, optionally a layout root such as `team:acme`, and optionally
+ `recall_each_turn(timeout)`: recall for the current message on every turn,
+ waited on for at most `timeout` before the first model call (late recall
+ leaves the turn without a memory note).
- `AgentLayout` ([`layout.rs`](layout.rs)): `home` is `<workspace>/agents/<id>/`, `skills`
is `<workspace>/agents/<id>/skills/`, `transcripts` is
`<workspace>/session_raw/`, and `action_dir` is the resolved acting root.
diff --git a/crates/openhuman-embed/src/agent/spec_tests.rs b/crates/openhuman-embed/src/agent/spec_tests.rs
index cc5005f658..88a3493e0e 100644
--- a/crates/openhuman-embed/src/agent/spec_tests.rs
+++ b/crates/openhuman-embed/src/agent/spec_tests.rs
@@ -58,3 +58,15 @@ fn composio_credential_is_carried_to_the_build_step_and_kept_out_of_debug() {
assert_eq!(credential.api_key(), "ck_secret_alpha");
assert_eq!(credential.entity(), "tenant-a");
}
+
+#[test]
+fn a_memory_binding_recalls_each_turn_only_when_asked() {
+ let binding = MemoryBinding::new("writer").root("team:acme");
+ assert_eq!(binding.recall_each_turn_timeout(), None);
+ let binding = binding.recall_each_turn(std::time::Duration::from_millis(1_500));
+ assert_eq!(
+ binding.recall_each_turn_timeout(),
+ Some(std::time::Duration::from_millis(1_500))
+ );
+ assert_eq!(binding.root_namespace(), Some("team:acme"));
+}
diff --git a/crates/openhuman-embed/tests/README.md b/crates/openhuman-embed/tests/README.md
index ecd30f52aa..d86ffee8c5 100644
--- a/crates/openhuman-embed/tests/README.md
+++ b/crates/openhuman-embed/tests/README.md
@@ -38,6 +38,7 @@ record types preserve populated persisted JSON, including metadata and lineage.
| [`attached_tools.rs`](attached_tools.rs) | `Agent::attach_tools` sources survive clones and session resume, and name collisions are refused. |
| [`composio_agents.rs`](composio_agents.rs) | Two agents with their own `ComposioHostCredential` reach Composio with their own key only. |
| [`memory_facade.rs`](memory_facade.rs) | `Runtime::memory` over TinyMemory's in-memory reference engine keeps two tenant roots apart. |
+| [`memory_recall_each_turn.rs`](memory_recall_each_turn.rs) | `MemoryBinding::recall_each_turn`: recall in time reaches the first model request as the tail note after the user's message and never the transcript; a late recall leaves the turn without a note; without it a cold first turn is unchanged. |
| [`saas_profiles.rs`](saas_profiles.rs) | A `ProfileRuntime` (SaaS mode, in-process): two users on thread `t1` see only their own messages and ride their own credential, a held `ProfileHandle` keeps its profile from release, a relayed Telegram message lands on the user's `channel:` thread with its `channel_outbound` reply on that user's events only, and the process refuses any other core afterwards. Inference is `common::echo_inference` behind `common::PointedInference`. |
| [`host_only_tools.rs`](host_only_tools.rs) | Host tools declare read-only requirements through Embed's `ToolPolicy`; the exact host catalog is advertised and built-in shell/write calls are refused. |
| [`structured_turns.rs`](structured_turns.rs) | Host-owned document tools preserve structured response shape, usage, budgets and untrusted-input restrictions across the tool loop. |