openai / openai/codex-plugin-cc
task command misparses prompt words like "--resume" as CLI flags when forwarded as a single argument
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 33.3k
- Forks
- 2.3k
- PR merge metrics
- No merged PRs in 30d
Description
Bug: task command misparses prompt text as CLI flags when forwarded as a single shell argument, causing false "No previous Codex task thread was found" errors
Symptom
Running node scripts/codex-companion.mjs task "<some multi-word prompt>" with no other flags fails with:
Error: No previous Codex task thread was found for this repository.
even though --resume-last / --resume was never intentionally passed, and this may be the very first task run in the workspace.
Root cause
normalizeArgv() in scripts/codex-companion.mjs:
function normalizeArgv(argv) {
if (argv.length === 1) {
const [raw] = argv;
if (!raw || !raw.trim()) {
return [];
}
return splitRawArgumentString(raw);
}
return argv;
}
When the task subcommand receives exactly one remaining argv element — which happens whenever a caller forwards the whole prompt as a single shell-quoted argument and passes no other flags (e.g. node codex-companion.mjs task "$(cat <<'EOF' ... EOF)", the exact pattern the bundled codex-rescue subagent uses) — the function assumes this single string is an unparsed raw command line and re-splits it word-by-word via splitRawArgumentString().
Any standalone whitespace-delimited word in the prompt that matches one of the recognized boolean flag names (resume, resume-last, fresh, write, background, json) then gets parsed as that CLI flag by parseArgs() in scripts/lib/args.mjs, regardless of surrounding sentence context.
Reproduced: a prompt containing the plain-text sentence "No --resume for subagents, no documented session/context forking..." (discussing Claude Code's own --resume flag as subject matter, not intending to pass a flag) caused options.resume to be set to true, forcing resumeLast = true in executeTaskRun(). Since it was the first-ever task run for that workspace root, resolveLatestTrackedTaskThread() returned nothing, producing the error above.
Why the heuristic exists but misfires here
The argv.length === 1 re-split appears intended for a different calling convention — some caller that joins flags + prompt into a single raw string (e.g. "--write --resume-last fix the bug") that genuinely needs re-tokenizing. That's a legitimate use case. But the same code path is also hit by the codex-rescue subagent's own documented forwarding pattern (single quoted prompt argument, no flags when none apply), where re-tokenizing is actively harmful: it turns ordinary prose into accidental flags.
Suggested fix
Only re-tokenize when the single argument actually looks like an unparsed flag string, e.g. when it starts with - after trimming:
function normalizeArgv(argv) {
if (argv.length === 1) {
const [raw] = argv;
if (!raw || !raw.trim()) {
return [];
}
if (!raw.trimStart().startsWith("-")) {
return [raw];
}
return splitRawArgumentString(raw);
}
return argv;
}
This preserves the legitimate joined-flags-plus-prompt use case (raw string starts with -) while treating ordinary prompt text (which essentially never starts with -) as a single positional argument, not something to re-tokenize. Verified both cases behave correctly with this change:
["No --resume for subagents..."]→ no flags parsed, full text preserved as one positional.["--write --resume-last fix the bug"]→ still correctly parsed as{write: true, "resume-last": true}with positionals["fix", "the", "bug"].
Impact
Any codex-rescue invocation forwarding a prompt with no extra flags (the common case for read-only diagnosis/brainstorm requests, since --write is the only flag typically added by default) will misfire if the prompt happens to contain a bare word matching --resume, --resume-last, --fresh, --write, --background, or --json — which is fairly likely for any meta/technical discussion about Codex or Claude Code's own CLI flags, as in this case.
Contributor guide
No contributing guide indexed for this repository
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.
Research direction
Start in scripts/codex-companion.mjs at normalizeArgv(), then follow argument handling into scripts/lib/args.mjs and parseArgs(). Reproduce the two cases described in the issue: a single prompt containing --resume and a joined string beginning with --write; done means prompt text remains one positional argument while genuinely joined flags still parse correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100