(t *testing.T)
| 297 | } |
| 298 | |
| 299 | func 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 |
| 312 | agents: |
| 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 |
| 337 | agents: |
| 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 |
nothing calls this directly
no test coverage detected