Skip to content

Design a custom (non-catalog) adapter registration path for OllamaModelBackend #1650

Closed

Description

@planetf1

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_models and the composed adapter register together in one call
    instead of drifting out of sync by hand.
  • Document the config= shape a ServerMediatedBinding needs, extending
    docs/docs/tutorials/07-custom-adapter-function.md (or a sibling doc)
    to cover the Ollama/server-mediated case alongside the existing
    HF/LocalFileBinding one.

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

  1. added
    needs-design
    area/backends
    area/adapter-functions
    on Sep 17, 2026
  2. added
    p2
    enhancement
    on Oct 5, 2026
  3. planetf1 commented on Oct 20, 2026

    @planetf1
    ContributorAuthor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/adapter-functionsarea/backendsenhancementneeds-designp2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions