Skip to main content

Module profile_route

Module profile_route 

Source
Expand description

Routing of {model}:{profile} request ids.

A client selects a named sampling profile by suffixing the model it asks for — qwen3.6:coding. This module decides, for one requested id, whether that id names a model outright, a model plus a configured profile, or a profile that does not exist.

§Why the catalog decides, not a pattern

Colons are legitimate inside model names: Ollama-style name:tag ids are everywhere, so qwen3.6:27b may well be a model. A purely lexical rule cannot tell that apart from qwen3.6:coding naming a profile, so this module asks the catalog instead. A full-string catalog hit always wins, which means adding profiles can never shadow a model that already exists.

§Why an unmatched suffix is an error

When the suffix matches no profile and the base is a real model, the request is not forwarded — it fails with 404. Silently falling back to the bare model is the dangerous option: a coding agent whose profile was renamed or deleted would keep working while quietly sampling at the wrong temperature, which is exactly the failure this feature exists to prevent. A loud 404 at the moment of the rename is far cheaper to diagnose.

That branch cannot distinguish a deleted profile from a model tag that was never in the catalog (qwen3.6:27b with no such model and no 27b profile), so the error names both readings rather than guessing.

§Cost

An id with no : returns immediately with no catalog access at all, which is every request from a client that does not use profiles. Only colon-bearing ids reach the catalog.

§Why this runs before the pipeline, not inside it

apply is the request pipeline, and its stages all shape a request that is already known to belong to some model. This does not: it decides which model the request names, which is the question resolve needs answered before it can build a ModelContext at all. So it sits ahead of the pipeline rather than in it — a caller routes first, then resolves the base name it gets back, then applies.

It lives in gglib-core rather than beside the proxy that first needed it because the CLI selects profiles too, and gglib-core is the only crate both can reach.

Enums§

ModelRoute
What a requested model id turned out to mean.

Functions§

model_exists 🔒
Whether name resolves in the catalog, treating a query failure as absent.
resolve_route
Resolve a requested model id into a ModelRoute.