Drop sampling params unsupported by the model
The common-pattern enrichment and tracker-mapping agents run on
reasoning models such as gpt-5-nano, which reject an explicit
temperature and fail the whole request with a 400 ("Unsupported
value: 'temperature' does not support 0.1 with this model"). The
model registry already records this capability, but nothing
consulted it before dispatch, and dated provider snapshots like
gpt-5-nano-2025-08-07 did not resolve in the registry.
Resolve dated snapshots to their undated base model in registry
Lookup, and sanitize each chat completion request in the LLM
client by omitting the sampling knobs the target model does not
accept (temperature, top_p, frequency/presence penalties, stop).
Unknown models are left untouched, so models absent from the
registry keep their current behavior.
Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
@@ -17,6 +17,7 @@ package llm
|
||||
//go:generate go run go.probo.inc/probo/internal/cmd/genmodels
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
@@ -81,7 +82,9 @@ func DefaultRegistry() *Registry {
|
||||
|
||||
// Lookup finds a model by ID. It accepts both provider-prefixed IDs
|
||||
// ("anthropic/claude-opus-4.6") and bare provider IDs ("claude-opus-4-6",
|
||||
// "gpt-5.4"). Returns false if the model is not in the registry.
|
||||
// "gpt-5.4"). Dated provider snapshots ("gpt-5-nano-2025-08-07") fall
|
||||
// back to their undated base model ("gpt-5-nano"). Returns false if the
|
||||
// model is not in the registry.
|
||||
func (r *Registry) Lookup(modelID string) (ModelDefinition, bool) {
|
||||
if m, ok := r.byID[modelID]; ok {
|
||||
return *m, true
|
||||
@@ -91,6 +94,16 @@ func (r *Registry) Lookup(modelID string) (ModelDefinition, bool) {
|
||||
return *m, true
|
||||
}
|
||||
|
||||
if base := stripModelDateSuffix(modelID); base != modelID {
|
||||
if m, ok := r.byID[base]; ok {
|
||||
return *m, true
|
||||
}
|
||||
|
||||
if m, ok := r.byID[normalizeModelID(base)]; ok {
|
||||
return *m, true
|
||||
}
|
||||
}
|
||||
|
||||
return ModelDefinition{}, false
|
||||
}
|
||||
|
||||
@@ -121,3 +134,13 @@ func normalizeModelID(id string) string {
|
||||
|
||||
return strings.ReplaceAll(id, ".", "-")
|
||||
}
|
||||
|
||||
// modelDateSuffix matches a trailing provider snapshot date such as the
|
||||
// "-2025-08-07" in "gpt-5-nano-2025-08-07".
|
||||
var modelDateSuffix = regexp.MustCompile(`-\d{4}-\d{2}-\d{2}$`)
|
||||
|
||||
// stripModelDateSuffix removes a trailing dated-snapshot suffix from a
|
||||
// model ID, leaving the base model ID unchanged when none is present.
|
||||
func stripModelDateSuffix(id string) string {
|
||||
return modelDateSuffix.ReplaceAllString(id, "")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user