Repository navigation
Description
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_intrinsiclooks the adapter up by name only:_find_adapter(action.intrinsic_name, None)(huggingface.py), with a comment thatNoneis 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_typesreaches neither resolution nor generation on this path. Onmainthe same path filtered byaction.adapter_typesand raisedbackend has no adapter for processing intrinsicwhen 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(thecore.*/rag.*helpers) does not exposeadapter_typesat all — it hardcodes(ALORA, LORA), which is itself vestigial on HF.- A direct
Intrinsic(name, adapter_types=...)viaact()does not auto-resolve; it requires prior registration via a separate name-onlyresolve_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
- Should an explicit caller
adapter_typesbe honored on the Intrinsic path? If yes, it means teaching resolution (not just the generation lookup) about the caller's types — threadingallowed_typesthroughresolve_adapterand the walk (so the winner is chosen within the allowed set), and exposingadapter_typesoncall_intrinsicand 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. - If not honored, at minimum make it non-silent — warn when a direct
Intrinsiccarries an explicitadapter_typesthe resolved winner doesn't satisfy. - 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
- feat(adapters)!: prompt fallback for adapter functions without a trained adapter #1654 — introduces the behavior.
- Prompting Fallbacks for Granite Library Intrinsics #993 — the prompt-fallback feature (closed by feat(adapters)!: prompt fallback for adapter functions without a trained adapter #1654).
- Sibling: reroute-gap (Auto-reroute to requirement-check only matches aLoRA, not LoRA or prompt #1749).
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
ajbozarth commentedon Nov 13, 2026
cc @planetf1 @jakelorocco (hopefully this isnt too verbose to follow)
Proposal: move the caller's adapter-type choice from
Intrinsicto registrationWhile 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 byresolve_adapterwould 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 withadd_adapter(...). This happens first: incall_intrinsic, or in user code beforeact().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_adapteronly 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 theNonelookup 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
resolve_adapter(name, adapter_types=None)runs the walk restricted to the given set.Nonemeans 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_adapterkeeps working as the "I chose this one" path._generate_from_intrinsiclooks 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.adapter_typesfromIntrinsicandALoraRequirement.Intrinsicconstructs for a non-catalog name without it, since nothing reads the synthetic entry's types once lookups are name-only.add_adapterrefuses a second realization of a capability that is already registered, so name-only lookup is never ambiguous.The catalog's
IntrinsicsCatalogEntry.adapter_typesis unchanged and keeps meaning "what is published".How each path works afterwards
rag.*,core.*):call_intrinsicresolves withNoneand gets the walk's winner, or a warm hit on whatever the user already registered. A user who wants the LoRA everywhere callsbackend.resolve_adapter("answerability", adapter_types=(AdapterType.LORA,))once, and every helper call uses it. No helper signature changes.Intrinsicviaact(): register what you want (add_adapteror a filteredresolve_adapter), then run it by name. This is the documented contract today (docs/examples/intrinsics/intrinsics.py,intrinsics.md), minus the call-time tuple.ALoraRequirementruns 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 withadd_adapterthen running it withIntrinsic(name).Custom adapters drop a boilerplate argument
Choosing a realization of a catalog capability
Routing requirement checks through the prompt
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, them aloraREADME 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:
resolve_adaptertaking only a name was noted as a limitation, not chosen: it "has no way to request a specific type, so resolving there could register the wrong one" (feat(backends): support Ollama adapter functions #1634 review).Adapterthrough to generation would be the natural next step.Intrinsic'sadapter_typesparameter came from feat(backends): accept composed Adapter directly (Epic #929, issue #1144, PR1) #1619 as the way to build a synthetic catalog entry for custom adapters (replacing a catalog monkey-patch), not as a selection API._find_adapterwas a tie-breaker for that case.ALoraRequirementoverride from feat(backends): accept composed Adapter directly (Epic #929, issue #1144, PR1) #1619, which exists so a custom LoRA-only adapter gets past the aLoRA-only gate. Under this proposal that case is handled by registering the adapter; the gate's explicit route runs it by name.Open questions
resolve_adapterwith a conflicting filter replaces an adapter that an earlier resolve registered, but raises if the conflicting adapter came fromadd_adapter("registered explicitly;remove_adapterit first"), so an explicit choice is never silently undone.remove_adapterstays for lifecycle (freeing weights) either way.remove_adapter. It has no weights to unload, so adding one is small, but it's needed for the above.Rough scope
About 12 library sites (the
resolve_adaptersignature and walk, the lookups and reroute gates on three backends,Intrinsic,ALoraRequirement,call_intrinsic, theadd_adapterguard), 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.planetf1 commentedon Nov 16, 2026
Looks right to me, and it supersedes my
selection_typesidea 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_adapterincluded, 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_adapterotherwise). 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=Truecan 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.
jakelorocco commentedon Nov 17, 2026
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.
planetf1 commentedon Nov 19, 2026
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:
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.
_find_adapterdoes, on nameor 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.
and refuse a duplicate registration, and both embedded-registration loops
depend on that refusal looking like success (they call
add_adapterthencheck identity to see what won). Raise on a same-capability conflict under
a different key; keep re-registering the same adapter a no-op.
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.
Intrinsic.adapter_typespropertywith the parameter, and add a release-notes line for the docs
m alora add-readmegenerates: they embedadapter_types=in snippets uploaded tousers' 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.