Skip to content

Registered subprocess ownership is lost when execution waiters are cancelled #3307

Closed

Description

@alex-furman

Reproduction

On unmodified official dev a72271d9c23a4ec8a2aa273bcc9e15a363135685, cancelling a chat or headless execution coroutine after its subprocess is registered removes that subprocess from ProcessRegistry even while it continues running. Cancelling an asyncio waiter does not stop an already-running executor thread.

  1. Run either execution coroutine with a disposable Python child in place of the model CLI.
  2. Wait for subprocess registration and stdin closure, then cancel the coroutine.
  3. Confirm the child is still alive with poll(), and query the registry.

Expected: the child remains tracked and available to status/termination until its exit is observed; tracking and log subscriptions close after eventual worker completion.
Actual: the child remains alive but is absent from the registry. The same ownership issue applies when the outer timeout abandons its worker.

A second regression exercises terminate() with both waits raising subprocess.TimeoutExpired: after SIGINT and SIGKILL fail to establish exit, it still reports success. Expected: an explicit unconfirmed-termination failure and retained handle.

Environment and evidence

Python 3.13 in an isolated Linux container, official dev revision above. Three initial regression cases fail on stock: cancelled chat, cancelled headless execution, and unconfirmed termination. These tests use ordinary local Python children, no model/provider calls, and stub cgroup sweeping so they own only their test children.

A registry-only change is insufficient: it preserves live handles but has no eventual cleanup when the request waiter has already ended. Both executors need worker-completion cleanup after waiter abandonment while retaining normal result-before-stream-end ordering.

Scope

This report concerns ownership of registered processes and truthful termination results. It does not claim a solution for pre-spawn ownership, capacity enforcement, server restart survival, or complete descendant-process termination.

Related work: #2433, #2435 and #2450 cover timeout/executor and cleanup concerns; the cancellation and eventual-cleanup regressions above are distinct. Existing issue/PR searches found no direct open duplicate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    complexity-mediumpriority-p2theme-reliabilitytype-bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions