Skip to content

tool: trim persisted LSP diagnostics in edit/write metadata - #44811

Closed
Schubox84 wants to merge 1 commit into
anomalyco:devfrom
Schubox84:fix/trim-persisted-lsp-diagnostics
Closed

tool: trim persisted LSP diagnostics in edit/write metadata#44811
Schubox84 wants to merge 1 commit into
anomalyco:devfrom
Schubox84:fix/trim-persisted-lsp-diagnostics

Conversation

@Schubox84

Copy link
Copy Markdown

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-result metadata, 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 persistedmetadata.diagnostics down to only the touched file, while keeping the full map in-memory for the per-call output computation (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

  • Diagnostics are recomputed per call via touchFile + diagnostics(); metadata is persistence/debug only and not used to derive the model-facing output.
  • The output block (which the agent actually reads) is unchanged — it already separates "this file" vs "other files" and is capped by MAX_PROJECT_DIAGNOSTICS_FILES.
  • Follows the intent of the earlier closed PR tool: trim persisted LSP diagnostics #6671, re-implemented against the current Effect-based LSP service.

Verification

  • tsgo --noEmit clean
  • bun test test/tool/lsp-diagnostics-metadata.test.ts — 2 pass
  • Existing write/edit suites pass (one pre-existing umask-dependent file-permission test fails only under umask 0002, unrelated).

@github-actions

Copy link
Copy Markdown
Contributor

Hey! Your PR title tool: trim persisted LSP diagnostics in edit/write metadata doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@github-actionsgithub-actionsBot added the needs:compliance This means the issue will auto-close after 2 hours. label Aug 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

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

Copy link
Copy Markdown
Author

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.

@github-actions

Copy link
Copy Markdown
Contributor

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.

@github-actionsgithub-actionsBot removed the needs:compliance This means the issue will auto-close after 2 hours. label Aug 25, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@Schubox84