Skip to content

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

chore(scope): remove unused agent registry files and clean up web chat modules

Steven Enamakel7048d4dbfae9
diff --git a/crates/openhuman-core/src/agent/registry/agents/morning_briefing/agent.toml b/crates/openhuman-core/src/agent/registry/agents/morning_briefing/agent.toml
index 4f8f92b596..3d47d3387f 100644
--- a/crates/openhuman-core/src/agent/registry/agents/morning_briefing/agent.toml
+++ b/crates/openhuman-core/src/agent/registry/agents/morning_briefing/agent.toml
@@ -5,14 +5,13 @@ temperature = 0.5
max_iterations = 8
sandbox_mode = "read_only"
-# The brief pulls its recent memory itself via `memory_tree_cover_window`
-# (last 24h, source-grouped) — see prompt.md. We therefore suppress the
-# injected all-time memory blob (`## User Memory`, the namespace root
-# summaries): it is stale relative to "today" and would compete with the
-# fresh windowed tool result. Identity/safety boilerplate stays off too —
-# the prompt carries its own voice.
+# The brief grounds itself in the compiled memory context injected at
+# session start (`omit_memory_context = false`) plus live integration
+# reads. It has no `memory` tool: the tool reports `Write` permission
+# without arguments, which the read-only sandbox cannot admit.
+# Identity/safety boilerplate stays off — the prompt carries its own voice.
omit_identity = true
-omit_memory_context = true
+omit_memory_context = false
omit_safety_preamble = true
[model]
@@ -20,14 +19,12 @@ hint = "agentic"
[tools]
# Named, not wildcard: a wildcard belt here handed a cron-driven read-only
-# job every registered tool. The brief needs its memory window, the user's
+# job every registered tool. The brief needs the user's
# connected integrations (calendar, email, tasks — the composio meta-tools,
# plus each connected action as a `Deferred` tool through `tool_search`), and
# the clock. `sandbox_mode = "read_only"` keeps `composio_execute` to
# Read-scoped actions.
named = [
- "memory_tree",
- "memory_recall",
"composio_list_connections",
"composio_list_tools",
"composio_execute",
diff --git a/crates/openhuman-core/src/agent/registry/agents/planner/agent.toml b/crates/openhuman-core/src/agent/registry/agents/planner/agent.toml
index 7de37cff97..73f92fc516 100644
--- a/crates/openhuman-core/src/agent/registry/agents/planner/agent.toml
+++ b/crates/openhuman-core/src/agent/registry/agents/planner/agent.toml
@@ -10,11 +10,11 @@ sandbox_mode = "read_only"
omit_identity = true
omit_memory_context = false
omit_safety_preamble = true
-# Memory is no longer pre-fetched eagerly before every turn. The planner
-# keeps `omit_memory_context = false`, so it still receives the cheap
-# per-turn memory recall; deep memory-tree walks are the orchestrator's
-# on-demand concern (`delegate_retrieve_memory`), and the orchestrator
-# hands the planner grounded context in the delegation prompt.
+# The planner keeps `omit_memory_context = false`, so it receives the
+# compiled memory context at session start. It has no `memory` tool: the
+# tool reports `Write` permission without arguments, which a read-only
+# sandbox cannot admit, so deeper memory lookups are the caller's concern
+# and arrive in the delegation prompt.
# Spawn hierarchy: this is the deep-thinking tier (reasoning model hint).
# The planner produces a DAG of leaf tasks for downstream workers; it
@@ -38,7 +38,6 @@ hint = "reasoning"
# even though `composio_execute` is on this list. Only `Read`-scoped
# actions slip past the gate.
named = [
- "memory_recall",
"file_read",
# Read-only nav primitives from #1208. `edit`, `apply_patch`, `lsp`
# are intentionally NOT included — sandbox_mode = "read_only" above
diff --git a/crates/openhuman-core/src/agent/registry/agents/trigger_reactor/agent.toml b/crates/openhuman-core/src/agent/registry/agents/trigger_reactor/agent.toml
index df37ba9170..f925d1cf70 100644
--- a/crates/openhuman-core/src/agent/registry/agents/trigger_reactor/agent.toml
+++ b/crates/openhuman-core/src/agent/registry/agents/trigger_reactor/agent.toml
@@ -12,15 +12,6 @@ sandbox_mode = "none"
omit_identity = true
omit_memory_context = false
omit_safety_preamble = false
-# The reactor personalises small reactive messages (e.g. a follow-up
-# DM on behalf of the user) — PROFILE.md gives it the user's name,
-# role, and voice so replies don't land generic.
-omit_profile = false
-# MEMORY.md carries curated context about the user's ongoing work so
-# reactive follow-ups stay coherent with what came before. Frozen per
-# session (KV-cache contract on `omit_memory_md`).
-omit_memory_md = false
-trigger_memory_agent = "always"
[model]
# Always remote. Reactive work hits write-path tools and needs
@@ -31,13 +22,12 @@ hint = "agentic"
[tools]
# Small, deliberately narrow tool surface:
-# - trigger_memory_agent / memory_store: look up and persist context
+# - memory: recall prior context and learn a durable note
# - read_workspace_state: understand what the user is working on
# No `spawn_subagent`: as a worker-tier agent with no `[subagents]`
# allowlist it could never dispatch one. A reaction bigger than one or two
# calls is the triage agent's escalation to decide, not the reactor's.
named = [
- "memory_recall",
- "memory_store",
+ "memory",
"read_workspace_state",
]
diff --git a/crates/openhuman-core/src/agent/registry/agents/trigger_triage/agent.toml b/crates/openhuman-core/src/agent/registry/agents/trigger_triage/agent.toml
index 4434e17583..85e9760bf8 100644
--- a/crates/openhuman-core/src/agent/registry/agents/trigger_triage/agent.toml
+++ b/crates/openhuman-core/src/agent/registry/agents/trigger_triage/agent.toml
@@ -5,19 +5,13 @@ temperature = 0.2
max_iterations = 2
sandbox_mode = "read_only"
-# Strip everything except the global memory/context sections — the
-# classifier needs app state to make good decisions but does not
+# Strip everything except the memory context — the classifier needs to
+# know who the user is and what they decided before (the same inbound
+# trigger can be urgent for one user and noise for another) but does not
# need the identity preamble, safety scaffolding, or skills catalog.
omit_identity = true
omit_memory_context = false
omit_safety_preamble = true
-# Classification quality depends on who the user is — same inbound
-# trigger can be urgent for one user profile and noise for another.
-omit_profile = false
-# Same reasoning: MEMORY.md surfaces past user decisions ("this sender
-# was marked spam last time") so the classifier can replicate them.
-# Frozen per session — see KV-cache contract on `omit_memory_md`.
-omit_memory_md = false
[model]
# This hint is consumed by `agent::triage::routing::resolve_provider`,
diff --git a/crates/openhuman-core/src/flows/mod.rs b/crates/openhuman-core/src/flows/mod.rs
index ee230dac22..a30d58be8f 100644
--- a/crates/openhuman-core/src/flows/mod.rs
+++ b/crates/openhuman-core/src/flows/mod.rs
@@ -20,9 +20,8 @@
//! method that fails at runtime.
//!
//! The leaf gate holds only because no always-compiled domain has a real code
-//! edge into this tree. `memory/tools.rs` and `memory/tools/flavour.rs` name
-//! `flows::tinyflows` in **comments only**. If either ever becomes a real
-//! `use`, this family must convert to the facade+stub shape (see `voice/`).
+//! edge into this tree. If one ever gains a real `use` of `flows::`, this
+//! family must convert to the facade+stub shape (see `voice/`).
pub mod agents;
pub mod builder_tools;
@@ -74,15 +73,11 @@ pub use tinyflows_catalog::{
DraftOrigin, Flow, FlowConnection, FlowDraft, FlowImport, FlowRevision, FlowRun, FlowRunStep,
FlowRunTrigger, FlowSuggestion, FlowValidation, FlowValidationError, SuggestionStatus,
};
-// `FLOW_MEMORY_NAMESPACE_PREFIX` / `flow_namespace` live in `memory_tools`
-// (the domain logic sibling that owns the agent tools consuming them) and are
-// re-exported here so every existing `flows::flow_namespace` /
-// `flows::FLOW_MEMORY_NAMESPACE_PREFIX` call site (`bus.rs`, `ops.rs`, this
-// module's own doc comments) keeps resolving unchanged — `mod.rs` stays
-// export-focused only, per this repo's canonical module shape.
-// `cross_flow_recall` is re-exported for the same reason: the tinyflows
-// `memory` node's `OpenHumanMemory` adapter (`scope: "flows"` recall) must
-// see byte-identical cross-flow results to `flow_memory_recall`'s own
-// `scope: "flows"` arm, so both call the one implementation here rather than
-// each walking `namespace_summaries` independently.
-pub use memory_tools::{cross_flow_recall, flow_namespace, FLOW_MEMORY_NAMESPACE_PREFIX};
+// Flow memory scoping (`flow:<id>` tags over memory v2) lives in
+// `memory_tools`, the sibling that owns the agent tools; the digest
+// subscriber, `flows_delete` and the tinyflows `memory` node adapter reach the
+// same helpers through these re-exports so every caller tags identically.
+pub use memory_tools::{
+ cross_flow_filter, flow_filter, flow_key_of, flow_meta, flow_tag, forget_matching,
+ remember_keyed, FLOWS_TAG,
+};
diff --git a/crates/openhuman-core/src/memory/tools.rs b/crates/openhuman-core/src/memory/tools.rs
index 337b387742..da24e3b689 100644
--- a/crates/openhuman-core/src/memory/tools.rs
+++ b/crates/openhuman-core/src/memory/tools.rs
@@ -10,7 +10,8 @@
//! - `tool_call` — this call's name and provider-assigned id;
//! - `source.kind = agent`.
-use std::sync::Arc;
+use std::collections::HashMap;
+use std::sync::{Arc, LazyLock, Mutex};
use async_trait::async_trait;
use serde_json::{json, Value};
@@ -23,7 +24,44 @@ use crate::core::events::DomainEvent;
use super::error::MemoryError;
use super::ops;
-use super::types::{FetchParams, ForgetParams, LearnParams, RecallParams};
+use super::types::{FetchParams, ForgetParams, LearnParams, RecallParams, TurnCitation};
+
+/// Most citations kept per thread between two drains.
+const MAX_TURN_CITATIONS: usize = 20;
+
+/// Citations `recall` produced during a thread's in-flight turn, drained by
+/// the chat surface once the turn returns ([`take_turn_citations`]).
+static TURN_CITATIONS: LazyLock<Mutex<HashMap<String, Vec<TurnCitation>>>> =
+ LazyLock::new(|| Mutex::new(HashMap::new()));
+
+fn record_turn_citations(thread_id: &str, citations: &[tinymemory::Citation]) {
+ if citations.is_empty() {
+ return;
+ }
+ let mut all = TURN_CITATIONS
+ .lock()
+ .unwrap_or_else(std::sync::PoisonError::into_inner);
+ let entry = all.entry(thread_id.to_string()).or_default();
+ for citation in citations {
+ if entry.len() >= MAX_TURN_CITATIONS {
+ break;
+ }
+ if !entry.iter().any(|existing| existing.id == citation.id.0) {
+ entry.push(TurnCitation::from(citation));
+ }
+ }
+}
+
+/// Drains the citations `recall` produced for `thread_id` since the last
+/// drain.
+#[must_use]
+pub fn take_turn_citations(thread_id: &str) -> Vec<TurnCitation> {
+ TURN_CITATIONS
+ .lock()
+ .unwrap_or_else(std::sync::PoisonError::into_inner)
+ .remove(thread_id)
+ .unwrap_or_default()
+}
/// The tool's name.
pub const MEMORY_TOOL_NAME: &str = "memory";
@@ -116,13 +154,19 @@ pub async fn run_action(config: &Config, args: &Value, facts: &CallFacts) -> Too
"recall" => match parse::<RecallParams>(args) {
Ok(params) => {
let question = params.question.clone();
- ops::recall(config, params).await.map(|view| {
- BUS.publish(DomainEvent::MemoryRecalled {
- query: question,
- hit_count: view.citations.len(),
- });
- json!(view)
- }).map_err(render_error)
+ ops::recall(config, params)
+ .await
+ .map(|view| {
+ if let Some(thread_id) = facts.thread_id.as_deref() {
+ record_turn_citations(thread_id, &view.citations);
+ }
+ BUS.publish(DomainEvent::MemoryRecalled {
+ query: question,
+ hit_count: view.citations.len(),
+ });
+ json!(view)
+ })
+ .map_err(render_error)
}
Err(error) => Err(error),
},
diff --git a/crates/openhuman-core/src/memory/types.rs b/crates/openhuman-core/src/memory/types.rs
index 9d8569babe..d9822d1718 100644
--- a/crates/openhuman-core/src/memory/types.rs
+++ b/crates/openhuman-core/src/memory/types.rs
@@ -431,3 +431,45 @@ pub struct ImportStateView {
/// The state.
pub state: ImportState,
}
+
+/// A recall citation attached to a chat reply so the UI can show where a
+/// memory-informed answer came from. Same JSON shape the chat surface has
+/// always rendered: `key` is the item kind, `namespace` its source kind,
+/// `timestamp` when it was observed, `snippet` a short excerpt.
+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+pub struct TurnCitation {
+ /// Item id.
+ pub id: String,
+ /// Item kind (`document`, `conversation`, `learning`).
+ pub key: String,
+ /// Source kind (`folder`, `agent`, …).
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub namespace: Option<String>,
+ /// Relevance, when the engine reports one.
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub score: Option<f64>,
+ /// When the item was observed (RFC 3339), or empty.
+ pub timestamp: String,
+ /// Short excerpt.
+ pub snippet: String,
+}
+
+impl From<&Citation> for TurnCitation {
+ fn from(citation: &Citation) -> Self {
+ Self {
+ id: citation.id.0.clone(),
+ key: citation.kind.as_str().to_string(),
+ namespace: Some(citation.meta.source.kind.as_str().to_string()),
+ score: citation.score.map(f64::from),
+ timestamp: citation
+ .meta
+ .observed_at
+ .map(|at| at.to_rfc3339())
+ .unwrap_or_default(),
+ snippet: citation.snippet.chars().take(TURN_CITATION_SNIPPET_CHARS).collect(),
+ }
+ }
+}
+
+/// Longest snippet a [`TurnCitation`] carries.
+pub const TURN_CITATION_SNIPPET_CHARS: usize = 280;
diff --git a/crates/openhuman-core/src/web_chat/presentation.rs b/crates/openhuman-core/src/web_chat/presentation.rs
index de3c59d272..b3423f3d28 100644
--- a/crates/openhuman-core/src/web_chat/presentation.rs
+++ b/crates/openhuman-core/src/web_chat/presentation.rs
@@ -54,7 +54,7 @@ pub(crate) async fn deliver_response(
request_id: &str,
full_response: &str,
user_message: &str,
- citations: &[crate::memory::agent::memory_loader::MemoryCitation],
+ citations: &[crate::memory::types::TurnCitation],
usage: Option<&LastTurnUsage>,
workspace_dir: Option<&std::path::Path>,
timing: Option<super::turn_timing::TurnTimingSnapshot>,
@@ -284,7 +284,7 @@ fn publish_chat_done(
thread_id: &str,
request_id: &str,
full_response: &str,
- citations: &[crate::memory::agent::memory_loader::MemoryCitation],
+ citations: &[crate::memory::types::TurnCitation],
usage_payload: Option<TurnUsagePayload>,
timing_payload: Option<crate::web_chat::TurnTimingPayload>,
) {
diff --git a/crates/openhuman-core/src/web_chat/presentation_test_support_tests.rs b/crates/openhuman-core/src/web_chat/presentation_test_support_tests.rs
index 771f90c8a0..1240f38bc7 100644
--- a/crates/openhuman-core/src/web_chat/presentation_test_support_tests.rs
+++ b/crates/openhuman-core/src/web_chat/presentation_test_support_tests.rs
@@ -1,4 +1,4 @@
-use crate::memory::agent::memory_loader::MemoryCitation;
+use crate::memory::types::TurnCitation;
pub async fn deliver_response_for_test(
client_id: &str,
@@ -6,7 +6,7 @@ pub async fn deliver_response_for_test(
request_id: &str,
full_response: &str,
user_message: &str,
- citations: &[MemoryCitation],
+ citations: &[TurnCitation],
) {
deliver_response_in_workspace_for_test(
client_id,
@@ -55,7 +55,7 @@ pub async fn deliver_response_in_workspace_for_test(
request_id: &str,
full_response: &str,
user_message: &str,
- citations: &[MemoryCitation],
+ citations: &[TurnCitation],
workspace_dir: Option<&std::path::Path>,
) {
super::deliver_response(
diff --git a/crates/openhuman-core/src/web_chat/presentation_tests.rs b/crates/openhuman-core/src/web_chat/presentation_tests.rs
index 765c0608cd..ce6bb344ca 100644
--- a/crates/openhuman-core/src/web_chat/presentation_tests.rs
+++ b/crates/openhuman-core/src/web_chat/presentation_tests.rs
@@ -146,7 +146,7 @@ async fn delivery_stores_the_reply_before_announcing_it() {
)
.expect("thread created");
- let citation = crate::memory::agent::memory_loader::MemoryCitation {
+ let citation = crate::memory::types::TurnCitation {
id: "mem-deliver".to_string(),
key: "summary-source".to_string(),
namespace: None,
diff --git a/crates/openhuman-core/src/web_chat/reply_persistence.rs b/crates/openhuman-core/src/web_chat/reply_persistence.rs
index 5676b2f261..00cd763264 100644
--- a/crates/openhuman-core/src/web_chat/reply_persistence.rs
+++ b/crates/openhuman-core/src/web_chat/reply_persistence.rs
@@ -22,7 +22,7 @@ use std::path::Path;
use serde_json::json;
-use crate::memory::agent::memory_loader::MemoryCitation;
+use crate::memory::types::TurnCitation;
use crate::threads::store::{self as conversations, run_reply_message_id, ConversationMessage};
/// Metadata scope stamped on a reply persisted by the web-channel delivery path.
@@ -54,7 +54,7 @@ pub(crate) fn persist_delivered_reply(
thread_id: &str,
request_id: &str,
full_response: &str,
- citations: &[MemoryCitation],
+ citations: &[TurnCitation],
) -> Result<bool, String> {
let content = full_response.trim();
if content.is_empty() {
diff --git a/crates/openhuman-core/src/web_chat/reply_persistence_tests.rs b/crates/openhuman-core/src/web_chat/reply_persistence_tests.rs
index 500baff2b5..37292a048d 100644
--- a/crates/openhuman-core/src/web_chat/reply_persistence_tests.rs
+++ b/crates/openhuman-core/src/web_chat/reply_persistence_tests.rs
@@ -1,7 +1,7 @@
use std::path::PathBuf;
use super::persist_delivered_reply;
-use crate::memory::agent::memory_loader::MemoryCitation;
+use crate::memory::types::TurnCitation;
use crate::threads::store::{self as conversations, CreateConversationThread};
fn temp_ws() -> PathBuf {
@@ -98,7 +98,7 @@ fn citations_ride_on_the_authoritative_row() {
let ws = temp_ws();
seed_thread(&ws, "t-6");
- let citation = MemoryCitation {
+ let citation = TurnCitation {
id: "mem-1".to_string(),
key: "draft-location".to_string(),
namespace: Some("notes".to_string()),
diff --git a/crates/openhuman-core/src/web_chat/run_task.rs b/crates/openhuman-core/src/web_chat/run_task.rs
index 1cf713a9f1..8969827ed1 100644
--- a/crates/openhuman-core/src/web_chat/run_task.rs
+++ b/crates/openhuman-core/src/web_chat/run_task.rs
@@ -161,7 +161,7 @@ pub(crate) async fn run_chat_task(
// any stale budget-exhausted signal before it could mislabel a
// later genuine empty response. See #3386.
super::ops::clear_budget_signal(thread_id).await;
- let citations = agent.take_last_turn_citations().await;
+ let citations = crate::memory::tools::take_turn_citations(thread_id);
let usage = agent.take_last_turn_usage_totals();
Ok(WebChatTaskResult {
full_response: response,
diff --git a/crates/openhuman-core/src/web_chat/types.rs b/crates/openhuman-core/src/web_chat/types.rs
index 529a5b8d82..14d5fe0515 100644
--- a/crates/openhuman-core/src/web_chat/types.rs
+++ b/crates/openhuman-core/src/web_chat/types.rs
@@ -106,7 +106,7 @@ pub(super) struct ParallelEntry {
#[derive(Debug, Clone)]
pub(super) struct WebChatTaskResult {
pub(super) full_response: String,
- pub(super) citations: Vec<crate::memory::agent::memory_loader::MemoryCitation>,
+ pub(super) citations: Vec<crate::memory::types::TurnCitation>,
/// Holistic token/cost/context totals for the turn (parent + sub-agents),
/// forwarded to the frontend on `chat_done`. `None` for synthetic results
/// (e.g. budget-exhausted placeholders) that never ran a real turn.