Skip to content

fix(write): only include written-file diagnostics in tool output#18894

Open
Haohao-end wants to merge 1 commit intoanomalyco:devfrom
Haohao-end:fix/17578-write-tool-sse-timeout
Open

fix(write): only include written-file diagnostics in tool output#18894
Haohao-end wants to merge 1 commit intoanomalyco:devfrom
Haohao-end:fix/17578-write-tool-sse-timeout

Conversation

@Haohao-end
Copy link
Copy Markdown

@Haohao-end Haohao-end commented Mar 24, 2026

Issue for this PR

Closes #17578

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

This fixes the write tool so it only includes diagnostics for the file that was just written.

Before this change, write would collect project-wide LSP diagnostics and append unrelated errors from other files into the tool output. That makes the returned tool result larger than necessary and can contribute to SSE timeouts in the provider path.

This patch keeps the change local to write:

  • only report diagnostics for the written file
  • stop including diagnostics from unrelated files
  • add a regression test covering that behavior

I chose this approach because it matches the narrower diagnostics behavior already used by edit / apply_patch, while still preserving useful error output for the file the tool actually modified.

How did you verify your code works?

I verified the change by reviewing the affected tool-result path and adding a focused regression test for the write tool output.

The new test covers the case where:

  • the written file has diagnostics
  • another file also has diagnostics

It checks that:

  • diagnostics for the written file are still included
  • diagnostics from unrelated files are not included

I also ran git diff --check to make sure the patch is clean and does not introduce formatting issues.

Screenshots / recordings

N/A

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions bot added the needs:compliance This means the issue will auto-close after 2 hours. label Mar 24, 2026
@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search, I found one potentially related PR:

PR #16424: fix(lsp): filter diagnostics to current project paths only
#16424

Why it might be related: This PR also addresses filtering diagnostics output, similar to PR #18894 which filters diagnostics to only include those from the written file. Both are concerned with reducing unnecessary diagnostic information in tool output, though PR #16424 focuses on project path filtering while #18894 focuses on file-specific filtering in the write tool.

The other results (PRs #6844 and #7015) appear to be older and less directly related to the current diagnostic filtering approach.

@github-actions github-actions bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Mar 24, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Write tool SSE timeout with claude-opus-4.6 via GitHub Copilot when generating long markdown files

1 participant