Skip to content

fix(companion): harden task path parsing and availability probes - #574

Open
SomSamantray wants to merge 4 commits into
openai:mainfrom
SomSamantray:fix/393-companion-parser-path
Open

fix(companion): harden task path parsing and availability probes#574
SomSamantray wants to merge 4 commits into
openai:mainfrom
SomSamantray:fix/393-companion-parser-path

Conversation

@SomSamantray

Copy link
Copy Markdown

Operators on the codex:codex-rescuetask path could see false “CLI not installed” errors after a worktree cleanup, have prompts like -m pytest turned into invalid --model values (surfacing Codex 400s as task output), or get a clean exit when the app-server had already emitted an error.

RC1 — availability: binaryAvailable() drops a non-existent cwd for version/help probes only, so a missing worktree no longer masquerades as a missing Codex install.

RC2 — prompt parsing: handleTask enables stopAtFirstPositional in parseArgs, and rescue/runtime docs require routing flags before -- and the prompt after --. Prompt fragments after the first positional are no longer parsed as CLI flags.

RC3 — result status: buildResultStatus() returns failure when turnState.error is set, even if finalTurn was inferred as completed.

node --test tests/process.test.mjs tests/args.test.mjs tests/codex-turn-status.test.mjs tests/commands.test.mjs — 19/19 pass. RC2 integration: node --test --test-name-pattern "does not treat prompt" tests/runtime.test.mjs — pass.

Fixes #393

Fix missing-cwd misreporting as CLI not installed, prevent prompt fragments from being parsed as --model on task, and fail results when turn capture records an app-server error. Adds stopAtFirstPositional for handleTask, -- before prompt in rescue docs, and node --test coverage.
@SomSamantray
SomSamantray requested a review from a team July 31, 2026 06:52

@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: 0edc4e5b8e

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread plugins/codex/scripts/lib/codex.mjs
@SomSamantray

Copy link
Copy Markdown
Author

@codex review

Skip storing error notifications with willRetry and clear state.error on a real completed turn so successful retries are not reported as failures.
@SomSamantray

Copy link
Copy Markdown
Author

@codex review

@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: 4c087f1ba1

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread plugins/codex/agents/codex-rescue.md Outdated
Those flags are Claude-side execution control only. Listing them among task flags before -- would queue a second detached job and return the launch message instead of Codex output.
@SomSamantray

Copy link
Copy Markdown
Author

@codex review

@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: ce4ac23bf2

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 23 to +27
if (!token.startsWith("-") || token === "-") {
positionals.push(token);
if (config.stopAtFirstPositional) {
stopOptions = true;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Stop parsing after any token becomes positional

When a raw task prompt starts with an unrecognized dash-prefixed token, such as --coverage run -m pytest, that token is added to positionals without enabling stopOptions because this new block only handles non-dash tokens. The later -m pytest is consequently still consumed as the model, so the prompt-parsing failure this option is intended to prevent remains for option-looking prompt prefixes. Set stopOptions whenever an unrecognized option is treated as positional as well.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in 790d49c: when \stopAtFirstPositional\ is set, unrecognized long/short options that fall through as positionals now arm \stopOptions, so later tokens like -m\ stay in the prompt instead of being parsed as --model. Covered in \ ests/args.test.mjs.

Comment on lines +539 to +543
emitProgress(
state.onProgress,
`Codex error (retrying): ${message.params.error?.message ?? "unknown error"}`,
"failed"
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep retriable errors out of the failed phase

When the app server emits an error with willRetry: true, this progress event is persisted by createJobProgressUpdater as the running job's phase, and /codex:status renders that phase directly. The job can therefore appear as running with phase failed while Codex is still retrying, potentially causing users or callers monitoring a background task to treat an active run as failed. Report a retrying/running phase here and reserve failed for terminal errors.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in 790d49c: retriable app-server errors (\willRetry: true) now emit progress phase
etrying\ via
esolveErrorProgressPhase; terminal errors still use \ ailed. Covered in \ ests/codex-turn-status.test.mjs.

Arm stopOptions when unrecognized dash tokens become positional so -m in prompts is not consumed as --model. Emit progress phase retrying (not failed) for willRetry app-server errors.
@SomSamantray

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 790d49c3e0

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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.

codex-companion task path: missing-cwd misread as 'not installed', prompt fragments parsed as --model (400 as result), dropped turn errors

1 participant