Validate providers and retain complete run debugging context
This commit is contained in:
+10
-5
@@ -3,6 +3,7 @@ package stage
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -12,6 +13,13 @@ const ModelType = "model"
|
||||
|
||||
const ModelID = "deepseek-v4.1-flash"
|
||||
|
||||
var providerID = regexp.MustCompile(`^[A-Za-z0-9_.-]+$`)
|
||||
var modelID = regexp.MustCompile(`^[A-Za-z0-9_./:-]+$`)
|
||||
|
||||
func ValidModel(provider, model string) bool {
|
||||
return len(provider) <= 200 && len(model) <= 300 && providerID.MatchString(provider) && modelID.MatchString(model)
|
||||
}
|
||||
|
||||
// ModelConfig and ModelSpec group the settings/contracts that belong specifically
|
||||
// to an LLM stage. Other stage types need not have a prompt, provider, or model.
|
||||
type ModelConfig struct {
|
||||
@@ -77,11 +85,8 @@ func (ModelStage) Spec(def Definition) (ModelSpec, error) {
|
||||
return ModelSpec{}, fmt.Errorf("unknown config %q", key)
|
||||
}
|
||||
}
|
||||
if provider := def.Configs["provider"]; provider != "opencode-go" {
|
||||
return ModelSpec{}, fmt.Errorf("unsupported provider %q", provider)
|
||||
}
|
||||
if model := def.Configs["model"]; model != ModelID {
|
||||
return ModelSpec{}, fmt.Errorf("unsupported model %q", model)
|
||||
if !ValidModel(def.Configs["provider"], def.Configs["model"]) {
|
||||
return ModelSpec{}, fmt.Errorf("invalid provider/model identifier; use the exact IDs validated during setup")
|
||||
}
|
||||
retries, err := strconv.Atoi(def.Configs["retries"])
|
||||
if err != nil || retries < 0 || retries > 100 {
|
||||
|
||||
Reference in New Issue
Block a user