Skip to content

fix(memory): clarify missing ollama embedding model#2533

Merged
senamakel merged 5 commits into
tinyhumansai:mainfrom
YOMXXX:fix/2474-ollama-embedding-guidance
May 25, 2026
Merged

fix(memory): clarify missing ollama embedding model#2533
senamakel merged 5 commits into
tinyhumansai:mainfrom
YOMXXX:fix/2474-ollama-embedding-guidance

Conversation

@YOMXXX
Copy link
Copy Markdown
Contributor

@YOMXXX YOMXXX commented May 23, 2026

Summary

  • Clarifies the Ollama embedding error when the configured model is missing.
  • Includes the exact ollama pull <model> recovery command in the returned error.
  • Keeps non-model HTTP failures on the existing generic status/body path.
  • Removes a flaky test assumption that 127.0.0.1:1 always refuses connections.

Problem

Solution

  • Detect Ollama 404 responses whose body indicates a missing model.
  • Format the error with the active embedding model, endpoint, and ollama pull command.
  • Add a focused regression test for the missing-model path and keep the existing server-error behavior intact.

Submission Checklist

  • Tests added or updated (happy path + at least one failure / edge case) per Testing Strategy
  • Diff coverage ≥ 80% - CI coverage gate will verify changed-line coverage; local diff-cover was not run for this narrow Rust-only change.
  • Coverage matrix updated - N/A: behavior-only error-message change, no matrix feature row added/removed/renamed.
  • All affected feature IDs from the matrix are listed in the PR description under ## Related - N/A: no matrix feature ID.
  • No new external network dependencies introduced (mock backend used per Testing Strategy)
  • Manual smoke checklist updated if this touches release-cut surfaces (docs/RELEASE-MANUAL-SMOKE.md) - N/A: no release-cut surface.
  • Linked issue closed via Closes #NNN in the ## Related section - N/A: partial diagnostic fix; issue remains broader.

Impact

  • Runtime impact is limited to clearer Rust core error text for Ollama-backed memory embeddings.
  • No storage, migration, or security policy changes.
  • Test stability improves by avoiding a real refused-port assumption.

Related


AI Authored PR Metadata (required for Codex/Linear PRs)

Linear Issue

  • Key: N/A
  • URL: N/A

Commit & Branch

  • Branch: fix/2474-ollama-embedding-guidance
  • Commit SHA: d6f7d64d

Validation Run

  • pnpm --filter openhuman-app format:check - N/A: no frontend changes.
  • pnpm typecheck - N/A: no TypeScript changes.
  • Focused tests: GGML_NATIVE=OFF cargo test --manifest-path Cargo.toml missing_model_404_mentions_pull_command --lib; GGML_NATIVE=OFF cargo test --manifest-path Cargo.toml memory::tree::score::embed::ollama --lib
  • Rust fmt/check (if changed): cargo fmt --manifest-path Cargo.toml --all --check; GGML_NATIVE=OFF cargo check --manifest-path Cargo.toml; git diff --check
  • Tauri fmt/check (if changed): N/A: no Tauri changes.

Validation Blocked

  • command: N/A
  • error: N/A
  • impact: N/A

Behavior Changes

  • Intended behavior change: Missing Ollama embedding model errors now include the active model and recovery command.
  • User-visible effect: Users can fix memory embedding stalls by pulling the missing model or choosing an installed embedding model.

Parity Contract

  • Legacy behavior preserved: Non-missing-model HTTP errors keep the generic status/body format.
  • Guard/fallback/dispatch parity checks: Existing Ollama embedder tests plus new missing-model test.

Duplicate / Superseded PR Handling

  • Duplicate PR(s): N/A
  • Canonical PR: N/A
  • Resolution (closed/superseded/updated): N/A

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Improved error messaging for missing Ollama embedding models—when a model isn't found, users now receive a descriptive error with clear instructions on how to install it.
  • Tests

    • Expanded unit test coverage to validate the improved error messaging for missing models, including verification of the installation guidance.

Review Change Stack

@YOMXXX YOMXXX requested a review from a team May 23, 2026 12:25
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 23, 2026

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: ec5ffea6-a325-4a8c-b046-c44e362fa494

📥 Commits

Reviewing files that changed from the base of the PR and between 93701b5 and 430d663.

