Skip to content

Commit 751310f

Browse files
committed
feat: add test for malformed tool_call
1 parent 96bda53 commit 751310f

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

lib/msgfmt/format_tool_call.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,10 @@ func removeClaudeReportTaskToolCall(msg string) (string, []string) {
6666

6767
// If the toolCall is malformed, we don't want to log it
6868
if !toolCallIdxs[i].malformed {
69+
toolCallMessages = append(toolCallMessages, strings.Join(lines[start:end], "\n"))
70+
} else {
6971
// [DEBUG] print, will remove before merge
7072
fmt.Printf("Found malformed toolCall with newLineAfterToolCall, start: %d, end: %d, toolcall: %s", start, end, strings.Join(lines[start:end], "\n"))
71-
toolCallMessages = append(toolCallMessages, strings.Join(lines[start:end], "\n"))
7273
}
7374

7475
lines = append(lines[:start], lines[end:]...)

lib/msgfmt/testdata/format/claude/remove-task-tool-call/expected.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,6 @@
4040
Open the HTML file in your web browser and use the arrow keys
4141
to move the snake. Collect the red food to grow and increase
4242
your score!
43+
44+
45+
Above is a malformed tool call message

lib/msgfmt/testdata/format/claude/remove-task-tool-call/msg.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@
7272
"message": "Thanks for reporting!"
7373
}
7474

75+
coder - coder_report_task (MCP)(summary: "Snake game created
76+
successfully at snake-game.html",
77+
link: "file:///home/coder/snake-ga
78+
me.html", state: "working")
79+
80+
Above is a malformed tool call message
81+
7582

7683
───────────────────────────────────────────────────────────────────
7784

0 commit comments

Comments
 (0)