Skip to content

close_agent is missing from the VS Code multi-agent tool schema #36211

Open

Description

@gcalpay

What version of the IDE extension are you using?

26.721.41059

What subscription do you have?

ChatGPT Plus

Which IDE are you using?

Visual Studio Code 1.131.0 using Remote - WSL

What platform is your computer?

Microsoft Windows NT 10.0.19045.0 x64

What issue are you seeing?

In new Codex chats opened through the VS Code extension, close_agent is missing from the callable collaboration-tool schema even though multi_agent is enabled.

The affected sessions expose:

  • spawn_agent
  • followup_task
  • send_message
  • interrupt_agent
  • list_agents
  • wait_agent

They do not expose close_agent.

This is partial tool exposure: multi-agent support is available, but the operation needed to close a completed subagent is missing. interrupt_agent is not a replacement because it only interrupts the agent's current turn and explicitly leaves the agent available.

The issue persists after updating the extension, completely restarting VS Code, and creating multiple brand-new chats.

What steps can reproduce the bug?

  1. Enable multi-agent support in ~/.codex/config.toml:

    [features]
    multi_agent = true
    
  2. Restart VS Code and open a Git repository through Remote - WSL.

  3. Open a new Codex chat and send this exact request:

    Use a subagent to list the repository's top-level files. Wait for the subagent to finish, close it using close_agent, and report the lifecycle operations you performed.
    
  4. Observe that the session can access spawn_agent and wait_agent, but cannot perform the requested cleanup because close_agent is absent from its callable tool schema. The available cleanup-adjacent operation is interrupt_agent, which interrupts the current turn but leaves the agent available.

What is the expected behavior?

With stable multi_agent enabled, every new VS Code Codex chat should receive the complete documented collaboration lifecycle, including a callable close_agent operation.

A workflow should be able to:

  1. spawn a child agent;
  2. wait for its result;
  3. explicitly close the child;
  4. verify that the child reached a terminal state and its slot was reclaimed.

If close_agent has intentionally been replaced, the extension should expose and document an equivalent finalization operation. interrupt_agent should not be treated as equivalent to lifecycle closure.

Additional information

The Codex runtime bundled with the affected extension reports:

codex-cli 0.146.0-alpha.3.1

Relevant configuration:

[features]
multi_agent = true

The VS Code workspace is opened through Remote - WSL with Ubuntu 24.04.4 LTS. The Windows host platform is recorded in the dedicated platform field above.

