Yeachan-Heo/oh-my-codex · error · Error

[ask] --agent-prompt role "${normalizedRole}" is empty: ${pr

Error message

[ask] --agent-prompt role "${normalizedRole}" is empty: ${promptPath}

What it means

The requested role's prompt file exists but its contents are empty (or whitespace-only, since content is trimmed). `omx ask` refuses to use an empty prompt because concatenating it would silently produce a prompt with no role instructions.

Source

Thrown at src/cli/ask.ts:85

    throw new Error(`[ask] prompts directory not found: ${promptsDir}. Run "omx setup" to install prompts.`);
  }

  const promptPath = join(promptsDir, `${normalizedRole}.md`);
  if (!existsSync(promptPath)) {
    const files = await readdir(promptsDir).catch(() => [] as string[]);
    const availableRoles = files
      .filter((file) => file.endsWith('.md'))
      .map((file) => file.slice(0, -3))
      .sort();
    const availableSuffix = availableRoles.length > 0
      ? ` Available roles: ${availableRoles.join(', ')}.`
      : '';
    throw new Error(`[ask] --agent-prompt role "${normalizedRole}" not found in ${promptsDir}.${availableSuffix}`);
  }

  const content = (await readFile(promptPath, 'utf-8')).trim();
  if (!content) {
    throw new Error(`[ask] --agent-prompt role "${normalizedRole}" is empty: ${promptPath}`);
  }

  return content;
}

export function parseAskArgs(args: readonly string[]): ParsedAskArgs {
  const [providerRaw, ...rest] = args;
  const provider = (providerRaw || '').toLowerCase();

  if (!provider || !ASK_PROVIDER_SET.has(provider)) {
    throw askUsageError(`Invalid provider "${providerRaw || ''}". Expected one of: ${ASK_PROVIDERS.join(', ')}.`);
  }

  if (rest.length === 0) {
    throw askUsageError('Missing prompt text.');
  }

  let agentPromptRole: string | undefined;

View on GitHub (pinned to 3ad79a8a6f)

Solutions

  1. Fill in the prompt file at the path shown in the error with actual role instructions
  2. If the file is a leftover stub, delete it so the 'role not found' path guides you to valid roles instead
  3. Check git status/history for accidental truncation of the prompt file

Example fix

# before
# prompts/executor.md is empty
omx ask --agent-prompt executor "task"
# after
echo 'You are a careful executor agent...' > prompts/executor.md
omx ask --agent-prompt executor "task"
Defensive patterns

Strategy: validation

Validate before calling

import { readFileSync } from 'node:fs';
const content = readFileSync(join(promptsDir, role + '.md'), 'utf-8').trim();
if (!content) throw new Error(`prompt file for '${role}' is empty`);

Try / catch

catch (e) { if (/is empty:/.test(String(e))) { scaffoldDefaultPrompt(role); retry(); } else throw e; }

Prevention

When it happens

Trigger: Passing `--agent-prompt <role>` where `<promptsDir>/<role>.md` exists but is 0 bytes or contains only whitespace/newlines.

Common situations: Placeholder files created but never filled in; prompt files truncated by a bad merge or editor; template scaffolding that creates empty stubs.

Related errors


AI-assisted analysis of Yeachan-Heo/oh-my-codex@3ad79a8a6f (2026-08-27). Data as JSON: /api/errors/b78d1ecfbde51d1e. Report an issue: GitHub.