Skip to content

fix: route Lemonade models by mapping downloaded to available state - #161

Merged
thushan merged 1 commit into
thushan:mainfrom
matthewjhunter:fix/lemonade-model-state
Jun 7, 2026
Merged

thushan merged 1 commit into
thushan:mainfrom
matthewjhunter:fix/lemonade-model-state

Conversation

@matthewjhunter

@matthewjhunter matthewjhunter commented Jun 7, 2026 •

Copy link
Copy Markdown
Contributor

Resolves #160

Problem

Endpoints configured with type: "lemonade" are health-checked fine, but no model on them is ever routable: the discovery parser drops the per-model downloaded flag that Lemonade returns in /api/v1/models, so every Lemonade model resolves to state=unknown. The router treats unknown-state models as being on unhealthy endpoints and excludes them, so a Lemonade endpoint is unreachable for chat even when it is up and the model is downloaded.

MapModelState (internal/adapter/unifier/model_builder.go) marks a model available when it has a state/loaded indicator or a non-zero size. LemonadeModel declared neither downloaded nor size, so both were dropped at unmarshal and the model stayed unknown.

Change

Capture Lemonade's downloaded flag and map it to ModelStateAvailable. This mirrors how a pulled, load-on-demand Ollama model is already treated: present on disk and serveable, so available for routing. Lemonade also loads on demand, and downloaded: true is the equivalent readiness signal.

  • lemonade.go: add Downloaded bool to LemonadeModel (ordered to satisfy fieldalignment).
  • lemonade_parser.go: set Details.State = "available" when downloaded is true.
  • lemonade_parser_test.go: table-driven test covering downloaded true / false / omitted.

I deliberately did not also capture size: Lemonade reports it as a GiB float while Olla's internal size is bytes, so it would need a unit conversion. The routing fix stands on downloaded alone; capturing size for catalog/concurrency parity can be a separate change if wanted.

Verification

  • make ready passes (test-short, test-race, fmt, vet, golangci-lint 0 issues, betteralign clean).
  • Validated end-to-end against a live Lemonade SDK backend: before the change a chat request for a downloaded Lemonade-hosted model returns 404 "No openai endpoints available"; after, the model reports state: available and the request routes to the Lemonade endpoint and returns a completion (X-Olla-Routing-Decision: routed, X-Olla-Routing-Reason: model_found).

Note

This makes Lemonade models routable via the native /olla/lemonade/... path. Reaching the same endpoints through the generic /olla/openai/... path needs additional work that is out of scope here (the openai-compatible compatibility check and per-backend path translation); I'll open a separate issue describing that gap.

Summary by CodeRabbit

Release Notes

  • New Features

    • Implemented model download status tracking. Models now indicate their availability state based on download completion.
  • Tests

    • Added test coverage validating model state transitions when download status is received.

Lemonade reports a per-model `downloaded` flag in /api/v1/models, but the
discovery parser dropped it, so every Lemonade model resolved to
state=unknown. The router treats unknown-state models as being on
unhealthy endpoints and excludes them, leaving Lemonade endpoints
unroutable for chat completions (404 "No <provider> endpoints available")
even when the endpoint is healthy and the model is downloaded.

Capture `downloaded` and map it to ModelStateAvailable - the same
treatment a pulled, load-on-demand Ollama model already receives.

Refs thushan#160
@matthewjhunter
matthewjhunter requested a review from thushan as a code owner June 7, 2026 06:33
@coderabbitai

coderabbitai Bot commented Jun 7, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 575bcec5-8220-4266-9c2c-70ca2b2bd9d9

📥 Commits

Reviewing files that changed from the base of the PR and between b19ba57 and 6a37101.

📒 Files selected for processing (3)
  • internal/adapter/registry/profile/lemonade.go
  • internal/adapter/registry/profile/lemonade_parser.go
  • internal/adapter/registry/profile/lemonade_parser_test.go

Walkthrough

The PR adds support for Lemonade model routing by capturing the downloaded readiness flag from Lemonade API responses and mapping it to an internal model state. LemonadeModel gains a Downloaded field, the parser translates it to domain.ModelStateAvailable, and tests validate this mapping across three field-presence scenarios.

Changes

Lemonade model routing state

Layer / File(s) Summary
Downloaded field and state mapping
internal/adapter/registry/profile/lemonade.go, internal/adapter/registry/profile/lemonade_parser.go, internal/adapter/registry/profile/lemonade_parser_test.go
LemonadeModel adds a Downloaded boolean field (JSON downloaded). The parser maps model.Downloaded == true to details.State = "available", marking the model as serveable. Three test cases verify state assignment when the field is true, false, or omitted.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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 accurately describes the main change: adding the Downloaded field to LemonadeModel and mapping it to available state for routing.
Linked Issues check ✅ Passed The PR fully addresses issue #160's primary objective: capturing the downloaded field and mapping it to available state so Lemonade models become routable.
Out of Scope Changes check ✅ Passed All changes directly support the routing fix objective; no unrelated modifications are present outside the scope of issue #160.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@thushan

thushan commented Jun 7, 2026

Copy link
Copy Markdown
Owner

Looks good to me, easy merge, thanks for the contrib.

@thushan
thushan merged commit c336dc7 into thushan:main Jun 7, 2026
5 checks passed
@thushan thushan added the resolved Issue is resolved and merged. label Jun 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working llm-backend Issue is about an LLM Backend, provider or type. (Eg. Ollama, vllm) resolved Issue is resolved and merged. routing This issue is with routing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lemonade models are never routable for chat: discovery parser discards the downloaded/size fields, so every model resolves to state=unknown

2 participants