From 7fe1d102cbe15c041cda46abc8301abd7efbb747 Mon Sep 17 00:00:00 2001 From: CheesesNguyen Date: Thu, 5 Mar 2026 14:43:45 +0700 Subject: [PATCH] fix: don't treat empty input as truncation for tools without required fields Tools like TaskList, TaskGet have no required parameters, so empty input is valid. Previously, the truncation detector flagged all empty inputs as truncated, causing these tools to be skipped and breaking the tool loop. Now only flag empty input as truncation when the tool has required fields defined in RequiredFieldsByTool. --- .../kiro/claude/truncation_detector.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/internal/translator/kiro/claude/truncation_detector.go b/internal/translator/kiro/claude/truncation_detector.go index 7a72431b..cc0d3484 100644 --- a/internal/translator/kiro/claude/truncation_detector.go +++ b/internal/translator/kiro/claude/truncation_detector.go @@ -84,13 +84,18 @@ func DetectTruncation(toolName, toolUseID, rawInput string, parsedInput map[stri ParsedFields: make(map[string]string), } - // Scenario 1: Empty input buffer - no data received at all + // Scenario 1: Empty input buffer - only flag as truncation if tool has required fields + // Many tools (e.g. TaskList, TaskGet) have no required params, so empty input is valid if strings.TrimSpace(rawInput) == "" { - info.IsTruncated = true - info.TruncationType = TruncationTypeEmptyInput - info.ErrorMessage = "Tool input was completely empty - API response may have been truncated before tool parameters were transmitted" - log.Warnf("kiro: truncation detected [%s] for tool %s (ID: %s): empty input buffer", - info.TruncationType, toolName, toolUseID) + if _, hasRequirements := RequiredFieldsByTool[toolName]; hasRequirements { + info.IsTruncated = true + info.TruncationType = TruncationTypeEmptyInput + info.ErrorMessage = "Tool input was completely empty - API response may have been truncated before tool parameters were transmitted" + log.Warnf("kiro: truncation detected [%s] for tool %s (ID: %s): empty input buffer", + info.TruncationType, toolName, toolUseID) + return info + } + log.Debugf("kiro: empty input for tool %s (ID: %s) - no required fields, treating as valid", toolName, toolUseID) return info }