fix(modelloop): feed the cached model catalog to the runtime so reasoning models get the right token parameter

This commit is contained in:
sam committed 2026-10-06 00:45:09 +11:00
1 parent 78c2f33928
commit d427671fc5
5 files changed
+20 -7

No files matched your search

+13 -3
View File
@@ -1,14 +1,19 @@
package modelloop
import (
"os"
"github.com/samcharles93/ai-sdk/runtime"
"github.com/samcharles93/archie-core/internal/domain/agentrun"
)
// NewRuntime builds a provider runtime for interactive chat or a worker-local
// workflow stage. Nil means no providers were configured.
func NewRuntime(providers map[string]agentrun.Provider) *runtime.Runtime {
// workflow stage. Nil means no providers were configured. catalogPath is the
// models.dev snapshot the service already cached; it supplies each model's
// reasoning flag so requests use the parameters the model accepts. Empty or
// unreadable leaves the runtime without model metadata.
func NewRuntime(providers map[string]agentrun.Provider, catalogPath string) *runtime.Runtime {
if len(providers) == 0 {
return nil
}
@@ -23,5 +28,10 @@ func NewRuntime(providers map[string]agentrun.Provider) *runtime.Runtime {
}
catalog[name] = cfg
}
return runtime.NewRuntime(runtime.Config{Providers: catalog})
cfg := runtime.Config{Providers: catalog}
models := runtime.NewCatalog(runtime.CatalogOptions{})
if raw, err := os.ReadFile(catalogPath); err == nil && models.LoadFromJSON(raw) == nil {
return runtime.NewRuntimeWithCatalog(cfg, models)
}
return runtime.NewRuntime(cfg)
}