Skip to content

fix: normalize literal \n escape sequences in todo list parsing#11978

Draft
roomote-v0[bot] wants to merge 1 commit intomainfrom
fix/todo-literal-newline-splitting
Draft

fix: normalize literal \n escape sequences in todo list parsing#11978
roomote-v0[bot] wants to merge 1 commit intomainfrom
fix/todo-literal-newline-splitting

Conversation

@roomote-v0
Copy link
Contributor

@roomote-v0 roomote-v0 bot commented Mar 21, 2026

Related GitHub Issue

Closes: #11977

Description

This PR attempts to address Issue #11977. Some models/providers (e.g. LiteLLM with qwen3-coder-next) send the todos parameter with literal escape sequences -- the two-character string \n (backslash + n) rather than actual newline characters. This causes all checklist items to end up on a single line, so only one todo item gets parsed.

The fix normalizes literal \n and \r\n escape sequences into actual newline characters in parseMarkdownChecklist() before the existing .split(/\r?\n/) call. This is a minimal, targeted change that handles the mismatch without affecting any other behavior.

Files changed:

  • src/core/tools/UpdateTodoListTool.ts - Added normalization of literal escape sequences
  • src/core/tools/__tests__/updateTodoListTool.spec.ts - Added 3 test cases covering literal \n, literal \r\n, and mixed literal/actual newlines

Test Procedure

  • Added unit tests in updateTodoListTool.spec.ts covering:
    • Items separated by literal \n escape sequences
    • Items separated by literal \r\n escape sequences
    • Mixed literal and actual newlines
  • All 24 tests pass: cd src && npx vitest run core/tools/__tests__/updateTodoListTool.spec.ts
  • Lint and type checks pass across all packages

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes.
  • Documentation Impact: No documentation updates are required.
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Documentation Updates

  • No documentation updates are required.

Additional Notes

Feedback and guidance are welcome.

Interactively review PR in Roo Code Cloud

Some models/providers send the todos parameter with literal escape
sequences (the two-character string \n) rather than actual newline
characters. This causes all checklist items to end up on a single line,
resulting in only one todo item being parsed.

Normalize literal \n and \r\n sequences into actual newlines before
splitting. Adds test coverage for this scenario.

Closes #11977
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] todo items are not split by \n

1 participant