MCPcopy
hub / github.com/docker/docker-agent / TestTitleModelResolution

Function TestTitleModelResolution

pkg/teamloader/teamloader_test.go:218–297  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

216}
217
218func TestTitleModelResolution(t *testing.T) {
219 t.Setenv("OPENAI_API_KEY", "dummy")
220 t.Setenv("ANTHROPIC_API_KEY", "dummy")
221
222 t.Run("named title model", func(t *testing.T) {
223 data := []byte(`models:
224 primary:
225 provider: anthropic
226 model: claude-sonnet-4-5
227 title_model: fast
228 fast:
229 provider: openai
230 model: gpt-4o-mini
231agents:
232 root:
233 model: primary
234 instruction: test
235`)
236
237 team, err := Load(t.Context(), config.NewBytesSource("title.yaml", data), &config.RuntimeConfig{}, withTestProviderRegistry()...)
238 require.NoError(t, err)
239
240 root, err := team.Agent("root")
241 require.NoError(t, err)
242
243 require.NotNil(t, root.TitleModel())
244 assert.Equal(t, "openai/gpt-4o-mini", root.TitleModel().ID().String())
245
246 // The dedicated title model comes first, the agent's own model follows
247 // as a fallback so title generation still works if it is unavailable.
248 models := root.TitleModels(t.Context())
249 require.Len(t, models, 2)
250 assert.Equal(t, "openai/gpt-4o-mini", models[0].ID().String())
251 assert.Equal(t, "anthropic/claude-sonnet-4-5", models[1].ID().String())
252 })
253
254 t.Run("inline title model", func(t *testing.T) {
255 data := []byte(`models:
256 primary:
257 provider: anthropic
258 model: claude-sonnet-4-5
259 title_model: openai/gpt-4o-mini
260agents:
261 root:
262 model: primary
263 instruction: test
264`)
265
266 team, err := Load(t.Context(), config.NewBytesSource("title.yaml", data), &config.RuntimeConfig{}, withTestProviderRegistry()...)
267 require.NoError(t, err)
268
269 root, err := team.Agent("root")
270 require.NoError(t, err)
271
272 require.NotNil(t, root.TitleModel())
273 assert.Equal(t, "openai/gpt-4o-mini", root.TitleModel().ID().String())
274 })
275

Callers

nothing calls this directly

Calls 11

NewBytesSourceFunction · 0.92
withTestProviderRegistryFunction · 0.85
ContextMethod · 0.80
AgentMethod · 0.80
TitleModelMethod · 0.80
TitleModelsMethod · 0.80
LoadFunction · 0.70
RunMethod · 0.65
IDMethod · 0.65
LenMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected