@@ -249,11 +249,6 @@ func WithEnv(env []string) Opt {
249249// NewLocalRuntime creates a new LocalRuntime without the persistence wrapper.
250250// This is useful for testing or when persistence is handled externally.
251251func NewLocalRuntime (agents * team.Team , opts ... Opt ) (* LocalRuntime , error ) {
252- modelsStore , err := modelsdev .NewStore ()
253- if err != nil {
254- return nil , err
255- }
256-
257252 defaultAgent , err := agents .DefaultAgent ()
258253 if err != nil {
259254 return nil , err
@@ -265,7 +260,6 @@ func NewLocalRuntime(agents *team.Team, opts ...Opt) (*LocalRuntime, error) {
265260 currentAgent : defaultAgent .Name (),
266261 resumeChan : make (chan ResumeRequest ),
267262 elicitationRequestCh : make (chan ElicitationResult ),
268- modelsStore : modelsStore ,
269263 sessionCompaction : true ,
270264 managedOAuth : true ,
271265 sessionStore : session .NewInMemorySessionStore (),
@@ -275,6 +269,14 @@ func NewLocalRuntime(agents *team.Team, opts ...Opt) (*LocalRuntime, error) {
275269 opt (r )
276270 }
277271
272+ if r .modelsStore == nil {
273+ modelsStore , err := modelsdev .NewStore ()
274+ if err != nil {
275+ return nil , err
276+ }
277+ r .modelsStore = modelsStore
278+ }
279+
278280 // Validate that the current agent exists and has a model
279281 // (currentAgent might have been changed by options)
280282 defaultAgent , err = r .team .Agent (r .currentAgent )
0 commit comments