33 lines
932 B
Go
33 lines
932 B
Go
package agent
|
|
|
|
import "os"
|
|
|
|
// defaultCompactionModels maps backend names to cheap models suitable for compaction.
|
|
var defaultCompactionModels = map[string]string{
|
|
"anthropic": "claude-3-5-haiku-latest",
|
|
"openai": "gpt-4o-mini",
|
|
"openrouter": "deepseek-v4-flash",
|
|
"gemini": "gemini-2.0-flash",
|
|
}
|
|
|
|
// backendNamer is the subset of backend.Backend needed for compaction model resolution.
|
|
type backendNamer interface {
|
|
Name() string
|
|
}
|
|
|
|
// resolveCompactionModel returns the model to use for compaction.
|
|
// Priority: agent config > OLLIE_COMPACTION_MODEL env > per-backend default.
|
|
// Returns "" if no override is configured (use the session's current model).
|
|
func resolveCompactionModel(cfgModel string, b backendNamer) string {
|
|
if cfgModel != "" {
|
|
return cfgModel
|
|
}
|
|
if env := os.Getenv("OLLIE_COMPACTION_MODEL"); env != "" {
|
|
return env
|
|
}
|
|
if b != nil {
|
|
return defaultCompactionModels[b.Name()]
|
|
}
|
|
return ""
|
|
}
|