fix(failover): send remote targets their own upstream model

A chain request reached a cloud-proxy target with the client's model,
the chain name, whenever the target set no upstream_model: passthrough
forwards the body's model and translate falls back to it. The upstream
answered 404, which neither retries nor trips, while the liveness
probe, which checks the target's own name, kept passing.

PrepareTarget now sets the upstream model of a remote target to
proxy.upstream_model or the target name, the same name the probe uses.
The request pipeline and realtime chain stages both call it.

Assisted-by: Claude:claude-opus-5-5
This commit is contained in:
Ettore Di Giacinto committed 2026-09-26 19:26:13 +00:00
1 parent d1a59aae41
commit e183ea11d1
8 files changed
+98 -7

No files matched your search

+11
View File
@@ -85,6 +85,17 @@ func UpstreamModel(cfg config.ModelConfig) string {
return cfg.Name
}
// PrepareTarget readies a copy of a target's config to serve a chain request.
// A remote target gets its upstream model set explicitly: left empty,
// passthrough forwards the client's "model" (the chain name) and translate
// falls back to it, so the upstream would answer 404 for a model the liveness
// probe (which checks UpstreamModel) just found.
func PrepareTarget(cfg *config.ModelConfig) {
if KindOf(*cfg) == KindRemote {
cfg.Proxy.UpstreamModel = UpstreamModel(*cfg)
}
}
func (p *DefaultProber) authorize(req *http.Request, cfg config.ModelConfig) error {
key, err := cfg.Proxy.ResolveAPIKey()
if err != nil || key == "" {
+17
View File
@@ -179,3 +179,20 @@ var _ = Describe("DefaultProber", func() {
}
})
})
var _ = Describe("PrepareTarget", func() {
It("names the upstream model of a remote target the way the probe does", func() {
plain := config.ModelConfig{Name: "argus-llm", Backend: "cloud-proxy"}
PrepareTarget(&plain)
Expect(plain.Proxy.UpstreamModel).To(Equal("argus-llm"))
mapped := config.ModelConfig{Name: "argus-llm", Backend: "cloud-proxy"}
mapped.Proxy.UpstreamModel = "big-llm"
PrepareTarget(&mapped)
Expect(mapped.Proxy.UpstreamModel).To(Equal("big-llm"))
local := config.ModelConfig{Name: "gemma", Backend: "llama-cpp"}
PrepareTarget(&local)
Expect(local.Proxy.UpstreamModel).To(BeEmpty())
})
})