@@ -58,7 +58,7 @@ func removeCodexReportTaskToolCall(msg string) (string, []string) {
5858 // Store all tool call start and end indices [[start, end], ...]
5959 var toolCallIdxs [][]int
6060
61- for idx := 0 ; idx < len (lines ); {
61+ for idx := 0 ; idx < len (lines ); idx ++ {
6262 line := strings .TrimSpace (lines [idx ])
6363
6464 // Check for tool call start (requires looking at next line)
@@ -71,21 +71,16 @@ func removeCodexReportTaskToolCall(msg string) (string, []string) {
7171
7272 // Check for tool call end
7373 if toolCallStartIdx != - 1 && line == "{\" message\" : \" Thanks for reporting!\" }" {
74- // Store [start, end] pair
75- // trim all the remaining empty lines after tool call
76- for idx + 1 < len (lines ) {
77- if strings .TrimSpace (lines [idx + 1 ]) == "" {
78- idx ++
79- } else {
80- break
81- }
74+ // Find the end of trailing empty lines after tool call
75+ endIdx := idx + 1
76+ for endIdx < len (lines ) && strings .TrimSpace (lines [endIdx ]) == "" {
77+ endIdx ++
8278 }
83- toolCallIdxs = append (toolCallIdxs , []int {toolCallStartIdx , idx + 1 })
79+ toolCallIdxs = append (toolCallIdxs , []int {toolCallStartIdx , endIdx })
8480
8581 // Reset to find the next tool call
8682 toolCallStartIdx = - 1
8783 }
88- idx ++
8984 }
9085
9186 // If no tool calls found, return original message
0 commit comments