[macOS App] Task marked complete while background Codex CLI inference continues and exhausts usage limit
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 12/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Active
- Tech stack
- python
- Domain
- ai-infra-agents, desktop
Research direction
The payload names no file in the Codex Desktop codebase. It cites a user's scripts/maintenance/batch.py and extraction.py, which are outside the project, and a session rollout JSONL. Start by finding where the desktop app marks a turn complete relative to child command processes, and compare it with the related #14731 and #40041. Done would need a maintainer decision on expected lifecycle behavior before any code change.
Written by the indexing model from the issue text.
Description
What version of the Codex App are you using (From “About Codex” dialog)?
ProductVersion: 26.6.2 BuildVersion: 25G83
What subscription do you have?
ChatGPT Plus
What platform is your computer?
Darwin 25.6.0 arm64 arm
What issue are you seeing?
Summary
Codex Desktop on macOS marked an agent turn as completed while a Python batch-processing command launched by that turn was still running.
The background process continued launching independent, authenticated codex exec inference requests for approximately 17 minutes after the main agent turn emitted task_complete.
I did not send any additional instructions during this period.
The continued inference was not clearly visible in the completed desktop conversation. The background process eventually encountered a usage_limit error, and my ChatGPT Plus five-hour Codex allowance was exhausted.
Confirmed Timeline
Date: October 9, 2026 (UTC+8)
| Time | Event |
|---|---|
| 09:37:41.279 | Codex Desktop launched a Python batch command through unified exec |
| 09:37:48 | Main agent turn emitted task_complete |
| 09:37–09:54 | Background batch continued running authenticated Codex CLI inference |
| 09:54:01 | A child inference request recorded error_category: usage_limit |
| 09:54:53.500 | Background CommandExecution completed with exit code 0 |
The background process remained active for approximately 17 additional minutes after the main agent turn was marked complete.
Verified Usage Evidence
I identified 15 successful inference receipts completed after the main task was marked finished.
Their recorded usage totals were:
| Metric | Tokens |
|---|---|
| Input tokens | 465,678 |
| Output tokens | 90,511 |
| Combined tokens | 556,189 |
An additional child request recorded:
error_category: usage_limit
Some of these requests may have started before the main agent turn completed. The figures above represent requests that completed afterward, not an exact measurement of exclusively post-completion token consumption.
OpenAI Support subsequently confirmed that my five-hour usage window was at 100%.
Core Problem
The primary issue is the mismatch between the Codex Desktop application's task-completion state and the lifecycle of background processes that continue consuming authenticated Codex usage.
The main conversation appeared finished while the underlying batch process continued scheduling additional model requests.
This created unexpected usage consumption without clear visibility or an obvious way to control the remaining background inference.
I would like the maintainers to investigate whether this is expected behavior or a background-process lifecycle defect.
What steps can reproduce the bug?
Reproduction Conditions
This issue was observed in a real Codex Desktop session on macOS.
The following steps describe the observed execution pattern. They have not been independently validated as a minimal reproduction.
-
Open Codex Desktop on macOS while authenticated through a ChatGPT Plus account.
-
Start an agent task that launches a long-running Python batch-processing command through unified exec.
-
The Python batch script uses
ThreadPoolExecutor(max_workers=2)to process independent jobs concurrently. -
Each worker invokes the signed-in Codex CLI using Python
subprocess.run(). -
The main Codex agent generates its final response and emits
task_completebefore the batch process exits. -
The Python batch continues scheduling and executing independent
codex execinference requests. -
Observe that the desktop conversation appears completed even though authenticated background inference continues.
-
Inspect the local session log and extraction receipts to confirm that the background command completes after
task_complete.
Actual Background Command
The command launched by the Codex agent was:
.venv/bin/python scripts/maintenance/batch.py run batch-0002 --workers 2 --retry-failed
Relevant Implementation
The batch processor uses a thread pool to schedule independent inference jobs:
with ThreadPoolExecutor(max_workers=workers) as executor:
pending[executor.submit(extract, pack, processing_path)] = (
video_id, pack
)
The extraction adapter then launches independent Codex CLI subprocesses:
command = [
cli,
"exec",
"--ephemeral",
"--skip-git-repo-check",
"--json",
# Additional execution arguments
]
result = subprocess.run(
command,
input=prompt,
capture_output=True,
text=True,
env=env,
timeout=900
)
The actual command also includes:
-c 'forced_login_method="chatgpt"'
The child CLI invocation does not explicitly specify a model using --model.
Relevant Session Information
Affected session ID:
01a11983-...-a2d25f6c
The full session ID has been provided to OpenAI Support.
Command execution ID:
exec-2ababd5a-b62e-4af9-b208-fed22eaa4dd7
Execution source:
unified_exec_startup
Process ID:
83963
Command duration:
1032.18 seconds
Exit code:
0
Model Information
- Main desktop session:
gpt-6.1-sol - Main session reasoning effort: High
- Current CLI default model:
gpt-6-sol - Current CLI default reasoning effort: High
- Child CLI model: Not independently verified
The main session historically used both Sol and Astra.
However, I have not established that the post-completion child requests used Astra. Their actual model identities require further investigation.
Reproduction Limitations
I have not rerun the workload solely to reproduce the issue because doing so could consume additional Codex usage allowance.
The original rollout logs, command execution records, and inference receipts have been preserved.
What is the expected behavior?
Expected Behavior
When Codex Desktop launches background processes capable of making authenticated model requests, the application should provide accurate execution status and effective user control.
1. Accurate Task Completion Status
The application should distinguish between:
- Completion of the main agent turn.
- Completion of commands launched by that turn.
- Completion of independently running inference subprocesses.
A completed main turn should not misleadingly imply that all usage-generating activity has stopped.
2. Background Inference Visibility
If model-consuming background processes remain active, the application should clearly indicate that they are still running.
Users should be able to identify which background tasks are consuming their usage allowance.
3. Reliable Cancellation
Users should have a way to terminate active background processes and their child inference requests.
When a user explicitly cancels a task, cancellation propagation should have clearly defined and predictable behavior.
4. Usage Transparency
The application should provide sufficient visibility into continued model usage after the main conversation has finished.
Users should not unknowingly exhaust their usage allowance through background inference that is no longer visible in the main task interface.
5. Model Configuration Transparency
Independently launched Codex CLI requests should have clearly identifiable effective model settings.
Important Clarification
I am not suggesting that all background processes must automatically terminate when an agent turn completes.
Some intentionally detached processes may need to continue running.
The expected behavior is that continued authenticated model inference remains visible, understandable, and controllable, particularly when it consumes the user's limited Codex allowance.
Additional information
Additional Technical Findings
Background Execution Lifecycle
The local rollout contains the following event sequence:
09:37:41.279— Background command started.09:37:48— Main turn emittedtask_complete.09:54:53.500— The same command reporteditem_completed(CommandExecution).
The command completion event therefore appeared approximately 17 minutes after the main task-completion event.
The command exited successfully with code 0.
Independent Codex Inference
Source inspection confirmed that:
batch.pyschedules concurrent inference jobs.extraction.pyinvokes independentcodex execsubprocesses.- These subprocesses authenticate through ChatGPT.
- They do not explicitly specify a model.
- The batch processor can continue assigning work after the main agent turn finishes.
The post-completion extraction receipts confirm continued inference activity.
Usage Limit Evidence
A child extraction failed at approximately 09:54:01 with:
{
"error_category": "usage_limit"
}
The failed request was generated by the independent background inference workflow.
OpenAI Support confirmed that my account's five-hour Codex usage window was exhausted.
I am requesting verification of the actual usage charged after the main task completed.
Desktop Client Identification
I was using the standalone Codex Desktop App on macOS, not the VS Code extension.
However, the local session metadata reports:
source: vscode
This may reflect an internal client classification, but I am including it because it could be relevant to debugging.
Related GitHub Issues
Potentially related reports:
- #14731 — Background process lifecycle and premature turn completion
- #40041 — Command completion appearing after
task_complete
My incident adds a usage-impact dimension: independently launched authenticated Codex inference continued after the main turn completed and eventually encountered a usage-limit error.
OpenAI Support Case
I have already reported the unexpected usage to OpenAI Support.
The case has been escalated to a human support specialist.
I am separately requesting a review of possible usage restoration or other appropriate remediation through the support channel.
This GitHub issue is intended to document the technical behavior and help prevent recurrence.
Available Evidence
I have preserved:
- Original Codex session rollout JSONL
- Command execution timestamps
- Background process execution details
- Inference usage receipts
usage_limitfailure record- Relevant Python source files
- Task completion screenshots
- Usage-limit screenshots
I can provide appropriately redacted logs through a secure channel if requested.
Requested Investigation
Could the maintainers please investigate:
- Why the main task emitted
task_completewhile the background command was still running. - Whether Codex Desktop should surface detached inference subprocesses more clearly.
- Whether users have sufficient control over such processes after the main turn finishes.
- Whether the command lifecycle and event ordering represent expected behavior or a defect.
- How the actual model identities and usage of the background CLI requests can be verified.
Thank you for investigating.
=== CODEX BACKGROUND EXECUTION EVIDENCE ===
Incident: 2026-10-09 (UTC+8)
Client: Codex Desktop / macOS
Session: 01a11983-...-a2d25f6c
=== MAIN TURN & BACKGROUND PROCESS ===
BACKGROUND PROCESS START: 09:37:41
MAIN TASK COMPLETE: 09:37:48
BACKGROUND PROCESS END: 09:54:53
PROCESS DURATION: 1032 seconds
POST-COMPLETION RUNTIME: ~17 minutes
EXIT CODE: 0
=== BACKGROUND INFERENCE RECEIPTS ===
Successful receipts completed after main turn: 15
Recorded input tokens: 465678
Recorded output tokens: 90511
Combined tokens: 556189
USAGE LIMIT ERROR: 09:54:01
ERROR CATEGORY: usage_limit
=== FINDINGS ===
- Main agent turn completed before the background
command exited. - Authenticated Codex CLI inference continued.
- Additional inference jobs completed after the
main turn was marked finished. - The background workflow encountered a usage limit.
NOTE:
Token totals cover requests completed after the
main turn, including some that may have started
before completion. They are not an exact measure
of exclusively post-completion usage.
Evidence derived from local Codex session logs
and extraction receipts.
No credentials or private project content included.
- Dominant language
- Rust
- Stars
- 129k
- Forks
- 20.3k
- Avg merge
- 1m
- Merged PRs (30d)
- 998
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from openai/codex
-
Python SDK: CodexClient.close() leaves the app-server's stdout/stderr pipes open (and never waits after kill)Possibly taken @akhil9tiet claimed this today. Openapp-server bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
openai/codex#54908 · 2 comments ·
Maintainers usually reply within 1 day
-
bug CLI tool-calls windows-os
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
bug tool-calls
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Clarification about NODE_REPL_TRUSTED_BROWSER_CLIENT_SHA256S in the VS Code extension environmentOpendocumentation extension windows-os
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
openai/codex#54780 · 1 comment ·
Maintainers usually reply within 1 day
-
bug context
Difficulty 2/5 Under an hour Newbie friendliness 74/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
521xueweihan/HelloGitHub#4023 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
nautechsystems/nautilus_trader#5365 ·
Maintainers usually reply within 1 day
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
IntersectMBO/developer-experience#347 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
registrystack/registry-stack#2168 ·
Maintainers usually reply within 1 day
-
bug crate: 3d help wanted triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
kornia/kornia-rs#1203 · 1 comment ·
Maintainers usually reply within 1 day