Codex fails bounded recovery after a post-tool stream disconnect

Open 💬 1 comment Opened Jun 17, 2026 by trackoor

Codex fails bounded recovery after a post-tool stream disconnect

What version of Codex CLI is running?

@openai/codex 0.140.0

What subscription do you have?

N/A. The reproduction uses a local OpenAI-compatible mock provider and a fake API key.

Which model were you using?

gpt-4 in the local mock-provider replay.

What platform is your computer?

Linux x86_64 in Docker (node:24-bookworm-based target image).

What terminal emulator and version are you using?

Non-interactive Docker/CI shell.

Codex doctor report

Not available in this minimal Docker reproduction.

What issue are you seeing?

Severity / performance impact: High. A provider stream that disconnects during a tool-use turn can force retry/error behavior after tool execution rather than a bounded recovery path.

What steps can reproduce the bug?

Prerequisites: Docker, Python 3, and the GitHub CLI (gh) for the clone command below. The linked reproducer is self-contained and uses only Python standard-library modules plus Docker. It builds the affected CLI version from the public package registry, starts a local mock provider, and runs the CLI in an isolated workspace. The Docker run is limited to 2 CPUs and 4 GiB RAM by default.

Complete self-contained reproducer: https://gist.github.com/N0zoM1z0/59777f34ade2d993e6d2b999f4bc694d

The Gist contains codex-post-tool-transient-disconnect.reproduce.py. Download and run:

gh gist clone 59777f34ade2d993e6d2b999f4bc694d codex-post-tool-transient-disconnect-reproducer
cd codex-post-tool-transient-disconnect-reproducer
python3 codex-post-tool-transient-disconnect.reproduce.py

To reuse an already-built local image:

python3 codex-post-tool-transient-disconnect.reproduce.py --skip-build

Expected successful reproduction output includes:

REPRODUCED

Observed evidence

The mock provider closes the stream mid tool-use event. The script verifies that a mid-stream close occurred and that the CLI exits nonzero or times out after retry/error handling.

What is the expected behavior?

Codex should recover cleanly or fail once with a clear error without duplicating committed tool state.

Additional information

Public-upstream status: This reproduces against stock public @openai/codex@0.140.0 built from npm.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