📒 Files selected for processing (1)
  • src/openhuman/memory_tree/score/embed/ollama.rs
💤 Files with no reviewable changes (1)
  • src/openhuman/memory_tree/score/embed/ollama.rs

📝 Walkthrough

Walkthrough

Ollama embedder now detects "model not found" 404 responses by inspecting response body text and emits a detailed error message with an ollama pull {model} suggestion. The embed method integrates this centralized error formatter, and test coverage includes both the new missing-model scenario and an updated connection-failure test.

Changes

Ollama Embedder Error Handling

Layer / File(s) Summary
Error detection and formatting helpers
src/openhuman/memory_tree/score/embed/ollama.rs
New private helper functions detect when a 404 response indicates a missing Ollama model by inspecting response body text, and format a detailed error message that includes endpoint, model, and recommended ollama pull command.
Embed method integration and test coverage
src/openhuman/memory_tree/score/embed/ollama.rs
The embed method's non-success HTTP response path is updated to use the new error formatter instead of generic status/body errors. New test case verifies 404 missing model detection and pull command suggestion; existing descriptive failure test is updated to use malformed URL scenario.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • graycyrus
  • M3gA-Mind

Poem

🐰 A model not found? No worry, dear friend,
We'll guide you to fetch it, from start to the end.
The error now whispers: ollama pull with care,
Embedding flows smooth when the model is there! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 55.56% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change: improving error messaging for missing Ollama embedding models.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/openhuman/memory/tree/score/embed/ollama.rs (1)

108-115: ⚡ Quick win

Consider using the actual Ollama error JSON structure in tests.

The detection logic checks for "model" and "not found" as substrings, which is simple but effective. However, the test at line 323 uses a minimal JSON body {"error":"model not found"}, while the actual Ollama response format (shown in context snippet from src/openhuman/embeddings/ollama_tests.rs:330-357) is:

{"error":"model \"bge-m3\" not found, try pulling it first"}

Using the actual format in the test would better validate that the detection works with real-world responses.

🧪 Suggested test improvement

At line 323, use the actual Ollama response format:

-            post(|| async { (StatusCode::NOT_FOUND, "{\"error\":\"model not found\"}") }),
+            post(|| async { (StatusCode::NOT_FOUND, r#"{"error":"model \"custom-embed\" not found, try pulling it first"}"#) }),
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/openhuman/memory/tree/score/embed/ollama.rs` around lines 108 - 115, The
detection function is_missing_model_response currently checks lowercase body
substrings "model" and "not found"; update the corresponding test to use a
realistic Ollama error JSON (e.g. {"error":"model \"bge-m3\" not found, try
pulling it first"}) so the test exercises the real-world message format and
verifies is_missing_model_response correctly detects missing-model responses
from Ollama.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/openhuman/memory/tree/score/embed/ollama.rs`:
- Around line 108-115: The detection function is_missing_model_response
currently checks lowercase body substrings "model" and "not found"; update the
corresponding test to use a realistic Ollama error JSON (e.g. {"error":"model
\"bge-m3\" not found, try pulling it first"}) so the test exercises the
real-world message format and verifies is_missing_model_response correctly
detects missing-model responses from Ollama.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1ae5228d-b10b-42bd-84b7-d8fefe10fd08

📥 Commits

Reviewing files that changed from the base of the PR and between 7745d58 and 93701b5.

📒 Files selected for processing (1)
  • src/openhuman/memory/tree/score/embed/ollama.rs

coderabbitai[bot]
coderabbitai Bot previously approved these changes May 23, 2026
@YOMXXX
Copy link
Copy Markdown
Contributor Author

YOMXXX commented May 23, 2026

Current red check is CI infrastructure, not this Rust change.

Build Tauri App failed during checkout/submodule fetch before build code ran. The shared workflow fix is #2535, which is green on 88ae50ff across Build/Test/E2E/Coverage. After #2535 lands, this PR should be retriggered or synced to pick up the workflow fix.

@YOMXXX
Copy link
Copy Markdown
Contributor Author

YOMXXX commented May 24, 2026

@graycyrus @senamakel Required checks are green, the full check set is clean after the retry, and there are no unresolved review threads. Ready for review.

@senamakel senamakel merged commit b969c3e into tinyhumansai:main May 25, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants