(t *testing.T)
| 720 | func TestStreamingToolExecutorFIFOAggregateBudget(t *testing.T) { |
| 721 | registry := coretools.NewToolRegistry(newLargeReadTool()) |
| 722 | cfg := config.NewConfig() |
| 723 | cfg.MaxMessageToolResultsChars = 120 |
| 724 | cfg.SessionDir = t.TempDir() |
| 725 | state := agent.NewAgentState() |
| 726 | executor := agent.NewStreamingToolExecutor(registry, cfg, &state, coretools.ExecutionContext{}) |
| 727 | executor.AddTool(coretools.ToolCall{ID: "tool-1", Name: "large_read", Input: map[string]any{"content": strings.Repeat("a", 100)}}) |
| 728 | executor.AddTool(coretools.ToolCall{ID: "tool-2", Name: "large_read", Input: map[string]any{"content": strings.Repeat("b", 100)}}) |
| 729 | |
| 730 | results := executor.GetRemainingResults(context.Background()) |
| 731 | if len(results) != 2 { |
| 732 | t.Fatalf("expected 2 results, got %d", len(results)) |
| 733 | } |
| 734 | if results[0]["tool_use_id"] != "tool-1" || results[1]["tool_use_id"] != "tool-2" { |
| 735 | t.Fatalf("results not FIFO: %#v", results) |
| 736 | } |
| 737 | total := 0 |
| 738 | for _, result := range results { |
| 739 | total += len(result["content"].(string)) |
| 740 | } |
| 741 | if total <= 120 { |
| 742 | return |
| 743 | } |
| 744 | if !strings.Contains(results[0]["content"].(string), "aggregate tool-result budget") { |
| 745 | t.Fatalf("expected aggregate truncation, total=%d results=%#v", total, results) |
| 746 | } |
| 747 | } |
| 748 | |
| 749 | func TestDeniedToolResultContentEscalates(t *testing.T) { |
| 750 | state := agent.NewAgentState() |
| 751 | call := coretools.ToolCall{ID: "tool-1", Name: "write_file", Input: map[string]any{}} |
| 752 | agent.DeniedToolResultContent(&state, call) |
nothing calls this directly
no test coverage detected