feat(doctor): surface embedding model health to user (#2474)
Summary
- Adds embedding model health check to the doctor diagnostics system: probes Ollama reachability and model availability, reports actionable errors ("Run
ollama pull bge-m3"). - Emits
DomainEvent::EmbeddingModelUnhealthyon the event bus when the startup health gate triggers a cloud fallback — UI layer can now surface a notification. - Upgrades missing-model 404 log from debug to WARN so it's visible without debug logging.
- Fixes a panic in
doctor_reportRPC:reqwest::blocking::Clientwas called inside the async runtime, now wrapped inspawn_blocking.
Test plan
- [x]
cargo check— clean - [x]
cargo fmt --check— clean - [x] RPC-verified:
openhuman.doctor_reportwith Ollama down →[Error] Ollama daemon unreachable... Start Ollama, then run: ollama pull bge-m3 - [x] RPC-verified:
openhuman.doctor_reportwith cloud provider →[Ok] embedding provider: cloud — no local daemon required - [x] Confirmed panic fix: doctor_report no longer crashes on async context
- [x] Direct Ollama API test:
bge-m3produces 1024-dim embeddings correctly
Closes #2474
Summary by CodeRabbit
-
New Features
- Added embedding-model health diagnostics that run during system health checks and surface model-specific status and a user-facing notification when a model is unavailable.
- Notifications include provider/model details and a suggested fallback/action.
-
Bug Fixes
- Improved warning/error messages with clear guidance to resolve embedding provider failures.
- Suppressed duplicate health alerts so users receive a single, actionable notification.
-
Tests
- Added unit tests validating model name/tag matching behavior.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 578ebaf7-4fcd-40d8-8d64-01064eb91564
📥 Commits
Reviewing files that changed from the base of the PR and between 2d2b681fe583131fb7b5de17fc573e2b88138a5e and ec16011af255f68841350ad767b1fa56dda30a16.
📒 Files selected for processing (2)
src/openhuman/doctor/core.rssrc/openhuman/doctor/core_tests.rs
🚧 Files skipped from review as they are similar to previous changes (1)
- src/openhuman/doctor/core.rs
📝 Walkthrough
Walkthrough
Adds embedding-model health diagnostics and reporting: new DomainEvent::EmbeddingModelUnhealthy, a doctor check that probes Ollama /api/tags (3s timeout) and records Ok/Warn/Error, spawn_blocking for the doctor runner, model-aware health-gate publishing on Ollama failures, and improved Ollama embedder warning logs.
Changes
Embedding Model Health Monitoring
| Layer / File(s) | Summary |
|---|---|
EmbeddingModelUnhealthy event type src/core/event_bus/events.rs |
Adds DomainEvent::EmbeddingModelUnhealthy { provider, model, fallback_provider, message } and routes it to the "memory" domain. |
Doctor embedding health check src/openhuman/doctor/core.rs, src/openhuman/doctor/ops.rs |
Adds check_embedding_model_health (probes Ollama /api/tags with 3s timeout, records Ok/Warn/Error and supports base-name model matches), integrates it into doctor::run, and runs doctor::run inside tokio::task::spawn_blocking. Includes model_matches helpers and unit tests. |
Health gate event publishing and tests src/openhuman/memory_store/factories.rs |
report_ollama_health_gate_once now accepts (base_url, model), logs host+model context, publishes DomainEvent::EmbeddingModelUnhealthy with provider/model/fallback/message, and unit test updated to verify once-per-process suppression. |
Ollama embedder warning logging src/openhuman/memory_tree/score/embed/ollama.rs |
Formats non-success HTTP responses into msg, logs WARN with that message (including ollama pull <model> hint when applicable), then bails with the formatted message. |
Sequence Diagram
sequenceDiagram
participant DoctorOps
participant SpawnBlocking
participant DoctorRun
participant EmbeddingCheck
participant OllamaAPI
DoctorOps->>SpawnBlocking: spawn_blocking(doctor::run)
SpawnBlocking->>DoctorRun: doctor::run(config)
DoctorRun->>EmbeddingCheck: check_embedding_model_health(config)
EmbeddingCheck->>OllamaAPI: GET /api/tags (3s timeout)
OllamaAPI-->>EmbeddingCheck: models list or error
EmbeddingCheck-->>DoctorRun: DoctorItem (Ok/Warn/Error)
DoctorRun-->>SpawnBlocking: DoctorReport
SpawnBlocking-->>DoctorOps: RpcOutcome
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
- tinyhumansai/openhuman#2533: Centralizes and improves Ollama error message formatting and failure guidance in the same embedder file.
Suggested reviewers
- senamakel
- M3gA-Mind
- graycyrus
Poem
🐰 I sniffed the models, checked every tag,
The daemon was silent, my ears went zag.
I sounded the gate, sent a tiny alarm,
Fell back to the cloud to keep things from harm.
Hop, patch, and log — now the system's a charm. 🥕
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title clearly summarizes the main change: adding embedding model health checking to the doctor diagnostics system to surface issues to the user. |
| Linked Issues check | ✅ Passed | The PR directly addresses the root cause identified in #2474: implementing embedding model health checks, publishing health events, and providing actionable remediation guidance. |
| Out of Scope Changes check | ✅ Passed | All changes are scoped to implementing the embedding model health diagnostics feature: event definitions, health-check probes, event publishing, and supporting logging/timeout improvements. |
| Docstring Coverage | ✅ Passed | Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
Comment @coderabbitai help to get the list of available commands and usage tips.
Clean feature addition with a well-targeted panic fix. A few things to address.
Issues
Missing tests for
check_embedding_model_healthThe function's HTTP paths are reasonably hard to unit-test (live daemon required), but the model-matching logic is pure and testable in isolation:
let model_base = model.split(':').next().unwrap_or(&model); // … serde_json parse + .any(|entry| { … tag_base == model_base … })This branch — matching
"bge-m3"against"bge-m3:latest"in the/api/tagsresponse — is the exact case most likely to cause silent failures in production (users install with a tag, doctor says "not found"). Consider extracting it into a smallfn model_matches(installed: &str, configured: &str) -> booland adding a#[cfg(test)] mod testsblock withbge-m3/bge-m3:latest/nomic-embed-text:latest/bge-m3:v1.0cases.Dead
unwrap_orbranchlet model_base = model.split(':').next().unwrap_or(&model);
split(':').next()always returnsSome— there is always at least one segment before a:. Theunwrap_orbranch is unreachable. Useunwrap_or(&model)→.unwrap()or justmodel.split(':').next().unwrap_or(model.as_str())to make the intent clear. Minor, but it's dead code in a security-adjacent path.
report_ollama_health_gate_onceevent publication not testedThe existing gate test verifies the
boolreturn value (first call fires, subsequent calls suppress). It doesn't verify that theEmbeddingModelUnhealthyevent is published. Testing event bus emission in unit tests is tricky (requiresinit_global), but theDEBUGlog line is a reasonable proxy — at minimum, a comment in the test noting "event publication is fire-and-forget; verified manually" would prevent future readers from asking why it isn't covered.
spawn_blockingmoves ALL doctor checks, not just the embedding probe
doctor::run()is a large sync function (env checks, file system probes, memory DB checks, now the Ollama probe). Wrapping the whole thing inspawn_blockingworks correctly — none of that code needs the async runtime. But it means future synchronous checks added todoctor::run()will implicitly inherit this threading model. A doc comment ondoctor::run()noting "runs in a blocking thread (viaspawn_blockinginops::doctor_report) — do not call.awaithere or add non-blocking async calls" would prevent accidental future breakage.What's correct
spawn_blockingis the right fix for the panic.Config: Clone + Send + 'static(required for the closure) — theconfig.clone()before the closure correctly satisfies the borrow. ✓EmbeddingModelUnhealthyis in the"memory"domain bucket (matches thedomain()arm added at line 605). ✓report_ollama_health_gate_oncecorrectly updated at both call sites ineffective_embedding_settings_probedandcreate_memory_full. ✓publish_globalis infallible (drops event when no receivers registered); the fire-and-forget comment is accurate. ✓- Upgrading the 404 log in
ollama.rstolog::warn!beforeanyhow::bail!is correct — the warn fires before the bail, so the remediation hint appears in logs regardless of whether the caller swallows the error. ✓- The 3-second timeout on the blocking probe is appropriate for a daemon on localhost. ✓
- The non-Ollama fast path (
if provider != "ollama" { items.push(ok(...)); return; }) correctly skips the probe for cloud/custom providers. ✓- Existing factory gate tests updated with the new
modelargument. ✓- CI green, no merge conflicts.
Add the
model_matchesunit test (or equivalent) and the doc note ondoctor::run(), then this is ready.
resolved this issue in further commits https://github.com/tinyhumansai/openhuman/pull/2674/commits/2d2b681fe583131fb7b5de17fc573e2b88138a5e