Skip to content

Fix task runner liveness, workspace, and cancellation reliability#497

Open
jugol wants to merge 5 commits into
openai:mainfrom
jugol:fix/task-runner-reliability
Open

Fix task runner liveness, workspace, and cancellation reliability#497
jugol wants to merge 5 commits into
openai:mainfrom
jugol:fix/task-runner-reliability

Conversation

@jugol

@jugol jugol commented Jul 14, 2026

Copy link
Copy Markdown

Summary

This fixes four task-runner reliability issues encountered in real-world use of plugin v1.0.6 with codex-cli 0.144.1 on Windows 11.

Changes

Detect orphaned running jobs

When a background worker was killed externally (e.g., a caller's shell-tool timeout killing the process tree), its persisted job stayed running indefinitely — we observed a job reported as running for 45+ minutes after its process had died. Status reads now verify recorded PIDs, persist an unexplained process exit as a failed job (Process exited without reporting.), and make that effective state available to status and resume-candidate selection.

Allow callers to pin the task workspace

Tasks launched from an unrelated caller directory could start Codex against the wrong workspace and waste the run (Codex correctly refuses to write outside its workspace root, so the whole task ends with no changes). The existing --cwd/-C task parsing is now documented in help text and validates that the requested path is a directory before starting Codex.

Make cancellation shell-safe and queue-safe

On Windows under Git Bash/MSYS, shell path conversion could rewrite taskkill /PID into taskkill 'C:/Program Files/Git/PID' and prevent cancellation. Separately, cancelling a still-queued job removed its record, and when the queued worker later started it crashed within seconds. taskkill now runs with an argument array and shell: false, cancellation is persisted before termination, and late workers exit cleanly for cancelled or missing records.

Prefer durable background rescue tasks

Foreground rescue tasks could be killed when the calling shell tool reached its timeout, producing the orphaned-job condition above. The rescue command and agent guidance now default work expected to exceed a few minutes to task background mode and require an explicit workspace root.

Tests

  • npm test: 98/98 passed (full suite run in WSL; the repo's raw native-Windows run has pre-existing POSIX-path assumptions unrelated to this change)
  • Targeted native-Windows tests for all changed process/runtime paths: 19/19 passed
  • New regression tests cover workspace selection, dead-PID reconciliation, queued-job cancellation, and cancellation races

🤖 Generated with Claude Code

- Detect orphaned running jobs: status reads verify recorded PIDs and
  persist unexplained process exits as failed jobs
- Document and validate the task --cwd/-C workspace override
- Make cancellation shell-safe (taskkill via argument array, shell:false)
  and queue-safe (cancellation persisted before termination; late workers
  exit cleanly on cancelled or missing records)
- Docs: default long rescue tasks to --background and require explicit --cwd

All four defects were hit in real-world use of v1.0.6 on Windows 11.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@jugol jugol requested a review from a team July 14, 2026 17:47

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f168a47c88

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread plugins/codex/agents/codex-rescue.md Outdated
Backslash now escapes only quotes, whitespace, or another backslash;
any other sequence (e.g. C:\Users\me\repo) keeps its backslashes, so
Windows --cwd paths survive raw-argument tokenization. Addresses the
automated review finding on the --cwd guidance.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f1c04d889a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread plugins/codex/scripts/codex-companion.mjs
Cancellation is still persisted before termination to keep the
queued-worker race closed, but if termination fails and the process is
verified alive, the job record is restored to its previous active state
with a retry note so /codex:status shows the live job and /codex:cancel
can be retried. A failed termination against an already-dead process
still settles as cancelled.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7fc8eff531

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread plugins/codex/commands/rescue.md Outdated
Comment thread plugins/codex/scripts/lib/args.mjs
…backslash

- task-resume-candidate now accepts --cwd/-C with the same validated
  resolution as task, and the rescue preflight guidance forwards the
  requested workspace so the continue/new-thread question is scoped to
  the right repo
- In the raw-argument splitter, a backslash before a closing quote is
  treated as a literal path separator when the quote is followed by
  whitespace or end-of-input, so quoted Windows paths like
  "C:\Program Files\Repo\" tokenize correctly while embedded
  escaped quotes elsewhere keep their existing behavior

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c6159deab6

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread plugins/codex/scripts/lib/args.mjs Outdated
A backslash before a closing quote is inherently ambiguous between an
escaped quote ("say \"hello\" now") and a literal trailing path
separator ("C:\Program Files\Repo\"). Local lookahead cannot
distinguish them, so parse in two deterministic passes: pass 1 prefers
escaped quotes and is accepted when all quoted regions close; if it
ends with an open quote (the trailing-separator signature), pass 2
treats backslashes before the active closing quote as literal.
The whitespace/EOI lookahead special case is removed as subsumed.
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