From 567e8a7263bce07f31555c22eaccdaac849f080f Mon Sep 17 00:00:00 2001 From: Djordje Lukic Date: Thu, 5 Feb 2026 14:59:08 +0100 Subject: [PATCH] Only create a new modelstore if none is given Signed-off-by: Djordje Lukic --- pkg/runtime/runtime.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pkg/runtime/runtime.go b/pkg/runtime/runtime.go index fbd1e52a6..b8ee64d57 100644 --- a/pkg/runtime/runtime.go +++ b/pkg/runtime/runtime.go @@ -249,11 +249,6 @@ func WithEnv(env []string) Opt { // NewLocalRuntime creates a new LocalRuntime without the persistence wrapper. // This is useful for testing or when persistence is handled externally. func NewLocalRuntime(agents *team.Team, opts ...Opt) (*LocalRuntime, error) { - modelsStore, err := modelsdev.NewStore() - if err != nil { - return nil, err - } - defaultAgent, err := agents.DefaultAgent() if err != nil { return nil, err @@ -265,7 +260,6 @@ func NewLocalRuntime(agents *team.Team, opts ...Opt) (*LocalRuntime, error) { currentAgent: defaultAgent.Name(), resumeChan: make(chan ResumeRequest), elicitationRequestCh: make(chan ElicitationResult), - modelsStore: modelsStore, sessionCompaction: true, managedOAuth: true, sessionStore: session.NewInMemorySessionStore(), @@ -275,6 +269,14 @@ func NewLocalRuntime(agents *team.Team, opts ...Opt) (*LocalRuntime, error) { opt(r) } + if r.modelsStore == nil { + modelsStore, err := modelsdev.NewStore() + if err != nil { + return nil, err + } + r.modelsStore = modelsStore + } + // Validate that the current agent exists and has a model // (currentAgent might have been changed by options) defaultAgent, err = r.team.Agent(r.currentAgent)