Repository navigation
Description
Problem
OllamaModelBackend.resolve_adapter() (and the cold-resolve path inside the
Requirement-rerouting logic in _generate_from_context) only knows how to
resolve adapter functions that are in the Granite intrinsics catalog
(fetch_intrinsic_metadata() in mellea/backends/adapters/catalog.py).
adapter_models={...} gets you the same experience as OpenAIBackend and
LocalHFBackend — but only for catalog names.
add_adapter() accepts a custom (non-catalog) adapter function on each
backend, for that backend's own binding type — Ollama's ServerMediatedBinding,
OpenAI's EmbeddedBinding, HF's LocalFileBinding (or the composed
equivalents). But on Ollama specifically, registering one without a matching
entry in adapter_models is confusing: right now a caller can call
add_adapter() and only discover the missing tag at generation time — a
direct Intrinsic call raises ValueError (PR #1634's
fix for a prior silent fallback to the base model); automatic Requirement→aLoRA
rerouting instead logs a warning and falls back to regular (LLM-as-judge)
generation. Neither is a registration API — both are safety nets for a
misconfiguration that has no ergonomic way to avoid in the first place.
The config= dict add_adapter() requires for a ServerMediatedBinding also
has no documented shape of its own. get_io_contract() already has a
documented non-catalog fallback (io_contracts.py, _DictContract), and
docs/docs/tutorials/07-custom-adapter-function.md documents the general
custom/non-catalog adapter path end-to-end — but that tutorial is
LocalFileBinding/HF-specific; it doesn't cover what a ServerMediatedBinding's
raw config needs to contain.
The old CustomIntrinsicAdapter shim partially covered this pre-refactor. It's
deprecated but still present (mellea/backends/adapters/adapter.py), scheduled
for deletion in #1621 — nothing has replaced its specific convenience for a
non-catalog, server-mediated adapter.
Proposal
Design a first-class registration path for a custom (non-catalog) adapter
function on OllamaModelBackend — something that plays the same role
resolve_adapter() plays for catalog names, but takes the model tag and
config directly instead of fetching them from the Hugging Face Hub catalog.
Candidate shapes to evaluate:
- A parameter on
add_adapter()(or a sibling method) that requires the
caller to supply the serving Ollama model tag at registration time, so
adapter_modelsand the composed adapter register together in one call
instead of drifting out of sync by hand. - Document the
config=shape aServerMediatedBindingneeds, extending
docs/docs/tutorials/07-custom-adapter-function.md(or a sibling doc)
to cover the Ollama/server-mediated case alongside the existing
HF/LocalFileBindingone.
Related — narrower than #1633
#1633 ("design(adapters): complete server-mediated adapter binding
semantics") is a broader design issue for ServerMediatedBinding's whole
lifecycle — target selection, per-request activation isolation, concurrency,
telemetry. Its requirement 5 ("Explicit adapter_models migration contract")
overlaps with this issue's registration-ergonomics question, but the rest of
#1633 doesn't. This issue is deliberately scoped to just the registration
API so it stays independently trackable rather than waiting on the full
binding rework. Whoever picks up #1633 should read this issue too, in case
resolving adapter_models's fate there naturally resolves this as well.
#1621 deletes the deprecated CustomIntrinsicAdapter/IntrinsicAdapter/
EmbeddedIntrinsicAdapter shims — this issue is about a modern replacement
for one of those shims' use cases, not about un-deleting them.
Context
Raised during review of PR #1634:
Activity
planetf1 commentedon Oct 20, 2026
Folded into #1633, reframed as the Ollama freeze-or-maintain decision. The registration ergonomics from here are under "What maintaining involves" there. If the decision is freeze, this is moot; if maintain, the candidate shapes are preserved in the host body.