Nested exec can orphan a mutating child while outer wait reports complete

Open
#36,287 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
rust
Domain
cli, devtools

Research direction

Trace the lifecycle of functions.exec and its nested tools.exec_command calls, focusing on how nested session_id values and outer cell completion are handled. Reproduce the slow filesystem-mutation case, then add a regression test covering a live child after the outer cell reports completion. Done means an outer completed result cannot coexist with an unreported live child process.

Written by the indexing model from the issue text.

Description

bug tool-calls
Summary

A long-running tools.exec_command invoked inside functions.exec can yield with its own session still running. If the wrapper only emits result.output, the nested session_id is discarded. Waiting on the outer functions.exec cell can then report completion even though the child shell process is still mutating the filesystem.

Observed impact

This happened during a large git switch. The outer cell completed with no output while the Git process continued in the background holding index.lock. A later status check raced the checkout. When the orphaned Git process was stopped, HEAD and the index were unchanged, but the working tree had been only partially transitioned: thousands of tracked deletions/modifications plus hundreds of untracked files. Recovery was possible only because HEAD/index remained intact and the filesystem state was separately preserved.

Reproduction shape
  1. Call functions.exec.
  2. Inside it, await tools.exec_command for a command that runs beyond the nested yield window.
  3. Emit only result.output, omitting result.session_id.
  4. The outer call yields a cell ID; wait on that cell.
  5. Observe the outer cell complete while the nested child process remains alive.
Expected safety behavior

One of the following should hold:

  • functions.exec automatically retains and surfaces nested exec session IDs;
  • the outer cell remains alive until every awaited nested exec finishes;
  • nested long-running exec calls are rejected unless their session handle is explicitly consumed; or
  • child processes are terminated when the outer isolate completes.

For mutating commands, an outer completed result must not coexist with an unreported live child process. A regression test using a slow filesystem mutation would be valuable.

Dominant language
Rust
Stars
125k
Forks
19.5k
Avg merge
1m
Merged PRs (30d)
1k

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from openai/codex

All issues in openai/codex

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.