Skip to content

Commit 64886d3

Browse files
cexllSWE-Agent.ai
andcommitted
fix(codeagent-wrapper): remove 150-char truncation limit for KeyOutput in summary mode
maxLen=0 in extractKeyOutputFromLines now means unlimited, so the orchestrator receives the agent's full concluding summary instead of a 150-character stub. Negative maxLen still returns empty. Structured summary format and log-path-only behaviour are preserved. Generated with SWE-Agent.ai Co-Authored-By: SWE-Agent.ai <noreply@swe-agent.ai>
1 parent 08877af commit 64886d3

3 files changed

Lines changed: 41 additions & 6 deletions

File tree

codeagent-wrapper/internal/app/cli.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ func runParallelMode(cmd *cobra.Command, args []string, opts *cliOptions, v *vip
545545
results[i].CoverageNum = extractCoverageNum(results[i].Coverage)
546546
results[i].FilesChanged = extractFilesChangedFromLines(lines)
547547
results[i].TestsPassed, results[i].TestsFailed = extractTestResultsFromLines(lines)
548-
results[i].KeyOutput = extractKeyOutputFromLines(lines, 150)
548+
results[i].KeyOutput = extractKeyOutputFromLines(lines, 0)
549549
}
550550

551551
if err := writeStructuredOutput(outputPath, results); err != nil {

codeagent-wrapper/internal/app/utils.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -479,11 +479,19 @@ func extractNumberBefore(s string, idx int) int {
479479
}
480480

481481
// extractKeyOutputFromLines extracts key output from pre-split lines.
482+
// maxLen=0 means unlimited; maxLen<0 returns "".
482483
func extractKeyOutputFromLines(lines []string, maxLen int) string {
483-
if len(lines) == 0 || maxLen <= 0 {
484+
if len(lines) == 0 || maxLen < 0 {
484485
return ""
485486
}
486487

488+
mayTruncate := func(s string) string {
489+
if maxLen == 0 {
490+
return s
491+
}
492+
return safeTruncate(s, maxLen)
493+
}
494+
487495
// Priority 1: Look for explicit summary lines
488496
for _, line := range lines {
489497
line = strings.TrimSpace(line)
@@ -498,7 +506,7 @@ func extractKeyOutputFromLines(lines []string, maxLen int) string {
498506
}
499507
content = strings.TrimSpace(content)
500508
if len(content) > 0 {
501-
return safeTruncate(content, maxLen)
509+
return mayTruncate(content)
502510
}
503511
}
504512
}
@@ -514,10 +522,10 @@ func extractKeyOutputFromLines(lines []string, maxLen int) string {
514522
if len(line) < 20 {
515523
continue
516524
}
517-
return safeTruncate(line, maxLen)
525+
return mayTruncate(line)
518526
}
519527

520-
// Fallback: truncate entire message
528+
// Fallback: return entire message
521529
clean := strings.TrimSpace(strings.Join(lines, "\n"))
522-
return safeTruncate(clean, maxLen)
530+
return mayTruncate(clean)
523531
}

codeagent-wrapper/internal/app/utils_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,33 @@ func TestSafeTruncate(t *testing.T) {
122122
}
123123
}
124124

125+
func TestExtractKeyOutputFromLines(t *testing.T) {
126+
tests := []struct {
127+
name string
128+
lines []string
129+
maxLen int
130+
want string
131+
}{
132+
{"empty lines returns empty", []string{}, 0, ""},
133+
{"negative maxLen returns empty", []string{"hello world"}, -1, ""},
134+
{"unlimited: summary prefix returned in full", []string{"Summary: all done with a very long description that exceeds 150 characters and should not be cut off at all"}, 0, "all done with a very long description that exceeds 150 characters and should not be cut off at all"},
135+
{"unlimited: first meaningful line returned in full", []string{"this is a meaningful line that is longer than twenty chars and should not be truncated"}, 0, "this is a meaningful line that is longer than twenty chars and should not be truncated"},
136+
{"unlimited: skips noise lines", []string{"---", "# heading", "short", "this is a meaningful line longer than twenty chars"}, 0, "this is a meaningful line longer than twenty chars"},
137+
{"limited: summary prefix truncated", []string{"Summary: hello world truncated"}, 10, "hello w..."},
138+
{"limited: first meaningful line truncated", []string{"this is a long meaningful line that will be truncated"}, 20, "this is a long me..."},
139+
{"unlimited: fallback joins all lines", []string{"short", "also short"}, 0, "short\nalso short"},
140+
}
141+
142+
for _, tt := range tests {
143+
t.Run(tt.name, func(t *testing.T) {
144+
got := extractKeyOutputFromLines(tt.lines, tt.maxLen)
145+
if got != tt.want {
146+
t.Fatalf("extractKeyOutputFromLines(%v, %d) = %q, want %q", tt.lines, tt.maxLen, got, tt.want)
147+
}
148+
})
149+
}
150+
}
151+
125152
func TestSanitizeOutput(t *testing.T) {
126153
tests := []struct {
127154
name string

0 commit comments

Comments
 (0)