Skip to content

Comments

Include todo list in system prompt to survive condensation#11434

Closed
0xMink wants to merge 2 commits intoRooCodeInc:mainfrom
0xMink:feat/prompts-include-todo-list
Closed

Include todo list in system prompt to survive condensation#11434
0xMink wants to merge 2 commits intoRooCodeInc:mainfrom
0xMink:feat/prompts-include-todo-list

Conversation

@0xMink
Copy link
Contributor

@0xMink 0xMink commented Feb 12, 2026

Summary

Fixes #11433

  • Render the current todo list as a dedicated CURRENT TODO LIST section in the system prompt when todo items exist
  • Wire todoList through both the task execution path (Task.ts) and webview prompt generator (generateSystemPrompt.ts)
  • Sanitize todo content for table integrity: pipe escaping, newline normalization, whitespace collapse
  • Treat todo entries as data (not instructions) to prevent prompt injection via crafted todo content

Test Plan

  • Unit tests for formatTodoListSection (13 tests): empty/undefined handling, status mapping, pipe escaping, newline normalization, whitespace collapse, table structure
  • Integration tests for SYSTEM_PROMPT (3 tests): section present with todos, absent when empty, absent when undefined
  • All 27 tests passing
  • No snapshot breakage

The todo list was only visible via ephemeral message content in
environment_details. After context condensation, the model could lose
awareness of outstanding work. Render the current todo list as a
dedicated system-prompt section when present, with sanitization for
table integrity (pipe escaping, newline normalization, whitespace
collapse). Wire todoList through both the task execution path and
the webview prompt generator.
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. Enhancement New feature or request labels Feb 12, 2026
@roomote
Copy link
Contributor

roomote bot commented Feb 12, 2026

Rooviewer Clock   See task

Reviewed changes since last review. Previous issue resolved, no new issues found.

  • formatTodoListSection missing backslash escaping before pipe escaping (inconsistent with existing formatReminderSection pattern, can break table with \| in content)
Previous reviews

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

Comment on lines 68 to 72
const normalizedContent = item.content
.replace(/\r?\n/g, " ")
.replace(/\|/g, "\\|")
.replace(/\s+/g, " ")
.trim()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sanitization chain escapes pipes but not pre-existing backslashes. The existing formatReminderSection in reminder.ts does .replace(/\\/g, "\\\\" ).replace(/\|/g, "\\|") -- backslashes first, then pipes. Without that first step here, content like foo\|bar produces foo\\|bar after pipe escaping, where \\ is an escaped backslash and | is a raw pipe that breaks the table structure.

Suggested change
const normalizedContent = item.content
.replace(/\r?\n/g, " ")
.replace(/\|/g, "\\|")
.replace(/\s+/g, " ")
.trim()
const normalizedContent = item.content
.replace(/\r?\n/g, " ")
.replace(/\\/g, "\\\\")
.replace(/\|/g, "\\|")
.replace(/\s+/g, " ")
.trim()

Fix it with Roo Code or mention @roomote and request a fix.

Without backslash-first escaping, content containing \| resolves into
a raw table pipe after pipe-escaping, breaking the markdown table.
Matches the escaping order already used by formatReminderSection in
reminder.ts. Includes regression test.
@0xMink
Copy link
Contributor Author

0xMink commented Feb 12, 2026

Addressed roomote/CodeQL feedback: formatTodoListSection() now escapes backslashes before pipe-escaping (prevents \| from becoming a raw table pipe), matching the order used by formatReminderSection in reminder.ts. Includes a regression test covering that case. 28/28 tests passing.

@hannesrudolph
Copy link
Collaborator

Closing: PR lacks clear evidence of manual testing.

@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Feb 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Todo list lost from system prompt after context condensation

2 participants