GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [FEATURE]: location "close and drain" so a client can know nothing in a directory can still run · Issue #60286 · anomalyco/opencode

[FEATURE]: location "close and drain" so a client can know nothing in a directory can still run #60286

New issue
Copy link
New issue
Copy link
Open
Open
[FEATURE]: location "close and drain" so a client can know nothing in a directory can still run#60286
Copy link

Description

@marcusrbrown
marcusrbrown
opened on Oct 29, 2026
Issue body actions

Feature hasn't been suggested before.

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

Describe the enhancement you want to request

I run opencode serve as a long-lived server for an automation client. Each run hands the agent a directory, and when the run ends the client hands that directory to the next run. Before it does, it has to know that nothing from the finished run can still write there. Today there's no way to get that guarantee from the HTTP API.

Even when every read I can make comes back empty, something from the old run can still start up again:

  • Waking a session after a notice is admitted. Session.synthetic admits the inbox item, looks the session up again, and only then calls execution.wake (core/src/session/session.ts). Nothing bounds the time between those steps.
  • Background shells. A shell drops off GET /api/shell before its output is read, the job settles, and its notice is admitted (core/src/shell.ts, tool/plugin/shell.ts notifyWhenDone). DELETE /api/shell/:id removes it from the listing before the process has exited and before the notice has been produced.
  • Subagent completion. It reads the child's messages and then admits the parent's notice in a separate step (session/subagent-job.ts, session/subagent-completion.ts).
  • Prompt preparation. It runs before the coordinator registers, so GET /api/session/active doesn't show it.

So a client can poll session/active, shell and the inbox for every session in the directory, see nothing, hand the directory off, and then have a woken turn or a late notice start running there afterwards. The best workaround is to require the directory to look quiet for several seconds. That narrows the window but doesn't close it.

I'd like a location-scoped "close and drain" operation, for example POST /api/location/drain?location[directory]=…, that:

  1. stops new prompts, wakes and job starts for the location;
  2. cancels and waits for in-flight work: session executions (including preparation), subagent and shell jobs (process exit, not just leaving the listing), and notification producers;
  3. answers only once nothing in the location can run without a new client request, and reports anything it couldn't stop;
  4. optionally reopens the location afterwards, or leaves it fenced until the next request.

This gives automation clients, and anything else that hands a directory between agents (CI, schedulers, multi-agent orchestrators), one call that says the directory is quiet instead of a timing heuristic. It probably overlaps with how shutdown already tears down a location's shells and executions, but as a per-location operation that doesn't stop the server.

Related: #60107 (interrupting a session doesn't cancel its background shells), #60245, #48826.

Activity

  1. opencodejr commented on Oct 29, 2026

    @opencodejr
    opencodejrBot
    on Oct 29, 2026
    Contributor
    More actions

    Thanks for the detailed write-up, @marcusrbrown!

    To restate the request: you'd like a location-scoped "close and drain" operation, something like POST /api/location/drain?location[directory]=…. It would stop new prompts, wakes and job starts in the location, then cancel and wait for in-flight executions, subagent and shell jobs and notification producers. It would answer only once nothing there can run without a new request, and report anything it couldn't stop. That would let an automation client hand a directory to the next run without relying on a "quiet for N seconds" check.

    I've marked this as a feature request for maintainers to consider. This can't be done as a plugin today, because blocking admission and waiting for in-flight work both need changes in core.

    Related issues:

    • v2: shell: interrupting a session doesn't cancel its background shell jobs #60107: interrupting a session doesn't cancel its background shell jobs (fix proposed in fix(core): cancel a session's background shell jobs on interrupt #60119)
    • core: orphaned background child keeps an admitted completion that nothing drains #60245: an orphaned background child keeps an admitted completion that nothing drains
    • [BUG] V2: subagent with pending background work (shell commands or subagents, background: true) marked completed early — results never collected #48826: a subagent is marked completed before its background work is collected
    • [Bug] Location inactivity eviction SIGTERMs live background shells after 60 minutes #51828: location inactivity eviction SIGTERMs live background shells
    • V2: define restart semantics for foreground and background shells #36348: defining restart semantics for foreground and background shells
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.