From 58f1fb0932847ee0806df604a7d36ef5e6c9174b Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Tue, 13 Jan 2026 09:14:04 +0530 Subject: [PATCH 1/5] chore: update version to 0.11.6 --- lib/msgfmt/format_tool_call.go | 54 ++++++++++++++++++- lib/msgfmt/msgfmt_test.go | 2 +- .../codex/remove-task-tool-call/expected.txt | 11 ++++ .../expected_tool_calls.txt | 17 ++++++ .../codex/remove-task-tool-call/msg.txt | 30 +++++++++++ .../codex/remove-task-tool-call/user.txt | 1 + 6 files changed, 113 insertions(+), 2 deletions(-) create mode 100644 lib/msgfmt/testdata/format/codex/remove-task-tool-call/expected.txt create mode 100644 lib/msgfmt/testdata/format/codex/remove-task-tool-call/expected_tool_calls.txt create mode 100644 lib/msgfmt/testdata/format/codex/remove-task-tool-call/msg.txt create mode 100644 lib/msgfmt/testdata/format/codex/remove-task-tool-call/user.txt diff --git a/lib/msgfmt/format_tool_call.go b/lib/msgfmt/format_tool_call.go index 8af1fdca..e6bf4904 100644 --- a/lib/msgfmt/format_tool_call.go +++ b/lib/msgfmt/format_tool_call.go @@ -50,6 +50,58 @@ func removeClaudeReportTaskToolCall(msg string) (string, []string) { return strings.TrimLeft(strings.Join(lines, "\n"), "\n"), toolCallMessages } +func removeCodexReportTaskToolCall(msg string) (string, []string) { + msg += "\n" // This handles the case where the message ends with a tool call + lines := strings.Split(msg, "\n") + + toolCallStartIdx := -1 + + // Store all tool call start and end indices [[start, end], ...] + var toolCallIdxs [][]int + + for idx := 0; idx < len(lines)-1; { + line := strings.TrimSpace(lines[idx]) + nextLine := strings.TrimSpace(lines[idx+1]) + + if strings.Replace(line, " ", "", -1) == "•Called" && strings.Contains(nextLine, "Coder.coder_report_task") { + toolCallStartIdx = idx + } else if toolCallStartIdx != -1 && line == "{\"message\": \"Thanks for reporting!\"}" { + // Store [start, end] pair + // trim all the remaining empty lines after tool call + for idx+1 < len(lines)-1 { + if strings.TrimSpace(lines[idx+1]) == "" { + idx++ + } else { + break + } + } + toolCallIdxs = append(toolCallIdxs, []int{toolCallStartIdx, min(len(lines), idx+1)}) + + // Reset to find the next tool call + toolCallStartIdx = -1 + } + idx++ + } + + // If no tool calls found, return original message + if len(toolCallIdxs) == 0 { + return strings.TrimRight(msg, "\n"), []string{} + } + + toolCallMessages := make([]string, 0) + + // Remove tool calls from the message + for i := len(toolCallIdxs) - 1; i >= 0; i-- { + idxPair := toolCallIdxs[i] + start, end := idxPair[0], idxPair[1] + + toolCallMessages = append(toolCallMessages, strings.Join(lines[start:end], "\n")) + + lines = append(lines[:start], lines[end:]...) + } + return strings.TrimRight(strings.Join(lines, "\n"), "\n"), toolCallMessages +} + func FormatToolCall(agentType AgentType, message string) (string, []string) { switch agentType { case AgentTypeClaude: @@ -59,7 +111,7 @@ func FormatToolCall(agentType AgentType, message string) (string, []string) { case AgentTypeAider: return message, []string{} case AgentTypeCodex: - return message, []string{} + return removeCodexReportTaskToolCall(message) case AgentTypeGemini: return message, []string{} case AgentTypeCopilot: diff --git a/lib/msgfmt/msgfmt_test.go b/lib/msgfmt/msgfmt_test.go index 312b6747..624967c0 100644 --- a/lib/msgfmt/msgfmt_test.go +++ b/lib/msgfmt/msgfmt_test.go @@ -218,7 +218,7 @@ func TestTrimEmptyLines(t *testing.T) { func TestFormatAgentMessage(t *testing.T) { dir := "testdata/format" - agentTypes := []AgentType{AgentTypeClaude, AgentTypeGoose, AgentTypeAider, AgentTypeGemini, AgentTypeCopilot, AgentTypeAmp, AgentTypeCodex, AgentTypeCursor, AgentTypeAuggie, AgentTypeAmazonQ, AgentTypeOpencode, AgentTypeCustom} + agentTypes := []AgentType{AgentTypeCodex} for _, agentType := range agentTypes { t.Run(string(agentType), func(t *testing.T) { cases, err := testdataDir.ReadDir(path.Join(dir, string(agentType))) diff --git a/lib/msgfmt/testdata/format/codex/remove-task-tool-call/expected.txt b/lib/msgfmt/testdata/format/codex/remove-task-tool-call/expected.txt new file mode 100644 index 00000000..96d1153f --- /dev/null +++ b/lib/msgfmt/testdata/format/codex/remove-task-tool-call/expected.txt @@ -0,0 +1,11 @@ +• Codex says: I'm starting by reporting the task as working with a + summary about reviewing the repository structure to gather + information for planning the snake game implementation. Next, + I'll inspect the repository files. + +• I'm drafting a concise final message starting with "Codex says:" + that briefly explains adding a terminal-based snake game in + snake.py, highlights key features like controls and scoring, + notes the need to run with python3 due to missing python alias, + includes usage instructions, and suggests next steps—all + formatted as short bullet points with a simple optional header. \ No newline at end of file diff --git a/lib/msgfmt/testdata/format/codex/remove-task-tool-call/expected_tool_calls.txt b/lib/msgfmt/testdata/format/codex/remove-task-tool-call/expected_tool_calls.txt new file mode 100644 index 00000000..524b73fe --- /dev/null +++ b/lib/msgfmt/testdata/format/codex/remove-task-tool-call/expected_tool_calls.txt @@ -0,0 +1,17 @@ +• Called + └ Coder.coder_report_task({"link":"snake- + game","state":"working","summary":"Reviewing repository + structure before coding"}) + {"message": "Thanks for reporting!"} +--- +• Called + └ Coder.coder_report_task({"link":"snake- + game","state":"working","summary":"Status 2"}) + {"message": "Thanks for reporting!"} + + +--- +• Called + └ Coder.coder_report_task({"link":"snake- + game","state":"working","summary":"Status 1"}) + {"message": "Thanks for reporting!"} diff --git a/lib/msgfmt/testdata/format/codex/remove-task-tool-call/msg.txt b/lib/msgfmt/testdata/format/codex/remove-task-tool-call/msg.txt new file mode 100644 index 00000000..251e5057 --- /dev/null +++ b/lib/msgfmt/testdata/format/codex/remove-task-tool-call/msg.txt @@ -0,0 +1,30 @@ +› Build a snake game + +• Called + └ Coder.coder_report_task({"link":"snake- + game","state":"working","summary":"Status 1"}) + {"message": "Thanks for reporting!"} + +• Codex says: I'm starting by reporting the task as working with a + summary about reviewing the repository structure to gather + information for planning the snake game implementation. Next, + I'll inspect the repository files. + +• Called + └ Coder.coder_report_task({"link":"snake- + game","state":"working","summary":"Status 2"}) + {"message": "Thanks for reporting!"} + + +• I'm drafting a concise final message starting with "Codex says:" + that briefly explains adding a terminal-based snake game in + snake.py, highlights key features like controls and scoring, + notes the need to run with python3 due to missing python alias, + includes usage instructions, and suggests next steps—all + formatted as short bullet points with a simple optional header. + +• Called + └ Coder.coder_report_task({"link":"snake- + game","state":"working","summary":"Reviewing repository + structure before coding"}) + {"message": "Thanks for reporting!"} \ No newline at end of file diff --git a/lib/msgfmt/testdata/format/codex/remove-task-tool-call/user.txt b/lib/msgfmt/testdata/format/codex/remove-task-tool-call/user.txt new file mode 100644 index 00000000..abeefff7 --- /dev/null +++ b/lib/msgfmt/testdata/format/codex/remove-task-tool-call/user.txt @@ -0,0 +1 @@ +Build a snake game \ No newline at end of file From be6e31d65aa405bac33a341b03bc47f30ba9ea86 Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Tue, 13 Jan 2026 15:52:08 +0530 Subject: [PATCH 2/5] fix: address comment --- lib/msgfmt/format_tool_call.go | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/msgfmt/format_tool_call.go b/lib/msgfmt/format_tool_call.go index e6bf4904..24f1c5a3 100644 --- a/lib/msgfmt/format_tool_call.go +++ b/lib/msgfmt/format_tool_call.go @@ -51,7 +51,6 @@ func removeClaudeReportTaskToolCall(msg string) (string, []string) { } func removeCodexReportTaskToolCall(msg string) (string, []string) { - msg += "\n" // This handles the case where the message ends with a tool call lines := strings.Split(msg, "\n") toolCallStartIdx := -1 @@ -59,23 +58,29 @@ func removeCodexReportTaskToolCall(msg string) (string, []string) { // Store all tool call start and end indices [[start, end], ...] var toolCallIdxs [][]int - for idx := 0; idx < len(lines)-1; { + for idx := 0; idx < len(lines); { line := strings.TrimSpace(lines[idx]) - nextLine := strings.TrimSpace(lines[idx+1]) - if strings.Replace(line, " ", "", -1) == "•Called" && strings.Contains(nextLine, "Coder.coder_report_task") { - toolCallStartIdx = idx - } else if toolCallStartIdx != -1 && line == "{\"message\": \"Thanks for reporting!\"}" { + // Check for tool call start (requires looking at next line) + if idx+1 < len(lines) { + nextLine := strings.TrimSpace(lines[idx+1]) + if strings.Replace(line, " ", "", -1) == "•Called" && strings.Contains(nextLine, "Coder.coder_report_task") { + toolCallStartIdx = idx + } + } + + // Check for tool call end + if toolCallStartIdx != -1 && line == "{\"message\": \"Thanks for reporting!\"}" { // Store [start, end] pair // trim all the remaining empty lines after tool call - for idx+1 < len(lines)-1 { + for idx+1 < len(lines) { if strings.TrimSpace(lines[idx+1]) == "" { idx++ } else { break } } - toolCallIdxs = append(toolCallIdxs, []int{toolCallStartIdx, min(len(lines), idx+1)}) + toolCallIdxs = append(toolCallIdxs, []int{toolCallStartIdx, idx + 1}) // Reset to find the next tool call toolCallStartIdx = -1 From 12005443943487b451536c1852c0c55f6783787f Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Tue, 13 Jan 2026 16:05:12 +0530 Subject: [PATCH 3/5] fix: address comment --- lib/msgfmt/format_tool_call.go | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/lib/msgfmt/format_tool_call.go b/lib/msgfmt/format_tool_call.go index 24f1c5a3..826e872e 100644 --- a/lib/msgfmt/format_tool_call.go +++ b/lib/msgfmt/format_tool_call.go @@ -58,7 +58,7 @@ func removeCodexReportTaskToolCall(msg string) (string, []string) { // Store all tool call start and end indices [[start, end], ...] var toolCallIdxs [][]int - for idx := 0; idx < len(lines); { + for idx := 0; idx < len(lines); idx++ { line := strings.TrimSpace(lines[idx]) // Check for tool call start (requires looking at next line) @@ -71,21 +71,16 @@ func removeCodexReportTaskToolCall(msg string) (string, []string) { // Check for tool call end if toolCallStartIdx != -1 && line == "{\"message\": \"Thanks for reporting!\"}" { - // Store [start, end] pair - // trim all the remaining empty lines after tool call - for idx+1 < len(lines) { - if strings.TrimSpace(lines[idx+1]) == "" { - idx++ - } else { - break - } + // Find the end of trailing empty lines after tool call + endIdx := idx + 1 + for endIdx < len(lines) && strings.TrimSpace(lines[endIdx]) == "" { + endIdx++ } - toolCallIdxs = append(toolCallIdxs, []int{toolCallStartIdx, idx + 1}) + toolCallIdxs = append(toolCallIdxs, []int{toolCallStartIdx, endIdx}) // Reset to find the next tool call toolCallStartIdx = -1 } - idx++ } // If no tool calls found, return original message From abcf21f45627be573f2458c129a1eaf7ee0a3838 Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Tue, 13 Jan 2026 16:06:22 +0530 Subject: [PATCH 4/5] fix: address comment --- .../format/codex/remove-task-tool-call/expected_tool_calls.txt | 1 - lib/msgfmt/testdata/format/codex/remove-task-tool-call/msg.txt | 1 - 2 files changed, 2 deletions(-) diff --git a/lib/msgfmt/testdata/format/codex/remove-task-tool-call/expected_tool_calls.txt b/lib/msgfmt/testdata/format/codex/remove-task-tool-call/expected_tool_calls.txt index 524b73fe..53a8d679 100644 --- a/lib/msgfmt/testdata/format/codex/remove-task-tool-call/expected_tool_calls.txt +++ b/lib/msgfmt/testdata/format/codex/remove-task-tool-call/expected_tool_calls.txt @@ -9,7 +9,6 @@ game","state":"working","summary":"Status 2"}) {"message": "Thanks for reporting!"} - --- • Called └ Coder.coder_report_task({"link":"snake- diff --git a/lib/msgfmt/testdata/format/codex/remove-task-tool-call/msg.txt b/lib/msgfmt/testdata/format/codex/remove-task-tool-call/msg.txt index 251e5057..abe429d8 100644 --- a/lib/msgfmt/testdata/format/codex/remove-task-tool-call/msg.txt +++ b/lib/msgfmt/testdata/format/codex/remove-task-tool-call/msg.txt @@ -15,7 +15,6 @@ game","state":"working","summary":"Status 2"}) {"message": "Thanks for reporting!"} - • I'm drafting a concise final message starting with "Codex says:" that briefly explains adding a terminal-based snake game in snake.py, highlights key features like controls and scoring, From da7834429ed72d92ddd173cb2ece069aa327088b Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Tue, 13 Jan 2026 20:08:59 +0530 Subject: [PATCH 5/5] fix: address comment --- lib/msgfmt/msgfmt_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/msgfmt/msgfmt_test.go b/lib/msgfmt/msgfmt_test.go index 624967c0..312b6747 100644 --- a/lib/msgfmt/msgfmt_test.go +++ b/lib/msgfmt/msgfmt_test.go @@ -218,7 +218,7 @@ func TestTrimEmptyLines(t *testing.T) { func TestFormatAgentMessage(t *testing.T) { dir := "testdata/format" - agentTypes := []AgentType{AgentTypeCodex} + agentTypes := []AgentType{AgentTypeClaude, AgentTypeGoose, AgentTypeAider, AgentTypeGemini, AgentTypeCopilot, AgentTypeAmp, AgentTypeCodex, AgentTypeCursor, AgentTypeAuggie, AgentTypeAmazonQ, AgentTypeOpencode, AgentTypeCustom} for _, agentType := range agentTypes { t.Run(string(agentType), func(t *testing.T) { cases, err := testdataDir.ReadDir(path.Join(dir, string(agentType)))