Skip to content

fix(core): unload completed V2 agents after an optional delay - #2

Open
CBEPX wants to merge 1 commit into
codex/base-rust-v0.163.0from
codex/completed-agent-unload-0.163.0
Open

CBEPX wants to merge 1 commit into
codex/base-rust-v0.163.0from
codex/completed-agent-unload-0.163.0

Conversation

@CBEPX

@CBEPX CBEPX commented Oct 16, 2026

Copy link
Copy Markdown
Owner

Completed V2 child runtimes keep MCP and language-server processes until capacity eviction or root shutdown. This patch adds an optional delay to unload idle child runtimes after completion, error, or interruption.

Behavior

  • Add features.multi_agent_v2.completed_agent_unload_delay_secs. An absent setting preserves the previous behavior. Zero requests unload at the first safe opportunity.
  • Support Code Mode ON and OFF. Reuse native eviction and preserve root runtimes, concurrency limits, saved conversation history, queue-only mail, and environment selections.
  • Block unload during active work, durable sleep, trigger mail, background terminals, active code-mode cells, approvals or other pending elicitation, or active descendants. Retry a blocked unload once after five seconds.
  • Protect delivery and interrupt operations during teardown. Follow-up input waits for teardown, then reloads the child from saved history.
  • Allow unload after collaboration reloads an archived child. Read archived history consistently with the reload path and preserve the archive state.

Validation

  • Final CI passed: formatter, ARM64 build, 2,794 core tests, and 44 feature tests.
  • The archive regression first failed during unload after successful archive and reload. The corrected regression passed in final CI.
  • All ten macOS E2E runs passed with Code Mode OFF/ON. Each mode covered absent delay, delay 0, delay 2 with teardown races, and real Serena/Pyright with dashboard on/off.
  • Both modes retained code_mode_host=true. OFF created no host or Code Mode calls. ON exercised real functions.exec, MCP calls, and the host.
  • Every run exited with code 0 and left zero owned MCP, LSP, or Code Mode host processes. A fresh process check found all 285 tracked PIDs absent.
  • Independent Claude Opus 5.5 initial and delta reviews completed with minor comments and no blocking defects.

All ten runs used the ARM64 dev-small binary with SHA-256 36d87746f4c4564fb88cc092f05ef0f6f42d41c45004b0aa37fb7db641a35466.

Source and limits

Head 9c21ce2def332b973a4d2589855294ac62852f65 contains one commit over rust-v0.163.0 base 83086188ae0614bd882818ff1aa23f3194962012. The diff contains 16 source, configuration, test, and documentation files. All source blobs match CI snapshot 4bb031c6a2043631af1adcb665b56c867ddb7ada. Only that snapshot contains the test workflow.

Opt-in remains required. Codex does not restore transient MCP state after reload, including REPL variables, subscriptions, or server-side tasks. Stateful node_repl and browser restoration remain unqualified.

These tests establish runtime cleanup in the tested cases. They do not prove a Pyright heap leak or qualify every working profile. Working installation remains unchanged because the user deferred activation.

Related: #1 and upstream issue. This PR stays inside CBEPX/codex because upstream policy does not accept external code contributions or PRs.

@CBEPX

CBEPX commented Oct 16, 2026 •

Copy link
Copy Markdown
Owner Author

Agent work: stage finished

Client: codex · Session: codex-unload-pr-publish-0163-20261016 · Claim: 246dad59-62f4-4534-a0c2-0027351d905b

Mode: write · Started: 2026-10-16T10:10:05+03:00 · Updated: 2026-10-16T10:13:17+03:00

Stage: Fork PR2 ready for review. Readback verified exact head9c21ce2/base83086188, byte-identical body and source-only diff: one commit16files. CI and10runtime E2E passed. Parent owns final handoff. No upstream PR, merge, installation or configuration changes.

Scope in this repository: .agent-work/pr-publication-0163-20261016

@CBEPX CBEPX added agent:busy Active agent-work claim; ownership is recorded in the coordination registry and removed agent:busy Active agent-work claim; ownership is recorded in the coordination registry labels Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant