(t *testing.T)
| 353 | } |
| 354 | |
| 355 | func TestMultiStepContextEvolution(t *testing.T) { |
| 356 | |
| 357 | mgr := NewManager(DefaultBudget(200000)) |
| 358 | registerTestTools(mgr) |
| 359 | |
| 360 | engine := NewEngine(mgr, DefaultEngineConfig()) |
| 361 | |
| 362 | plan1 := engine.PrepareContext("multi-step", "get latest commits from github") |
| 363 | t.Logf("Step 1 (GitHub): %d tools loaded", len(plan1.ToolsLoaded)) |
| 364 | |
| 365 | engine.AdaptContext(plan1, ExecutionResult{ |
| 366 | Success: true, |
| 367 | ToolUsed: plan1.ToolsLoaded[0], |
| 368 | Latency: 30 * time.Millisecond, |
| 369 | }) |
| 370 | |
| 371 | for _, id := range plan1.ToolsLoaded { |
| 372 | mgr.Evict(id) |
| 373 | } |
| 374 | plan2 := engine.PrepareContext("multi-step-2", "search jira issues assigned to me") |
| 375 | t.Logf("Step 2 (Jira): %d tools loaded", len(plan2.ToolsLoaded)) |
| 376 | |
| 377 | jiraCount := 0 |
| 378 | githubCount := 0 |
| 379 | for _, id := range plan2.ToolsLoaded { |
| 380 | if strings.HasPrefix(id, "jira") { |
| 381 | jiraCount++ |
| 382 | } |
| 383 | if strings.HasPrefix(id, "github") { |
| 384 | githubCount++ |
| 385 | } |
| 386 | } |
| 387 | |
| 388 | if jiraCount == 0 { |
| 389 | t.Error("step 2 should have loaded Jira tools") |
| 390 | } |
| 391 | if githubCount > jiraCount { |
| 392 | t.Errorf("step 2: Jira tools should dominate (jira=%d, github=%d)", jiraCount, githubCount) |
| 393 | } |
| 394 | |
| 395 | for _, id := range plan2.ToolsLoaded { |
| 396 | mgr.Evict(id) |
| 397 | } |
| 398 | plan3 := engine.PrepareContext("multi-step-3", "send slack message about the new jira issue") |
| 399 | t.Logf("Step 3 (Slack): %d tools loaded", len(plan3.ToolsLoaded)) |
| 400 | |
| 401 | hasSlack := false |
| 402 | for _, id := range plan3.ToolsLoaded { |
| 403 | if strings.HasPrefix(id, "slack") { |
| 404 | hasSlack = true |
| 405 | } |
| 406 | } |
| 407 | if !hasSlack { |
| 408 | t.Error("step 3 should have loaded Slack tools") |
| 409 | } |
| 410 | |
| 411 | t.Logf("Multi-step context evolution: GitHub(%d) → Jira(%d) → Slack(%d)", |
| 412 | len(plan1.ToolsLoaded), len(plan2.ToolsLoaded), len(plan3.ToolsLoaded)) |
nothing calls this directly
no test coverage detected