Conversation
`executeTaskRun` hardcoded `persistThread: true`, so every `task` run created a persistent Codex thread even for disposable, fire-and-forget work (e.g. many parallel subtasks from an orchestrating agent), flooding Codex Recent with `Codex Companion Task: ...` entries with no opt-out. `runAppServerTurn` already supports a per-call `persistThread` toggle that maps to the app-server's `ephemeral` thread param, and `codex exec` already exposes `--ephemeral` at the top level. This wires the same toggle into `codex-companion.mjs task` as an opt-in `--ephemeral` flag. - Default behavior is unchanged: omitting the flag persists a thread exactly as before, and `--resume`/`--resume-last` are untouched. - `--ephemeral` is rejected together with `--resume`/`--resume-last`, since an ephemeral thread cannot be resumed. - Job records now carry an `ephemeral` bit so `findLatestResumableTaskJob` never offers an ephemeral run as a `--resume-last` candidate, and so status/result rendering stops suggesting `codex resume <id>` for a thread that was never persisted. Verified against a real Codex CLI (0.155.1, logged-in ChatGPT account) against `~/.codex/state_5.sqlite`: a single `--ephemeral` task added 0 rows for its cwd, a plain `task` added 1 (unchanged default), 3 parallel `--ephemeral` tasks added 0 more, and `--resume-last` still resumed the persisted thread with context intact. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Edo771977
added a commit
to Edo771977/codex-plugin-cc
that referenced
this pull request
Sep 22, 2026
Import openai#779: --ephemeral on task, for runs nothing should come back to
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Codex Companion's
taskcommand always creates a persistent Codexthread, and this behavior is not changed by this PR —
taskstillpersists by default.
For large or parallel fire-and-forget task runs — especially agent
orchestration workloads that dispatch many independent subtasks —
each
taskinvocation shows up as its own persistent thread inChatGPT/Codex Recent, even when the caller only wants the result and
never resumes that particular thread. Persistent history is
unnecessary overhead in that case.
Solution
Add an opt-in
--ephemeralflag totask. Existingtaskbehavior is unchanged.
Existing:
task ...
→ persistent (behavior unchanged)
New:
task --ephemeral ...
→ non-persistent Codex execution
This is a minimal change that reuses the existing persistence
architecture —
runAppServerTurn'spersistThreadoption, whichalready maps directly to the app-server's
ephemeralthread param —rather than introducing a new thread/session abstraction.
Backward compatibility
existing
taskbehavior is unchanged.--ephemeralis strictly opt-in.--resume/--resume-lastare untouched and keep working exactlyas before for persistent tasks.
--ephemeralcombined with--resume/--resume-lastis rejectedwith an explicit error — this combination is contradictory, since an
ephemeral thread was never persisted and cannot be resumed.
ephemeralbit sofindLatestResumableTaskJobnever offers an ephemeral run as a
--resume-lastcandidate, and sostatus/result rendering stops suggesting
codex resume <id>for athread that was never persisted.
Tests
All 6 newly added tests pass:
--resumerejected--resume-lastrejected--resume-lastAlso manually verified against a real Codex CLI (0.155.1, logged-in
ChatGPT account), reading
~/.codex/state_5.sqlitefor a scratchcwd's persistent thread count:
task --ephemeral: +0task(no flag): +1task --resume-last: +0 (resumes the same thread, context intact)task --ephemeral: +0 moretask --ephemeral --resume-last: validation error, +0sqlite was used only for read-only verification of the outcome; the
implementation itself does not depend on it and only goes through the
existing/public Codex execution path (
runAppServerTurn→ app-serverthread/startwithephemeral).Motivation / use case
Lets an orchestrating agent choose per task:
so that dispatching many independent, fire-and-forget Codex subtasks
in parallel no longer pollutes Recent/history with threads nobody will
ever revisit or resume.