Yeachan-Heo/oh-my-codex · error · Error
Missing value for ${flag}.
Error message
Missing value for ${flag}. What it means
The autopilot arg parser supports both `--flag=value` and `--flag value` forms. In the two-token form, if the token after the flag is missing, empty, or is itself another `--flag`, the value is considered missing and the error names the flag that lacked a value.
Source
Thrown at src/cli/autopilot.ts:34
omx autopilot advance --to <ralplan|ultragoal> --handoff-json <json-or-path> [--session <id>] [--json]
The supervisor owns one session-scoped autopilot-state.json. Child stages remain
supervised phases; advance validates durable artifacts and cannot skip stages.
Cancel and state clear remain available through their normal exact-session paths.
`;
interface AutopilotCommandDependencies {
cwd?: () => string;
stdout?: (line: string) => void;
}
function value(args: readonly string[], flag: string): string | undefined {
const inline = args.find((arg) => arg.startsWith(`${flag}=`));
if (inline) return inline.slice(flag.length + 1);
const index = args.indexOf(flag);
if (index < 0) return undefined;
const result = args[index + 1];
if (!result || result.startsWith('--')) throw new Error(`Missing value for ${flag}.`);
return result;
}
function positionalTask(args: readonly string[]): string {
const valueFlags = new Set(['--task', '--session', '--to', '--handoff-json']);
const words: string[] = [];
for (let i = 0; i < args.length; i += 1) {
if (valueFlags.has(args[i])) { i += 1; continue; }
if (!args[i].startsWith('--')) words.push(args[i]);
}
return words.join(' ').trim();
}
async function jsonInput(raw: string): Promise<Record<string, unknown>> {
const text = raw.trim().startsWith('{') ? raw : await readFile(raw, 'utf-8');
const parsed = JSON.parse(text) as unknown;
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) throw new Error('--handoff-json must resolve to a JSON object.');
return parsed as Record<string, unknown>;View on GitHub (pinned to 3ad79a8a6f)
Solutions
- Supply the value: `--task "fix the bug"` or inline `--task="fix the bug"`
- If the value legitimately starts with `--`, use the `--flag=value` inline form to disambiguate
- Fix scripts so flags and values are appended as a pair, never conditionally one-sided
Example fix
# before omx autopilot --task --to alice # after omx autopilot --task="--to alice considered as text" --to alice
Defensive patterns
Strategy: validation
Validate before calling
function flagValue(args: string[], flag: string): string | undefined {
const i = args.indexOf(flag);
if (i < 0) return undefined;
const v = args[i + 1];
if (!v || v.startsWith('--')) throw new Error(`Missing value for ${flag}.`);
return v;
} Try / catch
catch (e) { const m = /Missing value for (.+)\./.exec(String(e)); if (m) { repromptForFlag(m[1]); } else throw e; } Prevention
- Prefer the --flag=value inline form for unambiguous parsing
- Append flags and values as pairs in scripts
- Quote values that may start with dashes
When it happens
Trigger: Calling autopilot with `--task --to alice` (value looks like another flag), `--task` as the last argument, or an empty inline value edge in `--session`/`--task`/`--to`/`--handoff-json`.
Common situations: Flag ordering mistakes; scripts conditionally appending a flag without its value; values that genuinely start with `--` (e.g. a task string beginning with dashes).
Related errors
- Missing value after --prompt
- Missing value after --actor
- Unknown adapt argument: ${arg}
- Unknown adapt subcommand: ${subcommand}. Supported subcomman
- agents-init accepts at most one path argument.\n${AGENTS_INI
AI-assisted analysis of Yeachan-Heo/oh-my-codex@3ad79a8a6f (2026-08-27).
Data as JSON: /api/errors/c5f0b01e30cc7ce1.
Report an issue: GitHub.