Skip to content

bug(gemini): the Gemini child is spawned without a process group, so terminate() resolves to the agent server's own group #4064

Closed

Description

@vybe

Summary

Surfaced independently by the /validate-pr + /cso --diff runs on #4011 and #4012 (merge train 2026-10-27, train PR #4061). Pre-existing since #2433; neither PR uses or widens it, and both were merged on that basis.

docker/base-image/agent_server/services/gemini_runtime.py spawns the Gemini child without start_new_session=True (chat at ~:299, headless at ~:783) and registers it without a pgid (register() at ~:315 / ~:797). Claude (claude_code.py:357) and Codex (codex_runtime.py:1275) both pass the spawn-captured pgid of a start_new_session=True child.

ProcessRegistry.terminate() → _signal_process_tree(pgid=None) → capture_pgid → os.getpgid(child), which for a child that shares the server's session is the agent server's own process group, and utils/subprocess_pgroup.py:100-102 then issues os.killpg(<server group>, SIGINT) with no group-leader check (despite the docstring). A terminate request on a Gemini execution can therefore signal the agent server itself.

#4009 and #4011 deliberately kill the Gemini child by pid rather than by group for exactly this reason (gemini_runtime.py:331-336 on dev after the train), so the per-PR fixes are correct in shape; the gap is the registry's terminate path.

A second residual from the same validation (#4012): the deferred release is keyed by execution id only, so a pid reuse between register and release is not distinguished.

Acceptance

  • Gemini chat and headless children are spawned with start_new_session=True and registered with their spawn-captured pgid, matching the Claude/Codex shape.
  • _signal_process_tree refuses to signal a group that equals the agent server's own (os.getpgrp()), fail-closed, with a test that drives terminate() on an entry registered without a pgid and asserts the server group is never signalled.
  • The AC 3 docstring on ProcessRegistry.unregister (fix(agent-runtime): an abandoned Gemini waiter hands release to its shielded reader (#3408) #4012) stays true for Gemini: "reachable by terminate()" means the child, not the server.
  • test_2433_gemini_registers.py / test_runtime_process_ownership.py updated so the Gemini arm pins the pgid.

Related: #3408 (series #4008–#4012), #2433, #3308, #4047.

Activity

  1. added
    priority-p2
    type-bug
    theme-reliability
    complexity-medium
    on Oct 28, 2026
  2. dolho commented on Oct 28, 2026

    @dolho
    Contributor

    /claim

  3. added
    status-in-progress
    on Oct 28, 2026
  4. github-actions commented on Oct 28, 2026

    @github-actions

    Claimed by @dolho. Label status-in-progress added.

    Next steps:

    1. Create branch: feature/4064-<short-slug>
    2. Implement the feature
    3. Open a PR with Fixes #4064
  5. added
    status-in-dev
    and removed
    status-in-progress
    on Oct 28, 2026
  6. removed
    status-in-dev
    on Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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