Skip to content

feat(lsp): add restartServer operation#6233

Open
JackNorris wants to merge 1 commit intoanomalyco:devfrom
JackNorris:feature/lsp-restart-server
Open

feat(lsp): add restartServer operation#6233
JackNorris wants to merge 1 commit intoanomalyco:devfrom
JackNorris:feature/lsp-restart-server

Conversation

@JackNorris
Copy link
Contributor

@JackNorris JackNorris commented Dec 27, 2025

Summary

Add restartServer operation to the LSP tool

Problem

When installing new packages (e.g., adding pyav to pyproject.toml), pyright doesn't pick up the changes automatically. It continues throwing diagnostic errors on every edit until opencode is restarted. Also affects rust-analyzer.

Solution

Allow opencode to restart the LSP server by file extension without requiring a full opencode restart.

Fixes #5899
Related: #2156

@rekram1-node
Copy link
Collaborator

Is this something we should do automatically? We do have a file watcher...

@rekram1-node
Copy link
Collaborator

Tho I will say I do like the ability of the user to restart lsp servers too

@JackNorris
Copy link
Contributor Author

Automatic restart would be a nice QoL feature I for sure. I didn't want to make the changes too aggressive though since the LSP tool is still tagged experimental so I thought it best to keep it simple.

I know pyright would benefit from automatic restarts when adding dependencies to a project. Rust might be more challenging as I think it goes out of sync over time but I've less experience with this one.

Happy to to take a look though unless it's something you want to handle.

@rekram1-node
Copy link
Collaborator

Gotcha, hm do u think the best spot for this is for the agent? Ig it makes some sense...

There are the 3 cases:

  • automatic (file watcher << if necessary, this may just be misconfigured lsp tbh)
  • user invoked (maybe they wanna force a restart, i do this in my ide daily)
  • agent invoked

Trying to think which one is highest priority, because the agent invoked one seems like it could lead to the worst outcomes if the agent confuses itself but ur changes prolly wouldn't cause that

@rekram1-node
Copy link
Collaborator

Have you been using the experimental lsp tool? (or ig has ur agent?)

@rekram1-node
Copy link
Collaborator

Screenshot 2025-12-26 at 10 32 37 PM

Lol so a more intelligent model like opus here would probably leverage ur option here actually.

@rekram1-node
Copy link
Collaborator

I literally just ran into this so, interesting

@JackNorris
Copy link
Contributor Author

I've been using it a fair bit yeah, really nice addition!

In the case of pyright it's a long standing issue that the LSP needs restarting on environment changes, there's no config options available to my knowledge. They (and pylance) have several open issues regarding it. Perhaps that needs addressing directly with them and we leave the ability open for the user/agent to trigger a restart?

I'm trying to think what the dangers would be if the agent did get confused.

Opus and Sonnet both seem leverage the restart feature well for what it's worth.

@JackNorris JackNorris force-pushed the feature/lsp-restart-server branch 2 times, most recently from 3c02d0f to 62088e8 Compare January 7, 2026 22:33
@JackNorris JackNorris force-pushed the feature/lsp-restart-server branch from 62088e8 to ad5b0a7 Compare January 16, 2026 15:50
@github-actions
Copy link
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@ragnsan
Copy link

ragnsan commented Feb 12, 2026

Would love this. Running into a bunch of stale LSP errors on a daily basis. Not sure if it's something we're doing wrong

@JackNorris
Copy link
Contributor Author

It's a common occurence for me too, running my own fork right now but would rather not. Even Claude Code can do this now.

@rekram1-node - Is this something you are interested in adding or not? I can create an issue if needed.

@JackNorris JackNorris force-pushed the feature/lsp-restart-server branch from ad5b0a7 to 94ba405 Compare February 14, 2026 00:49
@einarpersson
Copy link

einarpersson commented Feb 16, 2026

This is a daily occurance for me too, using typescript and svelte. The agent confuses itself all the time. Does edits, sees errors. Has to reassure itself that the errors are because of stale lsp. It even resorts to running external npm run check with shell tool to verify that there are no errors.

@JackNorris
Copy link
Contributor Author

Linked it with an issue. Not sure if anyone is going to actually pick up on this though.
Might be worth adding in an instruction to the system prompt for this if LSP support is enabled but I don't know.

@lljbash
Copy link

lljbash commented Mar 13, 2026

+1 This would be great! I'm using basedpyright and frequently run into stale LSP in two scenarios:

  1. Installing new packages (adding to pyproject.toml)
  2. Adding new files to the project

Looking forward to this being merged. Thanks!

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.

Restart LSP when it's stale

5 participants