Yeachan-Heo/oh-my-codex · warning
Usage: omx exec inject <session-id> --prompt <text> [--actor
Error message
Usage: omx exec inject <session-id> --prompt <text> [--actor <name>] [--json]
What it means
Usage error from parseExecInjectArgs when the `omx exec inject` CLI is invoked without a session id positional argument. The parser takes the first positional as the session id; if it is missing or whitespace-only, this usage string is thrown instead of attempting anything.
Source
Thrown at src/exec/followup.ts:365
}
export function formatInjectExecFollowupSuccess(result: InjectExecFollowupResult): string {
return [
`Queued exec follow-up ${result.queued.id} for session ${result.queued.session_id}.`,
`Queue: ${result.queuePath}`,
"Delivery: next Stop hook checkpoint; no tmux pane input was sent.",
].join("\n");
}
export function parseExecInjectArgs(args: string[]): {
sessionId: string;
prompt: string;
actor?: string;
json: boolean;
} {
const [, sessionIdRaw, ...rest] = args;
const sessionId = sessionIdRaw?.trim();
if (!sessionId) throw new Error("Usage: omx exec inject <session-id> --prompt <text> [--actor <name>] [--json]");
let prompt = "";
let actor: string | undefined;
let json = false;
for (let i = 0; i < rest.length; i += 1) {
const arg = rest[i]!;
if (arg === "--json") {
json = true;
} else if (arg === "--prompt") {
const value = rest[i + 1];
if (!value) throw new Error("Missing value after --prompt");
prompt = value;
i += 1;
} else if (arg.startsWith("--prompt=")) {
prompt = arg.slice("--prompt=".length);
} else if (arg === "--prompt-file") {
const value = rest[i + 1];
if (!value) throw new Error("Missing path after --prompt-file");View on GitHub (pinned to 3ad79a8a6f)
Solutions
- Provide the session id as the first positional: `omx exec inject <session-id> --prompt <text>`.
- If using a variable, verify it is non-empty first: `[ -n "$SESSION_ID" ] || exit 1`.
- Put the session id before all flags to avoid it being parsed as a flag value.
- Re-check quoting/quoting of arguments in scripts and CI templates.
Example fix
# before omx exec inject --prompt "rerun the tests" # after omx exec inject "$SESSION_ID" --prompt "rerun the tests"
Defensive patterns
Strategy: validation
Validate before calling
const sessionId = process.env.SESSION_ID?.trim();
if (!sessionId) { console.error('SESSION_ID is required'); process.exit(1); }
runCli(['exec', 'inject', sessionId, '--prompt', text]); Type guard
function isSessionIdArg(v: string | undefined): v is string {
return typeof v === 'string' && v.trim().length > 0 && !v.startsWith('-');
} Try / catch
catch (e) { if (e instanceof Error && e.message.startsWith('Usage: omx exec inject')) { console.error(e.message); process.exit(2); } throw e; } Prevention
- Assert positional id variables are non-empty before invoking the CLI.
- Place the session id before any flags.
- Use shell parameter defaults like ${SESSION_ID:?required}.
When it happens
Trigger: Running `omx exec inject` with no arguments; passing only flags (e.g. `omx exec inject --prompt hi`) so the first token is consumed as a flag, not a session id; passing a session id of only whitespace; shell quoting that drops the argument.
Common situations: Shell script passes an unset $SESSION_ID variable; user copies the example command but deletes the id placeholder; flags placed before the positional id get consumed as the id slot value incorrectly; CI template renders an empty id.
Understand the failure class
Background: "no subcommand specified" and "... is required": CLI errors when a required argument is missing — this error's family across 13 libraries.
Related errors
- Missing value after --prompt
- Missing path after --prompt-file
- Missing value after --actor
- Unknown exec inject argument: ${arg}
- Unknown adapt argument: ${arg}
AI-assisted analysis of Yeachan-Heo/oh-my-codex@3ad79a8a6f (2026-08-27).
Data as JSON: /api/errors/4556358730a43421.
Report an issue: GitHub.