mirror of
https://github.com/cexll/myclaude.git
synced 2026-03-03 15:33:14 +08:00
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>
This commit is contained in:
@@ -545,7 +545,7 @@ func runParallelMode(cmd *cobra.Command, args []string, opts *cliOptions, v *vip
|
|||||||
results[i].CoverageNum = extractCoverageNum(results[i].Coverage)
|
results[i].CoverageNum = extractCoverageNum(results[i].Coverage)
|
||||||
results[i].FilesChanged = extractFilesChangedFromLines(lines)
|
results[i].FilesChanged = extractFilesChangedFromLines(lines)
|
||||||
results[i].TestsPassed, results[i].TestsFailed = extractTestResultsFromLines(lines)
|
results[i].TestsPassed, results[i].TestsFailed = extractTestResultsFromLines(lines)
|
||||||
results[i].KeyOutput = extractKeyOutputFromLines(lines, 150)
|
results[i].KeyOutput = extractKeyOutputFromLines(lines, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := writeStructuredOutput(outputPath, results); err != nil {
|
if err := writeStructuredOutput(outputPath, results); err != nil {
|
||||||
|
|||||||
@@ -479,11 +479,19 @@ func extractNumberBefore(s string, idx int) int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// extractKeyOutputFromLines extracts key output from pre-split lines.
|
// extractKeyOutputFromLines extracts key output from pre-split lines.
|
||||||
|
// maxLen=0 means unlimited; maxLen<0 returns "".
|
||||||
func extractKeyOutputFromLines(lines []string, maxLen int) string {
|
func extractKeyOutputFromLines(lines []string, maxLen int) string {
|
||||||
if len(lines) == 0 || maxLen <= 0 {
|
if len(lines) == 0 || maxLen < 0 {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mayTruncate := func(s string) string {
|
||||||
|
if maxLen == 0 {
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
return safeTruncate(s, maxLen)
|
||||||
|
}
|
||||||
|
|
||||||
// Priority 1: Look for explicit summary lines
|
// Priority 1: Look for explicit summary lines
|
||||||
for _, line := range lines {
|
for _, line := range lines {
|
||||||
line = strings.TrimSpace(line)
|
line = strings.TrimSpace(line)
|
||||||
@@ -498,7 +506,7 @@ func extractKeyOutputFromLines(lines []string, maxLen int) string {
|
|||||||
}
|
}
|
||||||
content = strings.TrimSpace(content)
|
content = strings.TrimSpace(content)
|
||||||
if len(content) > 0 {
|
if len(content) > 0 {
|
||||||
return safeTruncate(content, maxLen)
|
return mayTruncate(content)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -514,10 +522,10 @@ func extractKeyOutputFromLines(lines []string, maxLen int) string {
|
|||||||
if len(line) < 20 {
|
if len(line) < 20 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
return safeTruncate(line, maxLen)
|
return mayTruncate(line)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback: truncate entire message
|
// Fallback: return entire message
|
||||||
clean := strings.TrimSpace(strings.Join(lines, "\n"))
|
clean := strings.TrimSpace(strings.Join(lines, "\n"))
|
||||||
return safeTruncate(clean, maxLen)
|
return mayTruncate(clean)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,6 +122,33 @@ func TestSafeTruncate(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestExtractKeyOutputFromLines(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
lines []string
|
||||||
|
maxLen int
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
{"empty lines returns empty", []string{}, 0, ""},
|
||||||
|
{"negative maxLen returns empty", []string{"hello world"}, -1, ""},
|
||||||
|
{"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"},
|
||||||
|
{"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"},
|
||||||
|
{"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"},
|
||||||
|
{"limited: summary prefix truncated", []string{"Summary: hello world truncated"}, 10, "hello w..."},
|
||||||
|
{"limited: first meaningful line truncated", []string{"this is a long meaningful line that will be truncated"}, 20, "this is a long me..."},
|
||||||
|
{"unlimited: fallback joins all lines", []string{"short", "also short"}, 0, "short\nalso short"},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got := extractKeyOutputFromLines(tt.lines, tt.maxLen)
|
||||||
|
if got != tt.want {
|
||||||
|
t.Fatalf("extractKeyOutputFromLines(%v, %d) = %q, want %q", tt.lines, tt.maxLen, got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestSanitizeOutput(t *testing.T) {
|
func TestSanitizeOutput(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
|
|||||||
Reference in New Issue
Block a user