-
Notifications
You must be signed in to change notification settings - Fork 2.8k
test: add regression test for malformed native tool call hang fix #9768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1967,3 +1967,40 @@ describe("Queued message processing after condense", () => { | |
| expect(taskB.messageQueueService.isEmpty()).toBe(true) | ||
| }) | ||
| }) | ||
|
|
||
| describe("Partial tool_use blocks at stream end", () => { | ||
| /** | ||
| * Regression test for: https://github.com/RooCodeInc/Roo-Code/pull/9758 | ||
| * | ||
| * The bug: malformed native tool calls leave partial=true, causing infinite hang. | ||
| * | ||
| * The fix at Task.ts line ~2947 must be: | ||
| * if (partialBlocks.length > 0) { presentAssistantMessage(this) } | ||
| * | ||
| * THE BROKEN CONDITION (causes infinite hang): | ||
| * if (partialBlocks.length > 0 && partialBlocks.some(block => block.type !== "tool_use")) | ||
| * | ||
| * This test reads the actual Task.ts source code and verifies the fix is correct. | ||
| */ | ||
| it("Task.ts must NOT filter out tool_use blocks when calling presentAssistantMessage", async () => { | ||
| const fs = await import("fs") | ||
| const path = await import("path") | ||
|
|
||
| // Read Task.ts source | ||
| const taskTsPath = path.join(__dirname, "..", "Task.ts") | ||
| const taskSource = fs.readFileSync(taskTsPath, "utf-8") | ||
|
|
||
| // The BROKEN pattern we must NOT have: | ||
| const hasBrokenCondition = taskSource.includes('partialBlocks.some((block) => block.type !== "tool_use")') | ||
|
|
||
| // The CORRECT pattern we MUST have: | ||
| const hasCorrectCondition = taskSource.includes( | ||
| "if (partialBlocks.length > 0) {\n\t\t\t\t\t// If there is content to update", | ||
| ) | ||
|
Comment on lines
+1997
to
+1999
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test's string matching for the correct condition is brittle because it relies on exact whitespace and comment text. The test checks for Fix it with Roo Code or mention @roomote and request a fix. |
||
|
|
||
| // The code MUST NOT use the broken condition (filtering out tool_use) | ||
| expect(hasBrokenCondition).toBe(false) | ||
| // The code MUST use the correct condition (simple length check) | ||
| expect(hasCorrectCondition).toBe(true) | ||
| }) | ||
| }) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The check for the correct condition relies on an exact string (with specific newline and tab characters), which could be brittle if formatting changes. Consider using a regex that ignores whitespace differences.