Uh oh!
There was an error while loading. Please reload this page.
tool: trim persisted LSP diagnostics in edit/write metadata - #44811
tool: trim persisted LSP diagnostics in edit/write metadata#44811Schubox84 wants to merge 1 commit into
Conversation
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
Schubox84
commented
Aug 24, 2026
Ready for review. This is a re-implementation of the earlier closed PR #6671, updated to the current Effect-based LSP service — trims the persisted metadata to the touched file only; the model-facing output is unchanged. |
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window. Feel free to open a new pull request that follows our guidelines. |
What & why
On every
edit/write,lsp.diagnostics()returns the whole workspace map (every file across every LSP client). That full map is persisted verbatim into the tool-resultmetadata, which the session stores and replays/prompts on future turns. For workspace-wide Lua/TS/etc. diagnostics this balloons the session transcript and hastens compaction.This trims the persisted
metadata.diagnosticsdown to only the touched file, while keeping the full map in-memory for the per-calloutputcomputation (unchanged agent behavior).Changes
packages/opencode/src/tool/write.ts— persist{ [normalizedFilepath]: issues }instead of the whole map.packages/opencode/src/tool/edit.ts— same trim (edit already only emits the touched file's diagnostics in output).packages/opencode/test/tool/lsp-diagnostics-metadata.test.ts— regression coverage: a fake LSP service returns a workspace-wide map and the tests assert persisted metadata contains only the touched file.Why it's safe
touchFile+diagnostics(); metadata is persistence/debug only and not used to derive the model-facing output.outputblock (which the agent actually reads) is unchanged — it already separates "this file" vs "other files" and is capped byMAX_PROJECT_DIAGNOSTICS_FILES.Verification
tsgo --noEmitcleanbun test test/tool/lsp-diagnostics-metadata.test.ts— 2 passwrite/editsuites pass (one pre-existing umask-dependent file-permission test fails only under umask 0002, unrelated).