Skip to content

System environment prompt causes cache invalidation #5224

@heimoshuiyu

Description

@heimoshuiyu

Question

In https://github.com/sst/opencode/blob/v1.0.134/packages/opencode/src/session/system.ts#L49

I've noticed that the environment() function in system.ts fetches 200 files from the current git working directory. This means that when files are added or removed in the directory, this portion of the system environment prompt is likely to change, resulting in context invalidation and increased API costs.

Here are some optimization ideas I have:

Optional solutions:

  1. Completely remove the section of the prompt. In my testing, most models are smart enough to use the list tool to view directory files.

  2. Retrieve the file list from git committed files, which ensures this part of the prompt remains unchanged until the user commits to the git repository.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions