Skip to content

Intrinsic generation path drops a caller's explicit adapter_types #1750

Open

Description

@ajbozarth

On the LocalHF Intrinsic generation path, an explicit Intrinsic.adapter_types is silently ignored — a caller who asks for (ALORA,) is served whatever the resolution walk registered, with no error and no warning. Before #1654 that path filtered by the caller's types and raised when unsatisfiable. Should the Intrinsic path honor a caller's explicit adapter_types again, and if so how?

Today (on the #1654 branch)

  • _generate_from_intrinsic looks the adapter up by name only: _find_adapter(action.intrinsic_name, None) (huggingface.py), with a comment that None is deliberate so a weightless prompt winner (type "prompt", never in a caller's tuple) isn't filtered out.
  • Registration is name-only too: resolve_adapter(name) runs the walk and registers one winner, never seeing the caller's types.
  • So the caller's adapter_types reaches neither resolution nor generation on this path. On main the same path filtered by action.adapter_types and raised backend has no adapter for processing intrinsic when unsatisfiable (OpenAI/Ollama still do this).

Why this happens (and why it's not a localized bug)

The path drops the type filter on purpose to keep the prompt winner reachable; losing the caller's restriction is the side effect. It is not merge drift and was not an articulated decision — #1654's PR body documents only the aLoRA-auto-select behavior change, not this one.

How reachable is it today

Narrow, which bears on urgency:

  • call_intrinsic (the core.* / rag.* helpers) does not expose adapter_types at all — it hardcodes (ALORA, LORA), which is itself vestigial on HF.
  • A direct Intrinsic(name, adapter_types=...) via act() does not auto-resolve; it requires prior registration via a separate name-only resolve_adapter/add_adapter, which already ignores the types.
  • The reroute path (ALoraRequirement) does honor explicit types (_find_adapter(name, search_types)), so the real "I want a specific type" use case has a working channel there.

So the regression is a silent drop on a path where the capability is barely expressible, not a loudly-broken common path.

The decision

  1. Should an explicit caller adapter_types be honored on the Intrinsic path? If yes, it means teaching resolution (not just the generation lookup) about the caller's types — threading allowed_types through resolve_adapter and the walk (so the winner is chosen within the allowed set), and exposing adapter_types on call_intrinsic and the public helpers. Filtering only at the generation lookup does not work: the walk has already committed to a winner by its own order, so a conflicting restriction would raise a false "no adapter" even when a satisfying adapter exists on the Hub.
  2. If not honored, at minimum make it non-silent — warn when a direct Intrinsic carries an explicit adapter_types the resolved winner doesn't satisfy.
  3. How does the prompt realization fit a caller restriction — append-prompt as a universal fallback, or strict "these types or fail"?

Relationship to the sibling issue

This is one of two places where the pre-prompt, adapter_type-keyed selection model struggles with the typeless prompt realization. This issue is the generation-path side: it doesn't filter (passes None) so the prompt stays reachable, at the cost of the caller's restriction. The sibling (#1749) is the gate side: it filters (("alora",)), so it loses the prompt. Same root incompatibility, opposite symptom. They are independent fixes but share the underlying design question (how a typeless realization participates in type-keyed selection), so they may be worth resolving together in one PR.

Scope

LocalHF. OpenAI/Ollama currently honor caller types (pre-#1654 model) and are a separate follow-up (#1748); the model chosen here is what they'd be aligned to.

Related

Code

_generate_from_intrinsic (huggingface.py); resolve_adapter + the walk (adapter.py); call_intrinsic (mellea/stdlib/components/intrinsic/_util.py); _find_adapter (adapter.py, type-filtered lookup).

Activity

  1. added
    area/backends
    area/adapter-functions
    on Oct 19, 2026
  2. self-assigned this
    on Oct 19, 2026
  3. ajbozarth commented on Nov 13, 2026

    @ajbozarth
    MemberAuthor

    cc @planetf1 @jakelorocco (hopefully this isnt too verbose to follow)

    Proposal: move the caller's adapter-type choice from Intrinsic to registration

    While working through the design for #1748 alongside this issue, I've landed on a proposed fix here that changes the API slightly, so I'd like feedback before implementing it. #1748 has to answer the same question on OpenAI and Ollama: both still filter generation by adapter_types, so a prompt winner registered by resolve_adapter would be filtered out. Rather than patch the lookup, this removes the root cause. Since it removes a public parameter, I'd appreciate any thoughts heading into next week; I plan to start on the implementation plan Monday.

    Root cause

    Selection happens before the request that carries the caller's preference.

    • resolve_adapter(name) runs the walk (aLoRA → LoRA → prompt) and registers one winner, or the user picks one with add_adapter(...). This happens first: in call_intrinsic, or in user code before act().
    • Intrinsic(name, adapter_types=...) arrives later and can only filter what is already registered. It can never influence what gets chosen.

    Before #1654 this was hidden: HF's resolve_adapter only ever registered the LoRA, so the generation-time filter only chose between what a user had registered by hand. #1654 exposed it. That is why the None lookup in #1654 drops the caller's types, and why restoring the old filter makes the prompt unreachable (see the three-arm table in the #1654 review thread).

    Proposal

    1. Select at registration. resolve_adapter(name, adapter_types=None) runs the walk restricted to the given set. None means everything available, including the prompt. An explicit tuple is a filter, not a priority list: the walk always keeps its own order (aLoRA → LoRA → prompt), so (LORA, ALORA) and (ALORA, LORA) behave the same. The tuple only says which realizations are allowed, so (ALORA, LORA) opts out of the prompt and (PROMPT,) means prompt only. add_adapter keeps working as the "I chose this one" path.
    2. Run by name. _generate_from_intrinsic looks the adapter up by name only, on all three backends. This is feat(adapters)!: prompt fallback for adapter functions without a trained adapter #1654's model applied everywhere.
    3. Remove adapter_types from Intrinsic and ALoraRequirement. Intrinsic constructs for a non-catalog name without it, since nothing reads the synthetic entry's types once lookups are name-only.
    4. One registered realization per capability per backend. add_adapter refuses a second realization of a capability that is already registered, so name-only lookup is never ambiguous.

    The catalog's IntrinsicsCatalogEntry.adapter_types is unchanged and keeps meaning "what is published".

    How each path works afterwards

    • Helpers (rag.*, core.*): call_intrinsic resolves with None and gets the walk's winner, or a warm hit on whatever the user already registered. A user who wants the LoRA everywhere calls backend.resolve_adapter("answerability", adapter_types=(AdapterType.LORA,)) once, and every helper call uses it. No helper signature changes.
    • Direct Intrinsic via act(): register what you want (add_adapter or a filtered resolve_adapter), then run it by name. This is the documented contract today (docs/examples/intrinsics/intrinsics.py, intrinsics.md), minus the call-time tuple.
    • Requirement reroute: an explicit ALoraRequirement runs whatever is registered under its name, which covers the custom LoRA-only adapter and the prompt without an override. The automatic route keeps its ("alora",) policy; whether that should broaden stays with Auto-reroute to requirement-check only matches aLoRA, not LoRA or prompt #1749. Gate and generation can no longer disagree, which fixes the gate/generation mismatch from the feat(adapters)!: prompt fallback for adapter functions without a trained adapter #1654 review.

    What changes for users

    Unchanged: the helpers (rag.*, core.*), Requirement.validate() and its automatic reroute, and registering an adapter with add_adapter then running it with Intrinsic(name).

    Custom adapters drop a boilerplate argument

    # Before: adapter_types only lets Intrinsic construct without a catalog entry
    backend.add_adapter(custom_adapter)
    Intrinsic("custom-failure-check", adapter_types=(AdapterType.ALORA,))
    
    # After
    backend.add_adapter(custom_adapter)
    Intrinsic("custom-failure-check")

    Choosing a realization of a catalog capability

    # Before: hand-build the LoRA (still works afterwards)
    backend.add_adapter(Adapter(...))  # ~15 lines: Identity, IOContract, LocalFileBinding
    rag.check_answerability(question, docs, ctx, backend)
    
    # After
    backend.resolve_adapter("answerability", adapter_types=(AdapterType.LORA,))
    rag.check_answerability(question, docs, ctx, backend)

    Routing requirement checks through the prompt

    # Before: only works if the walk already registered the prompt,
    # i.e. no trained requirement-check adapter exists for the model
    ALoraRequirement("...", adapter_types=(AdapterType.PROMPT,))
    
    # After: works whether or not a trained adapter exists
    backend.resolve_adapter("requirement-check", adapter_types=(AdapterType.PROMPT,))
    ALoraRequirement("...")

    Adapters are still early and I don't know of any users selecting realizations through Intrinsic's tuple. Every in-repo use is either the non-catalog construction requirement (tutorial 07, the stembolts example, the m alora README template) or the (PROMPT,) workaround documented for the #1749 gap.

    Fit with earlier design discussion

    I went back through the adapters work to check this doesn't undo a deliberate decision:

    Open questions

    1. Switching realizations. With one realization per capability, how does a user switch from the aLoRA to the LoRA? My lean: resolve_adapter with a conflicting filter replaces an adapter that an earlier resolve registered, but raises if the conflicting adapter came from add_adapter ("registered explicitly; remove_adapter it first"), so an explicit choice is never silently undone. remove_adapter stays for lifecycle (freeing weights) either way.
    2. Ollama has no remove_adapter. It has no weights to unload, so adding one is small, but it's needed for the above.
    3. Sequencing with feat(adapters): extend prompt fallback to the OpenAI and Ollama backends #1748. This can land as its own PR before feat(adapters): extend prompt fallback to the OpenAI and Ollama backends #1748, or with it. I lean toward on its own: it's an interface change, and feat(adapters): extend prompt fallback to the OpenAI and Ollama backends #1748 can then build the OpenAI/Ollama resolve paths on the new signature.

    Rough scope

    About 12 library sites (the resolve_adapter signature and walk, the lookups and reroute gates on three backends, Intrinsic, ALoraRequirement, call_intrinsic, the add_adapter guard), 6 doc, example, and CLI-template files, and about 10 test files. Mostly mechanical, with three behavior changes: removing a public parameter, the one-realization guard, and name-only lookup on OpenAI/Ollama.

  4. planetf1 commented on Nov 16, 2026

    @planetf1
    Contributor

    Looks right to me, and it supersedes my selection_types idea on #1654. Fine to drop the parameter.

    The filter only really chooses on LocalHF. On a switch model (OpenAI, or llama-server via #1735) it can only accept or refuse, so a clear "not available on this backend" error is enough. I'd skip Ollama, remove_adapter included, given #1633.

    On switching, I'd raise on any conflict, whoever registered first, and say how to free it (release() for a local adapter, remove_adapter otherwise). Replacing means tracking who registered what, lets one caller's resolve swap the adapter under everyone else, and needs new locking if a request has it active. Strict is also reversible: replace=True can come later.

    One small thing: the guard should match name or capability, like _find_adapter, since six catalogue names differ from their capability (requirement-check / requirement_check).

    Own PR before #1748 sounds good.

  5. jakelorocco commented on Nov 17, 2026

    @jakelorocco
    Contributor

    I agree. I think technically a model could have the lora and alora versions of the same adapter but that seems quite unlikely. It makes sense to me that you would configure these things at registration and then use the registered version of the adapter.

  6. planetf1 commented on Nov 19, 2026

    @planetf1
    Contributor

    Approving this as proposed. The direction is right and the history checks
    out where I could verify it (#881 added the parameter so lookup would accept
    either realization, not to select one).

    Some areas to pin down in the implementation, none of which changes the API:

    • Filter misses. Worth deciding up front what a filtered resolve raises
      when nothing satisfies the tuple. The case to watch is the warm path:
      today resolve returns the first registered match regardless of type, so a
      filtered resolve needs to check a warm hit against the filter or it
      silently returns the wrong realization. That's this issue's bug again,
      just in the new signature.
    • Guard matching. It should match the way _find_adapter does, on name
      or capability (six of twelve catalogue entries differ between the two),
      and look in the same stores that lookup does. Reusing the lookup the guard
      enforces against is the simplest way to keep them consistent.
    • Same-key re-adds should stay quiet. All three backends currently warn
      and refuse a duplicate registration, and both embedded-registration loops
      depend on that refusal looking like success (they call add_adapter then
      check identity to see what won). Raise on a same-capability conflict under
      a different key; keep re-registering the same adapter a no-op.
    • Embedded discovery can return more than one entry per name. An index
      listing two entries for one capability would hit the new guard from
      inside resolve. Decide the policy (pick by walk order at discovery, or
      reject the index) rather than letting it fall out of the implementation.
    • Removal details. Take the public Intrinsic.adapter_types property
      with the parameter, and add a release-notes line for the docs m alora add-readme generates: they embed adapter_types= in snippets uploaded to
      users' Hub repos, and we can't fix those after the fact.
    • call_intrinsic's hardcoded (ALORA, LORA) should go in the same PR;
      it's unread once all three backends are name-only.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/adapter-functionsarea/backends

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions