This repository has been archived on 2026-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
ollie-core/agent/compaction.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 ""
}