Activity

  1. added
    extension
    on Jul 30, 2026
  2. added
    bug
    subagent
    windows-os
    on Jul 30, 2026
  3. KNaiFen commented on Aug 4, 2026

    @KNaiFen

    codexcli 0.146 macos
    no vscode, same bug

  4. wuyak commented on Aug 9, 2026

    @wuyak

    I can reproduce the same missing tool surface outside VS Code.

    Environment:

    • Codex Desktop 26.803.41515 (build 6321)
    • bundled CLI codex-cli 0.146.0
    • macOS

    The collaboration tools exposed in the session are:

    • spawn_agent
    • followup_task
    • send_message
    • interrupt_agent
    • list_agents
    • wait_agent

    There is no close_agent. interrupt_agent only ends the current turn and leaves the child thread addressable, so it is not an equivalent close/retire/reclaim operation.

    This suggests the gap is not VS Code-specific. It would help to either expose close_agent consistently or document the supported idempotent replacement, with outcomes such as closed, already_closed, still_active, and not_found.

  5. mwcmaniac45 commented on Aug 11, 2026

    @mwcmaniac45

    Also reproduced in the Codex-native Code-mode collaboration surface on macOS with Codex CLI 0.147.0. The parent can spawn, list, wait for, and interrupt children, but has no close_agent or documented equivalent.

    Please expose the actual negotiated lifecycle capability to the parent surface: if native close is supported, provide an idempotent close operation that confirms the parent-child edge is closed; if it is unsupported, return an explicit unsupported/terminal-unclosed state so callers can halt safely rather than silently retaining concurrency. A wait timeout must not authorize closure of a nonterminal child, and archive should remain separate from lifecycle closure.

    This is consistent with the tagged V1 source defining close_agent as the operation that releases completed-agent concurrency, while the observed V2-style surface provides no corresponding safe operation.

  6. Geektrovert commented on Aug 12, 2026

    @Geektrovert

    Adding some context from our side, because this has happened enough times that we finally sat down and traced it properly.

    During a long multi-agent session in ChatGPT Desktop on macOS, the system ran out of application memory. The Force Quit window showed ChatGPT using 25.86 GB.

    macOS Force Quit dialog showing ChatGPT using 25.86 GB

    This screenshot shows the failure we hit, but it does not prove what caused all 25.86 GB of memory use.

    This was not a one-off for us. We have lost work or had to stop and clean up the machine several times after long multi-agent sessions. I cannot say that every incident had exactly the same cause, but the pattern has been consistent enough—and disruptive enough—that we wanted to understand what was actually being left behind.

    During the cleanup that led to this investigation, we recovered roughly 3.5 GB of disk space from agent-related processes and build state. That was a separate storage problem, but it prompted us to look more closely at the lifecycle of completed subagents.

    One part of the problem was straightforward to reproduce:

    • after two V2 subagents completed, the root and both child MCP processes were still running and using roughly 215 MiB of combined MCP RSS;
    • calling interrupt_agent did not reclaim them, which is consistent with what that operation promises to do;
    • explicitly unloading the completed children left only the root MCP process, at roughly 71.7 MiB;
    • across three runs, tracked RSS dropped by about 140–143 MiB each time.

    I do not think this explains the whole 25.86 GB incident. The root process continued to grow during the probe, so there is clearly more going on. What it does show is that completed subagents can retain a meaningful amount of memory and their MCP processes indefinitely, and that this portion can be reclaimed reliably.

    I put together a local prototype of a resumable release_agent operation. It only releases completed or interrupted agents that have no active work or pending messages. It shuts down the resident session and MCP processes but keeps the agent’s identity and history, so a later followup_task can reload the same agent instead of creating a new one.

    The current prototype is available here:

    https://github.com/Geektrovert/codex/tree/fix/subagent-session-release

    It is rebased onto the current main as of commit 6b18f03bc0311ddd6069cdefb79251cdafcdc1a3. The rebased tree compiles, and its formatting and diff checks pass. I could not complete the focused test run because the cold Cargo build filled the remaining disk space. I cleared only the generated build cache afterward.

    I also found the earlier work around automatic idle-thread shutdown and race-safe teardown, including #31304, as well as the more recent lazy MCP startup work in #38217. The former was closed without merging, and the latter reduces startup cost but does not unload completed agents, so I am not sure which lifecycle direction the team currently prefers.

    Before taking the prototype further, I would really appreciate a steer from the maintainers: does an explicit, resumable release_agent sound like the right direction, or would you rather solve this through automatic idle cleanup or by permanently closing the parent-child relationship?

    There are still two concurrency edge cases I want to tighten up, and I need to complete the focused tests once there is enough build space. If this approach fits what the team has in mind, I would be happy to finish that work and open a PR if you would like me to.

  7. CooperGarth commented on Sep 8, 2026

    @CooperGarth

    Confirmed on Windows with both the standalone CLI and the executable bundled with Codex Desktop reporting codex-cli 0.153.4. This is not limited to VS Code or macOS.

    Clean CLI reproduction

    A fresh ephemeral CLI invocation, ignoring user configuration, still exposes only:

    collaboration.spawn_agent
    collaboration.followup_task
    collaboration.interrupt_agent
    collaboration.list_agents
    collaboration.send_message
    collaboration.wait_agent
    

    There is no close_agent or documented genuine equivalent in the exposed schema. interrupt_agent explicitly leaves the agent available for follow-up, and the wait/spawn schemas do not document automatic closure or slot release.

    PowerShell reproduction, run in an empty disposable directory:

    $arguments = @(
      'exec', '--ignore-user-config', '--ephemeral', '--skip-git-repo-check',
      '--sandbox', 'read-only', '-m', 'gpt-6-astra',
      '-c', 'model_reasoning_effort="medium"',
      '-c', 'approval_policy="never"',
      '-c', 'agents.enabled=true',
      '--json', '--color', 'never',
      'Inspect only your currently exposed tool schemas. Return exact callable agent lifecycle names, whether close_agent or a documented genuine closure equivalent is exposed, and any schema-described completion/slot-release guarantee. Do not invoke tools, spawn children, read files, browse, or modify configuration. Do not infer capabilities from this prompt or assume interrupt/archival equals closure.'
    )
    codex @arguments

    Observed on 2026-09-08: exit 0, approximately 15 seconds, with the six tools above and an explicit report that no closure equivalent or slot-release guarantee is exposed. The diagnostic did not invoke any model-generated tools or create subagents. It still discovers skills despite --ignore-user-config, so this is user-config isolation, not a claim of a completely bare installation.

    Separate real-run evidence

    In an existing Desktop task, an explicit parallel-work request successfully created six subagents. Native history records a completed activity for each. A later read-only query of that exact parent's thread_spawn_edges shows all six corresponding edges still open; older edges for the same parent include closed, so the states are distinguishable.

    During that run the parent reported an agent-thread-limit failure when attempting another scanner, and reused an existing preparation agent instead. It explicitly stated that close_agent was unavailable and did not claim the completed children were closed. This establishes successful spawning plus unavailable cleanup; I am not claiming that the database edge status alone proves the precise cause of the concurrency-limit failure or any memory leak.

    The same missing-closure surface was explicitly reported by eight worker tasks. No database/session state was edited, no agents were interrupted to simulate closure, and no undocumented archive/unsubscribe workaround was attempted.

    Requested clarification/fix

    Please expose a supported, idempotent close/release operation consistently, or document the intended equivalent and its parent-child edge/concurrency-slot semantics. A completed turn and an interrupt are not currently documented as substitutes. If this is a negotiated tool-provider capability rather than a local CLI defect, please identify the supported remediation or fixed runtime version.

    This report intentionally omits private task contents, source data, local paths, credentials, and parent/child identifiers.

  8. benjaminstelzer commented on Sep 9, 2026

    @benjaminstelzer

    The subagent documentation says that Codex can steer, stop, or close running/completed subagent threads. However, close_agent is not available in Codex’s tool list. As a result, spawned agents cannot be individually closed, and the subagent limit can be exhausted permanently within a session.

    Please either expose a supported agent-lifecycle tool such as close_agent, or update the documentation to accurately describe the current limitation.

  9. shevakuilin commented on Sep 18, 2026

    @shevakuilin
    Confirming that this issue is still reproducible in the current Codex Desktop runtime on macOS, specifically with `gpt-5.6-sol`.
    
    ## Environment
    
    - Surface: Codex local task in the ChatGPT/Codex Desktop app
    - Application bundle: `/Applications/ChatGPT.app`
    - Bundle identifier: `com.openai.codex`
    - Desktop app version: `26.915.31029`
    - Desktop app build: `9771`
    - Codex CLI/runtime: `codex-cli 0.155.0-alpha.9`
    - Parent model: `gpt-5.6-sol`
    - OS: macOS 26.4, build `25E246`
    - Architecture: Apple Silicon / `arm64`
    
    The problem remained after updating Codex and completely restarting the application.
    
    ## Current Tool Surface
    
    In a fresh `gpt-5.6-sol` parent session, the callable collaboration tools are:
    
    - `collaboration.spawn_agent`
    - `collaboration.followup_task`
    - `collaboration.send_message`
    - `collaboration.wait_agent`
    - `collaboration.list_agents`
    - `collaboration.interrupt_agent`
    
    The session does not expose:
    
    - `close_agent`
    - `terminate_agent`
    - `release_agent`
    - `destroy_agent`
    - or another documented operation with equivalent lifecycle semantics
    
    `interrupt_agent` is not an equivalent replacement. It only interrupts the current turn and explicitly leaves the agent available for later messages or `followup_task`.
    
    ## Model-Selected Runtime Difference
    
    The current model catalog reports:
    
    ```text
    gpt-5.5       multi_agent_version: null
    gpt-5.6-luna  multi_agent_version: v1
    gpt-5.6-sol   multi_agent_version: v2
    gpt-5.6-terra multi_agent_version: v2

    This is consistent with the observed behavior. The GPT-5.5 workflow used the older lifecycle surface containing multi_agent_v1.close_agent, while GPT-5.6 Sol uses the V2-style collaboration surface without a close operation.

    This also suggests that the effective tool protocol is selected through model/runtime metadata rather than only through the locally reported feature-flag state.

    Reproduction in a Real Multi-Agent Workflow

    I use Codex as the parent orchestrator for a structured client-development workflow. Each role invocation is expected to run as an independent subagent so that implementation, architecture review, and code review do not share hidden context.

    The reproduction was:

    1. Start a Codex Desktop task using gpt-5.6-sol as the parent.
    2. Spawn an independent subagent for a bounded role task.
    3. Wait for the subagent to complete.
    4. Attempt to finalize and close the completed subagent.
    5. Observe that no close or release operation is available.
    6. Later dispatch another logically independent task for the same role.
    7. Observe that Codex uses followup_task to wake the previously completed agent instead of spawning a fresh isolated instance.
    8. The old conversation context remains available to the reused agent.

    This is not only a missing cleanup command or a stale UI indicator. The completed agent is actually addressable and reusable.

    Observed Invocation Data

    In one GPT-5.5 parent workflow on the same machine:

    spawn_agent: 31
    close_agent: 30
    followup_task: 0
    

    Its tool namespace included:

    multi_agent_v1.spawn_agent
    multi_agent_v1.wait_agent
    multi_agent_v1.send_input
    multi_agent_v1.close_agent
    

    In a comparable GPT-5.6-sol parent workflow:

    spawn_agent: 8
    close_agent: 0
    followup_task: 52
    send_message: 43
    wait_agent: 393
    

    Repeated reuse included:

    client_architect: followup_task invoked 22 times
    ios_engineer: followup_task invoked 17 times
    senior_client_engineer: followup_task invoked 6 times
    

    The workflow transcript explicitly described waking already completed agents through followup_task.

    Practical Impact

    Reusing completed agents causes context from earlier tasks to carry into later independent tasks.

    This affects:

    • isolation between implementation and review roles;
    • reviewer independence;
    • correctness of architecture and code-review conclusions;
    • task-specific instruction boundaries;
    • concurrency-slot accounting;
    • auditability of whether an agent was actually released;
    • context growth and eventual context degradation.

    For example, an agent that previously implemented code may later be reused as a reviewer. Its retained implementation context can influence the supposedly independent review.

    An external orchestrator also cannot safely record the agent as released. Writing a local release receipt does not prove that the native Codex agent was closed, especially when the same agent remains callable through followup_task.

    Post-Update Verification

    After updating to Desktop 26.915.31029 and CLI 0.155.0-alpha.9, I inspected the exact tool schema exposed to a fresh gpt-5.6-sol session.

    The close operation is still absent.

    I did not spawn another disposable probe after the update because the schema already showed that there would be no supported way to close it afterward. The actual reuse behavior was reproduced before the update, while the missing lifecycle capability has been reconfirmed after the update.

    Expected Behavior

    Codex should provide one of the following:

    1. An explicit, idempotent close_agent or release_agent operation in the collaboration tool surface; or
    2. Automatic finalization of completed subagents with a verifiable closed status and slot-release event.

    After finalization:

    • the agent should no longer be callable through followup_task;
    • its old context should not be reused for a new independent task;
    • its concurrency slot should be released;
    • the parent should be able to verify the terminal lifecycle state;
    • a new independent invocation should receive a new native agent ID.

    If resumable completed agents are intentional, Codex still needs a separate permanent close/release operation for workflows that require strict context isolation.

    Documentation Conflict

    The current Codex documentation says:

    ChatGPT or Codex handles orchestration across agents, including spawning new subagents, routing follow-up instructions, waiting for results, and closing agent threads.

    It also says users can ask Codex to:

    close completed subagent threads.

    Documentation:
    https://learn.chatgpt.com/codex/agent-configuration/subagents#orchestration-and-thread-controls

    The current GPT-5.6-sol collaboration schema does not provide the documented close capability.

    Could the Codex team please clarify:

    1. Is the absence of close/release in MultiAgent V2 intentional?
    2. If so, what is the supported equivalent?
    3. Are completed V2 agents expected to remain reusable indefinitely?
    4. How should a parent request permanent context isolation and slot release?
    5. Can an explicit close/release operation or a verifiable automatic finalization event be added?

    I can provide sanitized session excerpts and tool-call records privately if needed. Full rollout files are omitted because they contain private repository context.

  10. aphyllo commented on Oct 1, 2026

    @aphyllo

    Confirming the missing close/release capability in a current Windows Codex Desktop session (2026-10-01).

    • Surface: Codex Desktop (Microsoft Store package OpenAI.Codex_26.928.1915.0_x64)
    • OS: Windows NT 10.0.26200.0
    • Callable collaboration tools: spawn_agent, followup_task, send_message, wait_agent, list_agents, and interrupt_agent
    • Not exposed: close_agent or a documented equivalent

    This is a schema-level observation in the current session; I did not spawn a disposable agent or measure concurrency-slot or resource retention. interrupt_agent is not an equivalent because its schema says the child remains available for messages and follow-up tasks.

    The current subagent documentation still says users can ask Codex to close completed subagent threads. Please expose a supported close/release operation or clarify the intended lifecycle semantics and update the documentation. This appears to affect Desktop as well as the VS Code case in the original report.

  11. aphyllo commented on Oct 1, 2026

    @aphyllo

    I am also encountering this with the Codex VS Code extension on Windows, and the missing close/release operation is blocking longer multi-agent workflows.

    Environment checked locally: VS Code 1.140.0 (x64), openai.chatgpt extension 26.928.31416, Windows 10.0.26200, codex-cli 0.159.2, and [features] multi_agent = true with [agents] max_threads = 10. My current Codex collaboration tool surface exposes spawn_agent, followup_task, send_message, wait_agent, list_agents, and interrupt_agent, but no close_agent. That tool-schema observation is from the current Codex session, not an independently captured VS Code extension trace.

    I have repeatedly hit the subagent limit after tasks completed while their threads remained open. That limit behavior is my user-observed symptom, not a measured slot-reclamation trace. Reusing those threads is not suitable for independent fresh-context reviews. Please prioritize a supported way to close/release completed subagents and verify that their slots are reclaimed, or document the intended replacement workflow.

  12. benjaminstelzer commented on Oct 9, 2026

    @benjaminstelzer

    Same here. My workflow relies on automatically spawning agents for coding and code reviews.

    I increased the agent limit in config.toml as a workaround, but eventually Codex freezes completely, stops responding, and requires a restart.

    I don’t understand why close_agent wasn’t implemented, especially since it was included in the original documentation. Unfortunately, if this feature never arrives, that would be a reason for me to look for an alternative. I’d be very disappointed, because I find Codex’s user experience almost ideal, particularly compared to Claude Code.

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

    bugextensionsubagentwindows-os

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions