Skip to content

fix: gracefully handle unsupported thread/name/set on older Codex CLI - #126

Merged
dkundel-openai merged 2 commits into
openai:mainfrom
tmchow:fix/119-thread-name-set-compat
Apr 8, 2026
Merged

dkundel-openai merged 2 commits into
openai:mainfrom
tmchow:fix/119-thread-name-set-compat

Conversation

@tmchow

@tmchow tmchow commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

Summary

startThread() in codex.mjs calls thread/name/set unconditionally, which throws on Codex CLI v0.118.0 because that version doesn't support the method. This wraps the call in a try/catch so thread creation succeeds even when naming is unsupported.

Changes

One file: plugins/codex/scripts/lib/codex.mjs, function startThread() (line 639-645).

Thread naming is cosmetic (used for job log labels) and should not prevent thread creation. The try/catch allows the plugin to work with both older and newer Codex CLI versions.

Testing

  • npm test: same results as main (pre-existing failures in commands.test.mjs, unrelated)
  • npm run build: passes

This contribution was developed with AI assistance (Codex).

Fixes #119

Codex CLI v0.118.0 does not recognize the thread/name/set JSON-RPC method,
causing startThread() to throw. Thread naming is cosmetic (for job log
labels) and should not block thread creation. Wraps the call in try/catch
so it fails silently on older CLI versions.

Fixes #119

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

ℹ️ 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 Resolved
Address Codex review feedback: the bare catch swallowed all errors
including auth, network, and server failures. Now only suppresses
errors containing 'unknown variant' or 'unknown method' (the specific
error older CLI versions return) and rethrows everything else.
@D2758695161

Copy link
Copy Markdown

🦀 Assigned! I will submit a PR for this issue. Looking at the fix now.

@tmchow

tmchow commented Apr 5, 2026

Copy link
Copy Markdown
Contributor Author

🦀 Assigned! I will submit a PR for this issue. Looking at the fix now.

@D2758695161 please stop automating things, you're looking at PRs proposing PRs.

@dkundel-openai
dkundel-openai merged commit 4bd783b into openai:main Apr 8, 2026
@tmchow

tmchow commented Apr 8, 2026

Copy link
Copy Markdown
Contributor Author

@dkundel-openai thanks for the merge!

Crazytieguy added a commit to Crazytieguy/codex-plugin-cc that referenced this pull request Apr 15, 2026
Brings in auth-status-via-app-server (openai#177), session-scoped cancel
(openai#83,openai#84), older-CLI graceful fallback (openai#126), untracked-dir working
tree crash fix (openai#166), Windows SHELL handling (openai#178), the version
consistency checker, and related fixes.

Rejected from upstream: package rename back to @openai/*, version bump
to 1.0.3 (we are at 1.0.8), marketplace metadata.version field, the
$ARGUMENTS quoting fix in cancel/result/status slash commands (removed
in our fork), stop-review-gate test additions (feature removed), and
the README rewrite (ours is intentionally different).

Post-merge fixes:
- session-lifecycle-hook: use getCodexAvailability (lightweight) since
  the old getCodexLoginStatus was removed upstream.
- executePlanReviewRun: update orphaned ensureCodexReady call to
  ensureCodexAvailable (upstream renamed; our added code missed it).
- bump-version: drop metadata.version and plugins[codex].version
  targets since our marketplace.json omits them.
- package-lock.json: bump to 1.0.8.
- .claude/worktrees/.gitignore: ignore generated worktree contents.
- getCodexAuthStatus: on connect failure with a stale saved broker
  endpoint, clear the broker state and retry with disableBroker so a
  dead socket does not masquerade as a failed auth.
- runCommand: on Windows only honor $SHELL if it looks like a native
  drive-letter path; Git Bash / MSYS set SHELL to /usr/bin/bash which
  spawnSync cannot resolve.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
tzedekr pushed a commit to tzedekr/codex-plugin-cc that referenced this pull request Apr 21, 2026
Rebases fork onto upstream v1.0.4 and layers only the notification
pipeline deltas on top. Preserves all upstream v1.0.1-1.0.4 fixes
(openai#35, openai#83, openai#84, openai#126, openai#159, openai#166, openai#177, openai#179) which were lost in the
prior overlay.

Changes:
- scripts/lib/notify.mjs (new): writeCompletionMarker / readInbox /
  consumeMarkers writing to \$CLAUDE_PLUGIN_DATA/inbox/<sessionId>/
  <jobId>.json. Uses \${pid}.\${Date.now()} tmp suffix so concurrent
  writers racing on the same jobId can't clobber each other's tmp file.
- scripts/notify-hook.mjs (new): UserPromptSubmit hook that drains the
  current session's inbox and emits a <system-reminder> listing
  finished jobs.
- scripts/lib/tracked-jobs.mjs: writeCompletionMarker on runTrackedJob
  success and failure paths.
- scripts/codex-companion.mjs: worker exit-path safety handlers
  (process exit/SIGTERM/SIGINT/uncaughtException/unhandledRejection)
  and cancel-path marker in handleCancel.
- hooks/hooks.json: registers notify-hook.mjs on UserPromptSubmit.
- commands/prune.md (new): /codex:prune command.

The custom activity-watchdog/hard-timer block from the prior overlay
is not ported here — upstream v1.0.4 has its own completionTimer in
codex.mjs. If hangs recur in practice, that block can be re-applied
from backup-9c07229.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
robinmordasiewicz added a commit to f5-sales-demo/codex-plugin-cc that referenced this pull request Jul 24, 2026
* Fix working-tree review crash on untracked directories (openai#166)

* fix: skip untracked directories in review context

* fix: skip broken untracked symlinks in reviews

* fix: respect SHELL on Windows for Git Bash (openai#178)

* Use app-server auth status for Codex readiness (openai#177)

* Use app-server auth status for Codex readiness

* fix: reuse existing app server for auth checks

* fix: inherit process.env in app-server spawn when no explicit env is provided (openai#159)

`SpawnedCodexAppServerClient.initialize()` passes `this.options.env` to
`spawn()`, but no caller ever sets `env` in options. In Node.js, passing
`undefined` for `env` gives the child process **no** environment variables,
breaking any model provider that relies on env vars (e.g. DATABRICKS_TOKEN).

Fall back to `process.env` when `this.options.env` is not set, matching the
existing pattern in `broker-lifecycle.mjs` and `codex-companion.mjs`.

Co-authored-by: Isaac

Co-authored-by: Bhuvanesh Sridharan <[email protected]>

* fix: gracefully handle unsupported thread/name/set on older Codex CLI (openai#126)

* fix: gracefully handle unsupported thread/name/set on older Codex CLI

Codex CLI v0.118.0 does not recognize the thread/name/set JSON-RPC method,
causing startThread() to throw. Thread naming is cosmetic (for job log
labels) and should not block thread creation. Wraps the call in try/catch
so it fails silently on older CLI versions.

Fixes openai#119

* refactor: only suppress unsupported-method errors for thread/name/set

Address Codex review feedback: the bare catch swallowed all errors
including auth, network, and server failures. Now only suppresses
errors containing 'unknown variant' or 'unknown method' (the specific
error older CLI versions return) and rethrows everything else.

* codex: scope implicit resume-last selection to the current Claude session (openai#83)

Co-authored-by: VOIDXAI <[email protected]>

* codex: scope default cancel selection to the current Claude session (openai#84)

Co-authored-by: VOIDXAI <[email protected]>

* fix: avoid embedding large adversarial review diffs (openai#179)

* fix: avoid embedding large adversarial review diffs

* fix: preserve untracked content in lightweight review

* address comments

* fix: handle ENOBUFS type check in git diff sizing

* bump: update plugin version to 1.0.3 (openai#180)

* codex: honor --cwd when reporting session runtime (openai#35)

* codex: honor --cwd when reporting session runtime

* codex: keep session runtime lookup scoped to callers

---------

Co-authored-by: VOIDXAI <[email protected]>

* fix: declare model in codex-rescue agent frontmatter (openai#169)

* fix: declare model in codex-rescue agent frontmatter

The codex-rescue agent had no model field, leaving Claude Code to assign
whatever default it chooses. As a thin forwarding wrapper that issues a
single Bash call, this agent is well-suited to the haiku tier; declaring
it explicitly ensures a predictable cost profile and tier guarantee.

Co-Authored-By: Claude Code <[email protected]>

* Update codex-rescue.md

---------

Co-authored-by: claude[bot] <[email protected]>
Co-authored-by: Claude Code <[email protected]>
Co-authored-by: Dominik Kundel <[email protected]>

* fix: correct invalid 'xhigh' reasoning effort in README (openai#99)

Closes openai#77

Updated README to replace unsupported 'xhigh' value with 'high' to prevent configuration errors.

* fix: quote \$ARGUMENTS in cancel, result, and status commands (openai#168)

Unquoted \$ARGUMENTS in the ! shell commands allowed shell metacharacters
in user-supplied job IDs to be expanded before Node received them (e.g.,
`task-123; malicious-cmd` would execute the trailing command). This is
inconsistent with review.md and adversarial-review.md, which both wrap
"$ARGUMENTS" in double quotes.

Co-authored-by: claude[bot] <[email protected]>
Co-authored-by: Claude Code <[email protected]>

* fix: route /codex:rescue through the Agent tool to stop Skill recursion (openai#234) (openai#235)

* fix: route /codex:rescue through the Agent tool to stop Skill recursion (openai#234)

`/codex:rescue` previously combined two things that together caused a hang:

- `context: fork` in the frontmatter, which spawns a `general-purpose`
  subagent for the command body.
- Body prose "Route this request to the `codex:codex-rescue` subagent."
  without naming the transport.

When the main agent called `Skill(codex:rescue)` programmatically, the
fork resolved the ambiguous prose by trying `Skill(codex:codex-rescue)`
(unknown skill) and then falling back to `Skill(codex:rescue)`, which
re-entered this command and hung the session until the user cancelled.
No Codex job was ever created.

Naming the transport as `Agent(codex:codex-rescue)` alone is not enough:
forked general-purpose subagents do not expose the `Agent` tool, so the
forked runner cannot reach the subagent that way either. The minimal fix
is therefore two coordinated changes:

- Drop `context: fork` so the command body runs inline in the calling
  agent's context, where `Agent` is in scope.
- Say explicitly "use the `Agent` tool with `subagent_type:
  "codex:codex-rescue"`", and call out that `Skill(codex:codex-rescue)`
  and `Skill(codex:rescue)` are not valid routing paths. Add `Agent`
  to `allowed-tools` so the call does not prompt for permission.

Everything else in rescue.md (resume-candidate check, flag handling,
background/foreground semantics, operating rules) is unchanged. The
`codex:codex-rescue` subagent itself is unchanged.

Tests pin the new allow-list, the explicit `subagent_type`, the ban on
`Skill(codex:codex-rescue)`, and the absence of `context: fork`. The
existing "run the `codex:codex-rescue` subagent in the background"
assertion continues to hold since that sentence still reads correctly
with the Agent-tool transport.

Fixes openai#234

* test: match quoted result and cancel command arguments

---------

Co-authored-by: Dominik Kundel <[email protected]>

* fix: bump plugin version to 1.0.4 (openai#244)

* feat: add Claude session transfer command (openai#374)

* fix: bump plugin version to 1.0.5 (openai#398)

* Remove shell expansion for git commands (openai#447)

* Remove shell expansion for git commands

* Version bump

---------

Co-authored-by: Dominik Kundel <[email protected]>
Co-authored-by: Bhuvanesh Sridharan <[email protected]>
Co-authored-by: Bhuvanesh Sridharan <[email protected]>
Co-authored-by: Trevin Chow <[email protected]>
Co-authored-by: VOIDXAI <[email protected]>
Co-authored-by: VOIDXAI <[email protected]>
Co-authored-by: xiaolai <[email protected]>
Co-authored-by: claude[bot] <[email protected]>
Co-authored-by: Claude Code <[email protected]>
Co-authored-by: Manav Agarwal <[email protected]>
Co-authored-by: Friende <[email protected]>
Co-authored-by: stefanstokic-oai <[email protected]>
Co-authored-by: bryane-oai <[email protected]>
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.

companion script fails with 'unknown variant thread/name/set' on Codex CLI 0.118.0

3 participants