TestNewRuntime_ModelStorePrecedence pins the resolution order for the runtime's models.dev store: an explicit WithModelStore wins; otherwise a store carried on the ModelSwitcherConfig is adopted (this is how the team loader shares the catalog it already warmed); otherwise the runtime builds its own
(t *testing.T)
| 949 | // its own lazy store. Sharing the warmed store is what keeps the first /model |
| 950 | // open from re-paying the multi-MB catalog parse. |
| 951 | func TestNewRuntime_ModelStorePrecedence(t *testing.T) { |
| 952 | t.Parallel() |
| 953 | |
| 954 | newTeam := func() *team.Team { |
| 955 | root := agent.New("root", "test", agent.WithModel(&mockProvider{id: "test/m"})) |
| 956 | return team.New(team.WithAgents(root)) |
| 957 | } |
| 958 | |
| 959 | t.Run("explicit WithModelStore wins over ModelSwitcherConfig", func(t *testing.T) { |
| 960 | t.Parallel() |
| 961 | explicit := &mockCatalogStore{} |
| 962 | cfgStore := &mockCatalogStore{} |
| 963 | rt, err := NewLocalRuntime(t.Context(), newTeam(), |
| 964 | WithModelStore(explicit), |
| 965 | WithModelSwitcherConfig(&ModelSwitcherConfig{ModelsStore: cfgStore}), |
| 966 | ) |
| 967 | require.NoError(t, err) |
| 968 | assert.Same(t, explicit, rt.modelsStore) |
| 969 | }) |
| 970 | |
| 971 | t.Run("ModelSwitcherConfig store is adopted when no explicit store", func(t *testing.T) { |
| 972 | t.Parallel() |
| 973 | cfgStore := &mockCatalogStore{} |
| 974 | rt, err := NewLocalRuntime(t.Context(), newTeam(), |
| 975 | WithModelSwitcherConfig(&ModelSwitcherConfig{ModelsStore: cfgStore}), |
| 976 | ) |
| 977 | require.NoError(t, err) |
| 978 | assert.Same(t, cfgStore, rt.modelsStore) |
| 979 | }) |
| 980 | |
| 981 | t.Run("falls back to lazy store when neither is set", func(t *testing.T) { |
| 982 | t.Parallel() |
| 983 | rt, err := NewLocalRuntime(t.Context(), newTeam(), |
| 984 | WithModelSwitcherConfig(&ModelSwitcherConfig{}), |
| 985 | ) |
| 986 | require.NoError(t, err) |
| 987 | assert.IsType(t, &lazyModelStore{}, rt.modelsStore) |
| 988 | }) |
| 989 | } |
| 990 | |
| 991 | func TestProcessToolCalls_UnknownTool_ReturnsErrorResponse(t *testing.T) { |
| 992 | t.Parallel() |
nothing calls this directly
no test coverage detected