Skip to content

[FEATURE]: Release a project's cached services when its last client exits #53068

Open

Description

@angeloper86
  • I have verified this feature I'm about to request hasn't been suggested before.

What I'd like

Quitting a client (TUI or desktop) should release the services cached for the project it had open. Today local MCP servers are cached per directory without eviction tied to use (traced in #52946), so /exit leaves them running until some other mechanism kicks in. I'd like client presence to be the trigger: a project's cached services live while at least one client has it open, or a turn is running; when the last client exits they're released; when no client remains, all loaded locations are swept. Everything boots lazily again on next use.

Why client presence as the boundary

#51249 documents the unbounded cache and notes the fix needs a boundary choice — idle TTL vs client-driven dispose. This puts the client-driven option forward: predictable ("quit releases"), bounded by what is actually open rather than by session history or a fixed capacity, and it complements the LRU cap proposed in #52946 (which stops unbounded growth but keeps recently used directories warm). It also serves the disconnect/reconnect accumulation reported in #46035.

Prior art

I've been running this as a small TUI plugin for a few days — opencode-release-on-quit (https://github.com/angeloper86/opencode-release-on-quit, on npm). On quit it waits until the client process is really gone, then asks the service to evict that location; when no other client is running it sweeps all loaded locations. It never touches a location with a turn executing. It works, but from the outside it needs a detached helper and ps-based client detection (macOS/Linux only), and it depends on the experimental debug.location.evict endpoint, which has its own issues (#51198). A core implementation would be cross-platform and need none of that.

Happy to help with a design or PR if this fits where the service lifecycle is going.

Activity

  1. github-actions commented on Oct 4, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  2. opencodejr commented on Oct 27, 2026

    @opencodejr

    Thanks for the detailed proposal, @angeloper86, and for publishing opencode-release-on-quit as prior art.

    To restate it: a project's cached services (local MCP servers etc.) would stay loaded while at least one client has the project open or a turn is running. They would be released when the last client exits, and all loaded locations would be swept when no clients remain. Everything boots lazily again on next use.

    I've tagged this as a feature request for the maintainers to consider alongside the other work on the service lifecycle. For reference, dev already has a time-based experimental.location_idle_timeout, but nothing tied to client presence yet. Related issues:

    As you noted, doing this cleanly from a plugin would need core support: a server-side signal for client attach/detach per location, and a stable (non-debug) way to release a location that respects running turns. Your offer to help with a design is noted for the maintainers.

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

Metadata

Metadata

Assignees

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