Skip to content

Add opt-in lazy language-server initialization #1771

Description

@TyceHerrman

Problem

Codex may create multiple stdio MCP runtimes for one project. With Serena 1.6.1, four Serena processes started four rust-analyzer instances within 23 seconds; three reached 9.25–9.76 GB before the machine crashed.

Codex owns runtime reuse and cleanup, as discussed in #693 and openai/codex#30408. This request is for an optional Serena-side guard.

PR #227 made language-server initialization asynchronous but still starts it during project activation. True first-use initialization was previously prototyped but not merged:

Requested solution

Add an opt-in lazy mode:

  • Do not start language servers during project activation.
  • Initialize once through the existing serialized queue when the first dependent tool runs.
  • Let non-LSP tools run without triggering initialization.
  • Handle concurrent first calls, failures, restarts, project switching, and shutdown.
  • Keep eager initialization as the default.

The tradeoff is latency on the first dependent call.

Metadata

Metadata

Assignees

No one assigned

    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