From 25699ca15438b5151e7fceea2881bb6b30637420 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Sat, 15 Aug 2026 23:41:44 +1000 Subject: [PATCH] fix(tools): avoid predeclared max names --- internal/tools/budget_test.go | 6 +++--- internal/tools/builtin/grep.go | 4 ++-- internal/tools/limit.go | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/internal/tools/budget_test.go b/internal/tools/budget_test.go index 13b393dc7..09846b0fe 100644 --- a/internal/tools/budget_test.go +++ b/internal/tools/budget_test.go @@ -470,10 +470,10 @@ func TestWriteSpillSanitisesToolName(t *testing.T) { func TestCapPayloadKeepsRunesIntact(t *testing.T) { payload := strings.Repeat("é", 100) // 2 bytes per rune - for max := 1; max <= 20; max++ { - got := CapPayload("read", payload, max, nil) + for limit := 1; limit <= 20; limit++ { + got := CapPayload("read", payload, limit, nil) if !utf8.ValidString(got) { - t.Errorf("max=%d: CapPayload() returned invalid UTF-8: %q", max, got) + t.Errorf("limit=%d: CapPayload() returned invalid UTF-8: %q", limit, got) } } } diff --git a/internal/tools/builtin/grep.go b/internal/tools/builtin/grep.go index c038fb981..cb75d06db 100644 --- a/internal/tools/builtin/grep.go +++ b/internal/tools/builtin/grep.go @@ -316,8 +316,8 @@ func capGrepResult(output string, limit int) Result { // truncationBoundary returns the largest cut point <= max that does not split // a UTF-8 rune. -func truncationBoundary(s string, max int) int { - cut := max +func truncationBoundary(s string, limit int) int { + cut := limit for cut > 0 && !utf8.RuneStart(s[cut]) { cut-- } diff --git a/internal/tools/limit.go b/internal/tools/limit.go index 13cbf89c9..14a87999b 100644 --- a/internal/tools/limit.go +++ b/internal/tools/limit.go @@ -5,7 +5,7 @@ package tools // // JSON numbers decode as float64, but a model that emits an integer through // a different provider path can arrive as int, so both are accepted. -func ListLimit(input map[string]any, def, max int) int { +func ListLimit(input map[string]any, def, maxLimit int) int { var limit int switch v := input["limit"].(type) { case float64: @@ -16,8 +16,8 @@ func ListLimit(input map[string]any, def, max int) int { if limit <= 0 { return def } - if limit > max { - return max + if limit > maxLimit { + return maxLimit } return limit }