MCPcopy Create free account
hub / github.com/GongShichen/LuminaCode / TestStreamingToolExecutorFIFOAggregateBudget

Function TestStreamingToolExecutorFIFOAggregateBudget

test/agent_test.go:722–749  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

720func 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
749func 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)

Callers

nothing calls this directly

Calls 6

AddToolMethod · 0.95
GetRemainingResultsMethod · 0.95
NewConfigFunction · 0.92
NewAgentStateFunction · 0.92
NewStreamingToolExecutorFunction · 0.92
newLargeReadToolFunction · 0.85

Tested by

no test coverage detected