Skip to content

Return 503 capability_unavailable instead of falling back to the wrong backend - #236

Merged
thushan merged 11 commits into
mainfrom
fix/capability-unavailable-503
Oct 27, 2026
Merged

thushan merged 11 commits into
mainfrom
fix/capability-unavailable-503

Conversation

@thushan

@thushan thushan commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

A request that names no model is filtered by capability, for example a model-less /embed needs embeddings. When every capable host was down, Olla fell back to all endpoints unfiltered. With a TEI embedder down, a model-less /embed was then answered by a TEI reranker or classifier with 424 Model is not an embedding model.

Now, if capable hosts the request could be sent to exist but none is healthy, Olla answers 503 with X-Olla-Routing-Reason: capability_unavailable. This applies on /olla/proxy/ and on provider routes, including the getProviderEndpoints early exit. Details:

  • "Could be sent to" means the host type passes the path's profile check, and on a provider route it must also be in that provider's own scope (RequestProfile.ProviderScope). A healthy capable host the request can never reach, such as an Ollama embedder on /olla/tei/embed, no longer blocks the refusal.
  • Busy hosts count as down, which matches GetHealthyEndpoints, the source of candidates.
  • If no reachable host carries the capability at all, the old fallback stays, because tags are heuristic.
  • Named-model requests are unaffected.
  • The refusal is logged once through the final "Request rejected" line with routing_reason, and the detailed line is at Debug.

Type of change

  • Bug fix
  • Documentation

How was this tested?

TestProxyRouting_CapabilityUnavailable builds the fleet through the real unified registry and runs under strict, optimistic-compatible-only and optimistic-all. Cases:

  • every capable host offline or Busy on both routes;
  • a healthy non-candidate Ollama embedder present, on /olla/proxy/embed, /olla/tei/embed and /olla/tei/v1/embeddings;
  • no capable host at all, which keeps the fallback;
  • a named model.

Every case asserts the selected endpoints, not just the status.

TestFilterEndpointsByCapabilities_RefusalWritesNoWarn and TestProxyRouting_CapabilityRefusalWritesOnlyTheRejectionWarn cover the logging.

Live run on integration/test-october at c9d134c, against real Ollama, three TEI mocks and a vLLM mock, on the olla and sherpa engines with strict and optimistic routing. With the TEI embedder down, /olla/proxy/embed, /olla/tei/embed and /olla/tei/v1/embeddings returned 503 capability_unavailable 10/10, with zero 424s. /olla/proxy/v1/embeddings still reached Ollama. 200 refusals logged one sampled "Request rejected" and no other WARNs. Routing recovered once the embedder came back.

Checklist

  • make ready passes at 3fefff6
  • Tests added or updated for the change
  • Documentation updated: concepts/model-routing.md (Routing Reasons table), both TEI pages, and the v0.0.30 release note
  • No new dependencies added

Summary by CodeRabbit

  • Bug Fixes
    • Model-less requests requiring a capability now return 503 with a capability_unavailable routing reason when known models with that capability are hosted only on unhealthy compatible endpoints.
    • Requests still fall back to compatible endpoints if no model with the required capability has been discovered, or a healthy capable endpoint is outside the candidate set. Named-model requests are unaffected.
  • Documentation
    • Updated routing guidance to describe the capability-unavailable response and fallback behaviour.

@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Caution

Review failed

The pull request is closed.

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 68b6618 and 3fefff6.

Files selected for processing: 10
  • docs/content/about/release-notes.md
  • docs/content/api-reference/text-embeddings-inference.md
  • docs/content/concepts/model-routing.md
  • docs/content/integrations/backend/text-embeddings-inference.md
  • internal/app/handlers/handler_provider_common.go
  • internal/app/handlers/handler_proxy.go
  • internal/app/handlers/handler_proxy_capability_test.go
  • internal/app/handlers/handler_proxy_embeddings_mixed_fleet_test.go
  • internal/core/constants/routing.go
  • internal/core/domain/routing.go

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

Walkthrough

Model-less requests that require a capability now receive a 503 with a capability_unavailable routing reason when known capable models have no healthy, eligible host. Requests retain the compatible-endpoint fallback when no capable model is known or a capable host is outside the candidate set. Named-model requests are unaffected.

Changes

Capability routing

Layer / File(s) Summary
Routing contract and provider scope
internal/core/constants/routing.go, internal/core/domain/routing.go, internal/app/handlers/handler_provider_common.go
Adds routing constants and a ProviderScope field. Provider routes record their supported endpoint types.
Capability refusal decision
internal/app/handlers/handler_proxy.go, internal/app/handlers/handler_provider_common.go
Capability filtering checks whether any candidate serves a capable model and whether known, compatible capable hosts are all unhealthy. The handlers record an applicable refusal and return no endpoints.
Routing tests and documentation
internal/app/handlers/handler_proxy_capability_test.go, internal/app/handlers/handler_proxy_embeddings_mixed_fleet_test.go, docs/content/about/release-notes.md, docs/content/api-reference/text-embeddings-inference.md, docs/content/concepts/model-routing.md, docs/content/integrations/backend/text-embeddings-inference.md
Tests cover refusal and fallback cases, including offline and busy hosts, and verify warning output. Documentation describes the 503 response and fallback conditions.

Priority: Not assessed

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Possibly related PRs

  • thushan/olla#238: Extracts a model from request bodies, which can affect whether model-less capability filtering applies.
  • thushan/olla#231: Adds TEI capability tagging and model discovery used by capability routing.
  • thushan/olla#234: Changes model discovery and health-check HTTP clients used to determine capable-host availability.
Merge Risk: Low · up to dc586

The routing change is mergeable, but the release note should clarify when requests still fall back rather than return 503.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 72.73% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 6 files. (4 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed 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 describes the main routing change: return 503 with capability_unavailable instead of using an incorrect fallback backend.
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 72.73% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 6 files. (4 skipped: 4 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@thushan

thushan commented Oct 26, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review please

@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

@thushan I’ll review the changes in this PR.


🧠 Learnings used
Learnt from: CR
Repo: thushan/olla PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-06-11T11:33:04.495Z
Learning: Delegate code review and code changes to language subagents or reviewers, research to explore subagents, and testing to test subagents
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@thushan
thushan merged commit 546461c into main Oct 27, 2026
7 of 8 checks passed
@thushan
thushan deleted the fix/capability-unavailable-503 branch October 27, 2026 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant