⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Conversation

@hannesrudolph
Copy link
Collaborator

@hannesrudolph hannesrudolph commented Jan 24, 2026

Summary

At context condensation time, this PR uses tree-sitter to generate folded code signatures (function definitions, class declarations, etc.) for files that were read during the conversation. Each file is included as its own <system-reminder> block in the condensed summary, preserving structural awareness without consuming excessive tokens.

This allows the model to retain awareness of file structure after condensing, enabling better continuity when working with codebases.

File Selection Behavior

Files accumulate across multiple condensing events within a task:

This is because files_in_context metadata is persisted to disk via saveTaskMetadata(). The getFilesReadByRoo() method queries all files ever read during the task lifetime, not just since the last condense.

File sources included:

  • read_tool - Files explicitly read by the agent
  • file_mentioned - Files mentioned/referenced in conversation

Changes

  • FileContextTracker: Added getFilesReadByRoo() method to query files read during the task (filters by read_tool and file_mentioned sources)

  • foldedFileContext.ts (new file):

    • generateFoldedFileContext() function using tree-sitter parsing
    • Returns both content (joined string) and sections (array of individual file blocks)
    • Each file wrapped in its own <system-reminder> block
    • Character budget handling for large codebases (default 50,000 chars)
  • index.ts (condense): Updated summarizeConversation() to accept foldedFileContextSections?: string[] and push each section as a separate content block in the summary message

  • Task.ts: Integrated smart code folding in condenseContext() - calls generateFoldedFileContext() and passes sections to summarizeConversation()

  • Tests: 12 comprehensive tests covering:

    • Empty file list handling
    • Single/multiple file generation
    • Separate system-reminder blocks per file
    • Character budget limits
    • Error handling for unsupported files

Output Format

Each file gets its own content block in the summary message:

// Summary message content array:
[
  { type: "text", text: "## Conversation Summary\n..." },
  { type: "text", text: "<system-reminder>\n## File Context: src/api.ts\n...\n</system-reminder>" },
  { type: "text", text: "<system-reminder>\n## File Context: src/models.ts\n...\n</system-reminder>" },
]

At context condensation time, use tree-sitter to generate folded code
signatures (function definitions, class declarations) for files read
during the conversation. Each file is included as its own <system-reminder>
block in the condensed summary, preserving structural awareness without
consuming excessive tokens.

- Add getFilesReadByRoo() method to FileContextTracker
- Create generateFoldedFileContext() using tree-sitter parsing
- Update summarizeConversation() to accept array of file sections
- Each file gets its own content block in the summary message
- Add comprehensive test coverage (12 tests)
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. Enhancement New feature or request labels Jan 24, 2026
@roomote
Copy link
Contributor

roomote bot commented Jan 24, 2026

Oroocle Clock   See task on Roo Cloud

Re-review complete. The previously flagged tree-sitter error-string embedding issue is resolved in the latest commit.

  • Avoid embedding tree-sitter error strings into folded file context (treat missing/denied files as skipped instead).
Previous reviews

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


try {
// Get the folded definitions using tree-sitter
const definitions = await parseSourceCodeDefinitionsForFile(absolutePath, rooIgnoreController)
Copy link
Contributor

Choose a reason for hiding this comment

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

parseSourceCodeDefinitionsForFile() can return human-readable error strings (for example when a file is missing). Since those are truthy, generateFoldedFileContext() will embed the error text into the condensed context as if it were a code signature; it seems better to treat these as a skip (undefined/null) so condensation does not preserve error messages.

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

@roomote
Copy link
Contributor

roomote bot commented Jan 24, 2026

Fixaroo Clock   See task on Roo Cloud

Fixed the reported issue. Tree-sitter error strings are now skipped instead of embedded in folded file context. All local checks passed.

View commit | Revert commit

- Add isTreeSitterErrorString helper to detect error messages
- Skip files that return error strings instead of embedding them
- Add test for error string handling
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:XL This PR changes 500-999 lines, ignoring generated files.

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

3 participants