Skip to content

fix: add OLLAMA_HOST fallback and graceful degradation on missing model#72

Merged
yvonnedevlinrh merged 1 commit into
unbound-force:mainfrom
yvonnedevlinrh:opsx/ollama-host-fallback
Jun 18, 2026
Merged

fix: add OLLAMA_HOST fallback and graceful degradation on missing model#72
yvonnedevlinrh merged 1 commit into
unbound-force:mainfrom
yvonnedevlinrh:opsx/ollama-host-fallback

Conversation

@yvonnedevlinrh

@yvonnedevlinrh yvonnedevlinrh commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #61 - Dewey does not read the ecosystem-standard OLLAMA_HOST environment variable and hard-exits when the embedding model is missing. Users who configure Ollama via OLLAMA_HOST (which other tools like
uf doctor respect) found that Dewey always connects to localhost:11434. Additionally, when Ollama is reachable but the embedding model hasn't been pulled, dewey serve exits with a fatal error instead of degrading gracefully to keyword-only mode.

Changes

  • OLLAMA_HOST fallback: Add ResolveOllamaEndpoint() helper to embed/config.go implementing the three-tier env var fallback chain: DEWEY_EMBEDDING_ENDPOINT > OLLAMA_HOST > default. Values without
    a URL scheme are normalized with http://.
  • Default endpoint constant: Extract DefaultOllamaEndpoint from 5 hardcoded http://localhost:11434 strings across embed/, llm/, and cli.go.
  • Graceful degradation: Convert the hard exit on missing embedding model to a warning log + keyword-only mode in both dewey serve (main.go:initObsidianBackend) and dewey index/reindex (cli.go:createIndexEmbedder). Warning includes model name, endpoint, and ollama pull instructions.
  • Doctor consistency: Replace direct os.Getenv reads in dewey doctor with embed.ReadEmbeddingConfig() so doctor reports the same endpoint that serve/index resolve.
  • Init template: Comment out endpoint in the dewey init scaffolded config.yaml so OLLAMA_HOST works out of the box for new users.

Testing

  • go build ./... - PASS
  • go vet ./... - PASS
  • go test -race -count=1 ./... - PASS (all 17 packages)
  • Gaze: CRAPload 41/48 (PASS), GazeCRAPload 45/45 (PASS)
  • 10 new tests: 8 for endpoint resolution (including config.yaml vs OLLAMA_HOST precedence), 2 for graceful degradation (serve + index paths)
  • Manual verification: OLLAMA_HOST resolves correctly, missing model degrades gracefully with warning

Change Artifacts

OpenSpec: openspec/changes/ollama-host-fallback/

##Fixes
#61

@yvonnedevlinrh yvonnedevlinrh force-pushed the opsx/ollama-host-fallback branch 2 times, most recently from 689c969 to 49f1b00 Compare June 18, 2026 13:48
@yvonnedevlinrh yvonnedevlinrh requested a review from gxmiranda June 18, 2026 13:59
@yvonnedevlinrh yvonnedevlinrh self-assigned this Jun 18, 2026

@gxmiranda gxmiranda left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Clean, well-scoped bug fix addressing both issues from #61: OLLAMA_HOST env var fallback and graceful degradation when the embedding model is missing.

Highlights:

  • DefaultOllamaEndpoint constant eliminates 5 hardcoded endpoint strings
  • Three-tier fallback chain (DEWEY_EMBEDDING_ENDPOINT > OLLAMA_HOST > default) with scheme normalization
  • Graceful degradation to keyword-only mode in both serve and index paths
  • Doctor now uses ReadEmbeddingConfig() for consistent endpoint reporting
  • 10 new tests with mock Ollama servers covering precedence, normalization, and degradation paths
  • Complete OpenSpec artifacts (proposal, design, spec, tasks)
  • AGENTS.md updated with endpoint resolution precedence documentation

[LOW] Synthesis endpoint (llm/config.go) still uses DEWEY_EMBEDDING_ENDPOINT without OLLAMA_HOST fallback — explicitly deferred as out of scope per proposal. Should be tracked as a follow-up issue.

This review was generated by /review-pr (AI-assisted).

Add ecosystem-standard OLLAMA_HOST env var as a fallback when
DEWEY_EMBEDDING_ENDPOINT is not set. When Ollama is reachable but the
embedding model has not been pulled, Dewey now logs a warning and
continues in keyword-only mode instead of hard-exiting.

Changes:
- Add DefaultOllamaEndpoint constant and ResolveOllamaEndpoint() helper
  to embed/config.go with three-tier fallback chain
- Convert hard exit to graceful degradation in both serve and index
  paths (main.go initObsidianBackend, cli.go createIndexEmbedder)
- Fix dewey doctor to use ReadEmbeddingConfig() for consistent endpoint
  reporting instead of direct os.Getenv reads
- Update llm/config.go and llm/provider.go to use the constant
- Comment out endpoint in dewey init template so OLLAMA_HOST works out
  of the box for new users
- Add 10 new tests covering resolver, degradation, and config precedence

Fixes: unbound-force#61

Assisted-by: OpenCode (claude-opus-4-6)
Signed-off-by: Yvonne Devlin <ydevlin@redhat.com>
@yvonnedevlinrh yvonnedevlinrh force-pushed the opsx/ollama-host-fallback branch from 49f1b00 to 340a944 Compare June 18, 2026 15:56
@yvonnedevlinrh yvonnedevlinrh merged commit 7401ceb into unbound-force:main Jun 18, 2026
2 checks passed
@yvonnedevlinrh yvonnedevlinrh deleted the opsx/ollama-host-fallback branch June 18, 2026 16:09
@beatrizmcouto beatrizmcouto moved this to In Review 👀 in Unbound Force Planning Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Review 👀

Development

Successfully merging this pull request may close these issues.

Bug: Dewey does not read OLLAMA_HOST and exits when embedding model is missing

3 participants