runtimeOpts returns the runtime options derived from the current flags, the loaded team and the runtime configuration. The session store and the current agent name are passed in because they're resolved by callers from different sources (e.g. the spawner uses the same store as the parent).
(loadResult *teamloader.LoadResult, runConfig *config.RuntimeConfig, sessStore session.Store, agentName string)
| 736 | // current agent name are passed in because they're resolved by callers from |
| 737 | // different sources (e.g. the spawner uses the same store as the parent). |
| 738 | func (f *runExecFlags) runtimeOpts(loadResult *teamloader.LoadResult, runConfig *config.RuntimeConfig, sessStore session.Store, agentName string) []runtime.Opt { |
| 739 | modelSwitcherCfg := &runtime.ModelSwitcherConfig{ |
| 740 | Models: loadResult.Models, |
| 741 | Providers: loadResult.Providers, |
| 742 | ModelsGateway: runConfig.ModelsGateway, |
| 743 | EnvProvider: runConfig.EnvProvider(), |
| 744 | ProviderRegistry: loadResult.ProviderRegistry, |
| 745 | AgentDefaultModels: loadResult.AgentDefaultModels, |
| 746 | } |
| 747 | // Share the models.dev store the team loader already warmed (parsing the |
| 748 | // multi-MB catalog once) so the runtime doesn't build its own cold store |
| 749 | // and re-pay the parse on the first /model open. On error we leave it unset |
| 750 | // and the runtime falls back to its lazy default. |
| 751 | if store, err := runConfig.ModelsDevStore(); err == nil { |
| 752 | modelSwitcherCfg.ModelsStore = store |
| 753 | } else { |
| 754 | slog.Warn("Failed to obtain shared models.dev store; runtime will use its own", "error", err) |
| 755 | } |
| 756 | opts := []runtime.Opt{ |
| 757 | runtime.WithSessionStore(sessStore), |
| 758 | runtime.WithCurrentAgent(agentName), |
| 759 | runtime.WithWorkingDir(runConfig.WorkingDir), |
| 760 | runtime.WithTracer(otel.Tracer(AppName)), |
| 761 | runtime.WithModelSwitcherConfig(modelSwitcherCfg), |
| 762 | } |
| 763 | return opts |
| 764 | } |
| 765 | |
| 766 | // snapshotRuntimeOpts wires the snapshot builtin into a runtime. |
| 767 | // Returns the [runtime.Opt]s that hand the registry and the |