Skip to content

Conversation

@KJ7LNW
Copy link
Contributor

@KJ7LNW KJ7LNW commented Mar 15, 2025

Context

Implementing environment details compression to reduce token usage while preserving full context. Environment details contain redundant information across messages that can be optimized without losing information.

How to Test

This is not ready for public testing, I am putting it up to prevent duplicate effort.

Implementation

The compression strategy:

  1. Deduplicated into last message:

    • "Current Working Directory Files"
    • "VSCode Visible Files"
    • "VSCode Open Tabs"
    • "Current Mode"
    • and others that I find along the way.
  2. Kept in each message:

    • "Actively Running Terminals" (maintains command output)
    • "Inactive Terminals" (maintains command output)
  3. Special handling - "Current Time":

    • Appears in all messages
      • In the future we might create a flag for time since not all users need time in their context history
    • Prior messages: Convert to UTC UNIX timestamp
    • Last message: Keep human-readable format
  4. Section cleanup:

    • Remove empty VSCode sections entirely
    • Strip redundant "(No visible files)" and "(No open tabs)" markers

Screenshots

n/a

Eric Wheeler and others added 5 commits March 12, 2025 14:09
Implements environment details compression to reduce context window usage while
preserving all information. Compresses <environment_details> sections by accumulating
state in the last message and removing redundant content from prior messages.

Compressed sections, moved to last message:
- Current Working Directory Files
- VSCode Visible Files
- VSCode Open Tabs
- Current Time (converted to UTC UNIX)
- Current Mode

Unmodified sections, retained in existing message order:
- Actively Running Terminals (maintains command output)
- Inactive Terminals (maintains command output)

Signed-off-by: Eric Wheeler <[email protected]>
Adds task resumption message compression to reduce token usage while preserving
all information. Compresses task resumption messages by keeping only the most
recent one and preserving environment details from removed messages.

- Earlier task resumption messages removed
- Environment details preserved from removed messages
- Most recent task resumption message kept

Signed-off-by: Eric Wheeler <[email protected]>
Add getDebugFilenames helper to generate consistent debug filenames that:
- Include test type in the filename for better identification
- Use conv_ prefix to maintain consistency with existing files
- Follow format: conv_[before|after]_compression_[testType]_[timestamp]_[date]--[time].json

This makes it easier to identify which test generated each debug file.

Signed-off-by: Eric Wheeler <[email protected]>
- Update VSCode section handling to exclude empty sections
- Remove '(No visible files)' and '(No open tabs)' placeholders
- Remove VSCode sections that become empty
- Add tests:
  - Verify empty VSCode sections are excluded
  - Test VSCode sections becoming empty
  - Test mixed VSCode section states
  - Verify no empty placeholders are added

Signed-off-by: Eric Wheeler <[email protected]>
@hannesrudolph hannesrudolph moved this from New to PR [Pre Approval Review] in Roo Code Roadmap Mar 17, 2025
@d-oit
Copy link
Contributor

d-oit commented Mar 18, 2025

@KJ7LNW I found your PR after my changes. Did you already include this? On longer runs i have a a list of response temp. files in the env. details.

I would like to create a PR to prevent the temp. files from # VSCode Visible Files
C:\response_aed1fbd1-faf4-4f10-8bca-93bd67fe35da,...

async getEnvironmentDetails(includeFileDetails: boolean = false) {
	let details = ""

	const { maxOpenTabsContext } = (await this.providerRef.deref()?.getState()) ?? {}
	const maxTabs = maxOpenTabsContext ?? 20

	// It could be useful for cline to know if the user went from one or no file to another between messages, so we always include this context
	const visibleFilePaths = vscode.window.visibleTextEditors
		?.map((editor) => editor.document?.uri?.fsPath)
		.filter(Boolean)
		// Filter out temporary response files
		**.filter((path) => !path.includes("response_") && !path.match(/\\response_[a-f0-9-]+\\[0-9]+$/))**
		.map((absolutePath) => path.relative(cwd, absolutePath))

	// Filter paths through rooIgnoreController
	const allowedVisibleFiles = this.rooIgnoreController
		? this.rooIgnoreController.filterPaths(visibleFilePaths)
		: visibleFilePaths.map((p) => p.toPosix()).join("\n")

	if (allowedVisibleFiles) {
		details += "\n\n# VSCode Visible Files"
		details += `\n${allowedVisibleFiles}`
	}

	const openTabPaths = vscode.window.tabGroups.all
		.flatMap((group) => group.tabs)
		.map((tab) => (tab.input as vscode.TabInputText)?.uri?.fsPath)
		.filter(Boolean)
		.map((absolutePath) => path.relative(cwd, absolutePath).toPosix())
		.slice(0, maxTabs)

	// Filter paths through rooIgnoreController
	const allowedOpenTabs = this.rooIgnoreController
		? this.rooIgnoreController.filterPaths(openTabPaths)
		: openTabPaths.map((p) => p.toPosix()).join("\n")

	if (allowedOpenTabs) {
		details += "\n\n# VSCode Open Tabs"
		details += `\n${allowedOpenTabs}`
	}

@KJ7LNW
Copy link
Contributor Author

KJ7LNW commented Mar 18, 2025

@KJ7LNW I found your PR after my changes. Did you already include this? On longer runs i have a a list of response temp. files in the env. details.

I am sorry I am not familiar with your changes, can you elaborate or point me at a PR to read up on?

I would like to create a PR to prevent the temp. files from # VSCode Visible Files C:\response_aed1fbd1-faf4-4f10-8bca-93bd67fe35da,...

I am not familiar with this issue can you post me an entire example of your <environment_details> section so I can understand better?

OTOH, if you are referring to the temp files that this WIP currently creates, eventually I will turn those off, but I need them for troubleshooting.

@d-oit
Copy link
Contributor

d-oit commented Mar 18, 2025

this is what I am referring to:

Section cleanup:

Remove empty VSCode sections entirely
Strip redundant "(No visible files)" and "(No open tabs)" markers

@KJ7LNW
Copy link
Contributor Author

KJ7LNW commented Mar 18, 2025

this is what I am referring to:

Section cleanup:

Remove empty VSCode sections entirely Strip redundant "(No visible files)" and "(No open tabs)" markers

  • got it, so did you already taken care of those elsewhere?
  • do you have a pr number I can reference?

@d-oit
Copy link
Contributor

d-oit commented Mar 19, 2025

this is what I am referring to:

Section cleanup:

Remove empty VSCode sections entirely Strip redundant "(No visible files)" and "(No open tabs)" markers

  • got it, so did you already taken care of those elsewhere?
  • do you have a pr number I can reference?

This is the complete change set: d-oit@69b50f3
Didn't PR after i found your PR. Could do my own for this if it is easier for you.

background info vs. code temp files:
https://www.perplexity.ai/search/how-to-prevent-vscode-c-respon-c99T1ZGoTfOdodopEL0hUQ

@KJ7LNW
Copy link
Contributor Author

KJ7LNW commented Mar 19, 2025

This is the complete change set: d-oit@69b50f3 Didn't PR after i found your PR. Could do my own for this if it is easier for you.

background info vs. code temp files: https://www.perplexity.ai/search/how-to-prevent-vscode-c-respon-c99T1ZGoTfOdodopEL0hUQ

I think I understand you now. I looked at your patch and it appears to hard-code filter anything named response_*. This certainly solves your specific problem, but unless Roo Code is the one generating these files, the commit it is not generic enough to address the problem for everyone that uses Roo.

Questions:

  1. What generates those files?
  2. What is their content, is it specific to your project, or are they somehow related to AI responses via Roo?
  3. Have you tried creating a .rooignore for your purpose, or modifying visibleFilePaths to filter based on .rooignore

@d-oit
Copy link
Contributor

d-oit commented Mar 19, 2025

This is the complete change set: d-oit@69b50f3 Didn't PR after i found your PR. Could do my own for this if it is easier for you.
background info vs. code temp files: https://www.perplexity.ai/search/how-to-prevent-vscode-c-respon-c99T1ZGoTfOdodopEL0hUQ

I think I understand you now. I looked at your patch and it appears to hard-code filter anything named response_*. This certainly solves your specific problem, but unless Roo Code is the one generating these files, the commit it is not generic enough to address the problem for everyone that uses Roo.

Questions:

  1. What generates those files?
  2. What is their content, is it specific to your project, or are they somehow related to AI responses via Roo?
  3. Have you tried creating a .rooignore for your purpose, or modifying visibleFilePaths to filter based on .rooignore

You are right ignore these.

@KJ7LNW KJ7LNW mentioned this pull request May 8, 2025
@hannesrudolph hannesrudolph moved this from PR [Pre Approval Review] to PR [Draft/WIP] in Roo Code Roadmap May 10, 2025
@hannesrudolph hannesrudolph moved this from New to PR [Draft/WIP] in Roo Code Roadmap May 20, 2025
@hannesrudolph hannesrudolph moved this from PR [Draft / In Progress] to TEMP in Roo Code Roadmap May 26, 2025
@daniel-lxs
Copy link
Member

Hey @KJ7LNW,
Thank you for your contribution, We noticed this PR is stale and will be closed. If you plan to revisit this, please create an issue first as required by our issue-first approach before opening a new PR.

@daniel-lxs daniel-lxs closed this May 26, 2025
@github-project-automation github-project-automation bot moved this from TEMP to Done in Roo Code Roadmap May 26, 2025
@github-project-automation github-project-automation bot moved this from PR [Draft/WIP] to Done in Roo Code Roadmap May 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants