fix(llm): send the provider model id on the wire, not the alias
Nightly Build / build (push) Successful in 7m49s

LlmManager keys its model registry by llm_models.name (the user-facing
alias), and the kernel sent ModelHandle.id as the request's model field —
so the alias, not llm_models.model_id, went on the wire. A model worked
only while the alias was left equal to the model id; renaming it made
every provider reject the call (DeepInfra 404 model_not_found, DeepSeek
400 invalid_request_error).

ModelHandle gains an optional wire_id: the model identifier to put on the
wire when the selector's id is a bookkeeping key. The kernel and the
compaction summary call both send handle.wire_model(); SkaldSelector sets
wire_id from LlmEntry.model (llm_models.model_id). Everything else keeps
keying on the alias: the chat's model pin, health reporting, fallback
exclusion and request logging are untouched.
This commit is contained in:
2026-08-07 14:55:58 +01:00
parent 07d96a4881
commit ea31fad188
5 changed files with 31 additions and 9 deletions
@@ -91,7 +91,12 @@ impl ModelSelector for SkaldSelector {
};
let model = self.instrument(&name, &entry);
Ok(ModelHandle {
id: name,
// `id` is the registry alias: health, fallback exclusion and the
// chat's model pin all key on it. `wire_id` is what the provider
// API must see (`llm_models.model_id`) — an alias renamed in the
// UI must never change the request's model field.
id: name,
wire_id: Some(entry.model.clone()),
model,
info: model_info_of(&entry),
})
@@ -157,7 +162,10 @@ mod tests {
let sel = SkaldSelector::new(manager, None);
let h = sel.select(&ModelHint::name("weak-model"), &[]).await.unwrap();
// The handle keys on the alias; the wire carries the provider model id.
assert_eq!(h.id, "weak-model");
assert_eq!(h.wire_id.as_deref(), Some("weak-id"));
assert_eq!(h.wire_model(), "weak-id");
assert!(sel.select(&ModelHint::name("nope"), &[]).await.is_err());