MCPcopy Index your code
hub / github.com/docker/docker-agent / TestCompactionModelResolution

Function TestCompactionModelResolution

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

Source from the content-addressed store, hash-verified

297}
298
299func TestCompactionModelResolution(t *testing.T) {
300 t.Setenv("OPENAI_API_KEY", "dummy")
301 t.Setenv("ANTHROPIC_API_KEY", "dummy")
302
303 t.Run("named compaction model", func(t *testing.T) {
304 data := []byte(`models:
305 primary:
306 provider: anthropic
307 model: claude-sonnet-4-5
308 compaction_model: fast
309 fast:
310 provider: openai
311 model: gpt-4o-mini
312agents:
313 root:
314 model: primary
315 instruction: test
316`)
317
318 team, err := Load(t.Context(), config.NewBytesSource("compaction.yaml", data), &config.RuntimeConfig{}, withTestProviderRegistry()...)
319 require.NoError(t, err)
320
321 root, err := team.Agent("root")
322 require.NoError(t, err)
323
324 require.NotNil(t, root.CompactionModel())
325 assert.Equal(t, "openai/gpt-4o-mini", root.CompactionModel().ID().String())
326 // The dedicated compaction model is independent of the primary model
327 // that runs the conversation.
328 assert.Equal(t, "anthropic/claude-sonnet-4-5", root.Model(t.Context()).ID().String())
329 })
330
331 t.Run("inline compaction model", func(t *testing.T) {
332 data := []byte(`models:
333 primary:
334 provider: anthropic
335 model: claude-sonnet-4-5
336 compaction_model: openai/gpt-4o-mini
337agents:
338 root:
339 model: primary
340 instruction: test
341`)
342
343 team, err := Load(t.Context(), config.NewBytesSource("compaction.yaml", data), &config.RuntimeConfig{}, withTestProviderRegistry()...)
344 require.NoError(t, err)
345
346 root, err := team.Agent("root")
347 require.NoError(t, err)
348
349 require.NotNil(t, root.CompactionModel())
350 assert.Equal(t, "openai/gpt-4o-mini", root.CompactionModel().ID().String())
351 })
352
353 t.Run("no compaction model", func(t *testing.T) {
354 data := []byte(`agents:
355 root:
356 model: openai/gpt-4o

Callers

nothing calls this directly

Calls 10

NewBytesSourceFunction · 0.92
withTestProviderRegistryFunction · 0.85
ContextMethod · 0.80
AgentMethod · 0.80
CompactionModelMethod · 0.80
ModelMethod · 0.80
LoadFunction · 0.70
RunMethod · 0.65
IDMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected