Skip to content

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

fix(archivist): classify ingest error before emitting local-model notice

shanu9a79abb22246
diff --git a/src/openhuman/agent/harness/archivist/tree_ingest.rs b/src/openhuman/agent/harness/archivist/tree_ingest.rs
index 81b0511cbf..d16bd14a45 100644
--- a/src/openhuman/agent/harness/archivist/tree_ingest.rs
+++ b/src/openhuman/agent/harness/archivist/tree_ingest.rs
@@ -201,18 +201,27 @@ impl ArchivistHook {
crate::openhuman::memory::tree::health::user_error::notice_corrupt_store_once(
"archivist tree ingest",
);
- } else {
+ } else if crate::openhuman::memory::tree::health::user_error::is_local_embedding_error(
+ &rendered,
+ ) {
tracing::warn!(
- "[archivist] tree ingest failed (non-fatal): source_id={source_id} \
- session={session_id} segment={segment_id} error={rendered}"
+ "[archivist] tree ingest hit a local-model embedding failure \
+ (non-fatal): source_id={source_id} session={session_id} \
+ segment={segment_id} error={rendered}"
);
// Surface a once-per-process user notification so the
// frontend can prompt the user to check their local model
- // configuration (openhuman#5867). Without this the failure
- // is silent beyond the log line above.
+ // configuration (openhuman#5867). Only fires for confirmed
+ // Ollama-specific errors; storage/bus/RPC failures are
+ // logged above and left to the existing retry/backoff path.
crate::openhuman::memory::tree::health::user_error::notice_local_model_unavailable_once(
"archivist tree ingest",
);
+ } else {
+ tracing::warn!(
+ "[archivist] tree ingest failed (non-fatal): source_id={source_id} \
+ session={session_id} segment={segment_id} error={rendered}"
+ );
}
}
}
diff --git a/src/openhuman/memory/tree/health/user_error.rs b/src/openhuman/memory/tree/health/user_error.rs
index 85d1668d1a..2fc62ce840 100644
--- a/src/openhuman/memory/tree/health/user_error.rs
+++ b/src/openhuman/memory/tree/health/user_error.rs
@@ -116,17 +116,44 @@ pub(crate) fn notice_memory_module_unavailable_once(reason: &str) {
/// once-per-process matches the rationale of [`notice_corrupt_store_once`]:
/// per-segment notices would be a banner storm. `origin` names the producing
/// path — logged, never sent to the frontend.
+///
+/// Uses [`std::sync::Once`] so the latch is not set until after the publish
+/// runs: a panic inside `publish_web_channel_event` leaves the `Once`
+/// un-initialized, so the next call retries rather than silently swallowing the
+/// failure (matching the pattern of [`notice_memory_module_unavailable_once`]).
pub(crate) fn notice_local_model_unavailable_once(origin: &str) {
- use std::sync::atomic::{AtomicBool, Ordering};
- static EMBED_UNAVAILABLE_NOTICED: AtomicBool = AtomicBool::new(false);
- if EMBED_UNAVAILABLE_NOTICED.swap(true, Ordering::Relaxed) {
- return;
- }
- log::warn!(
- "[archivist] action=broadcast_user_error kind={LOCAL_MODEL_UNAVAILABLE_KIND} \
- source={MEMORY_USER_ERROR_SOURCE} origin={origin}"
- );
- crate::openhuman::web_chat::publish_web_channel_event(local_model_unavailable_user_error());
+ static EMBED_UNAVAILABLE_NOTICED: std::sync::Once = std::sync::Once::new();
+ EMBED_UNAVAILABLE_NOTICED.call_once(|| {
+ log::warn!(
+ "[archivist] action=broadcast_user_error kind={LOCAL_MODEL_UNAVAILABLE_KIND} \
+ source={MEMORY_USER_ERROR_SOURCE} origin={origin}"
+ );
+ crate::openhuman::web_chat::publish_web_channel_event(
+ local_model_unavailable_user_error(),
+ );
+ });
+}
+
+/// Text classifier for a local Ollama embedding failure, for errors that crossed
+/// the bus and only exist as strings.
+///
+/// Matches the two error shapes emitted by `tinyinference::embeddings::ollama`:
+/// - `"ollama embed request failed (is Ollama running at <base>?): …"` —
+/// the transport bail when the daemon is not listening.
+/// - `"Ollama embedding model `<id>` is not installed at <base>. …"` —
+/// the rewritten 404 when the configured model was never pulled.
+///
+/// Both strings are Ollama-specific, so a generic cloud-embedder transport
+/// failure ("error sending request for url …") does not match and keeps its
+/// own non-notification path. Mirrors `classify_embed_error_str` from
+/// `tinycortex` — the typed host-side classifier it maps to
+/// `FailureCode::LocalModelUnavailable` — but operates on the pre-stringified
+/// `MemoryError` rendering so it works across the module-bus boundary where the
+/// typed error is no longer available.
+pub(crate) fn is_local_embedding_error(message: &str) -> bool {
+ let msg = message.to_ascii_lowercase();
+ msg.contains("is ollama running at")
+ || (msg.contains("ollama embedding model") && msg.contains("is not installed at"))
}
/// host-side fallback for paths that only ever see text.
diff --git a/src/openhuman/memory/tree/health/user_error_tests.rs b/src/openhuman/memory/tree/health/user_error_tests.rs
index 2bc0f3c51f..bdcb1c1ab3 100644
--- a/src/openhuman/memory/tree/health/user_error_tests.rs
+++ b/src/openhuman/memory/tree/health/user_error_tests.rs
@@ -99,6 +99,39 @@ fn wire_notice_is_latched_once_per_process() {
notice_corrupt_store_once("test detector");
}
+/// The local-embedding classifier matches the two Ollama error shapes and
+/// nothing else. A false positive here would tell the user to start Ollama
+/// for a generic storage or bus failure that has nothing to do with the local
+/// model runtime.
+#[test]
+fn local_embedding_error_classifier_matches_ollama_patterns_only() {
+ // Transport bail: daemon is not listening.
+ assert!(is_local_embedding_error(
+ "unreachable: ollama embed request failed \
+ (is Ollama running at http://localhost:11434?): connection refused"
+ ));
+ // Plain string variant the bus may emit.
+ assert!(is_local_embedding_error(
+ "is Ollama running at http://127.0.0.1:11434"
+ ));
+ // Model-not-pulled shape.
+ assert!(is_local_embedding_error(
+ "Ollama embedding model `nomic-embed-text` is not installed at \
+ http://localhost:11434. Run `ollama pull nomic-embed-text`."
+ ));
+ // Case-insensitive match.
+ assert!(is_local_embedding_error("IS OLLAMA RUNNING AT localhost"));
+
+ // Non-Ollama failures must not match.
+ assert!(!is_local_embedding_error("database or disk is full"));
+ assert!(!is_local_embedding_error("timed out: rpc timeout exceeded"));
+ assert!(!is_local_embedding_error(
+ "unreachable: connection refused to memory bus"
+ ));
+ assert!(!is_local_embedding_error("backend failed: 500 internal"));
+ assert!(!is_local_embedding_error(""));
+}
+
/// Once-latch for the archivist embedding failure path (openhuman#5867):
/// one failed embedding per segment must not become one banner per segment.
#[test]