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

Setup AGENTS merge policy flags do not accept values: ${arg}

Error message

Setup AGENTS merge policy flags do not accept values: ${arg} ${next}

What it means

The setup AGENTS merge policy flags are boolean switches and take no value. If the token immediately after one of `--merge-agents`, `--no-merge-agents`, `--clear-merge-agents-policy` is not another flag (doesn't start with `--`), the parser assumes you tried to give the switch a value and throws.

Source

Thrown at src/cli/index.ts:544

export type SetupMergeAgentsPolicyArg =
  | { kind: "set"; value: boolean }
  | { kind: "clear" }
  | undefined;

export function resolveSetupAgentsMergePolicyArg(args: string[]): SetupMergeAgentsPolicyArg {
  let policy: SetupMergeAgentsPolicyArg;
  const setPolicy = (next: Exclude<SetupMergeAgentsPolicyArg, undefined>, source: string): void => {
    if (policy && (policy.kind !== next.kind || (policy.kind === "set" && next.kind === "set" && policy.value !== next.value))) {
      throw new Error(`Conflicting setup AGENTS merge policy flags: ${source} conflicts with another merge policy selector.`);
    }
    policy = next;
  };
  for (let index = 0; index < args.length; index += 1) {
    const arg = args[index];
    if (arg === "--merge-agents" || arg === "--no-merge-agents" || arg === "--clear-merge-agents-policy") {
      const next = args[index + 1];
      if (next && !next.startsWith("--")) {
        throw new Error(`Setup AGENTS merge policy flags do not accept values: ${arg} ${next}`);
      }
      if (arg === "--merge-agents") {
        setPolicy({ kind: "set", value: true }, arg);
      } else if (arg === "--no-merge-agents") {
        setPolicy({ kind: "set", value: false }, arg);
      } else {
        setPolicy({ kind: "clear" }, arg);
      }
    } else if (
      arg.startsWith("--merge-agents=") ||
      arg.startsWith("--no-merge-agents=") ||
      arg.startsWith("--clear-merge-agents-policy=")
    ) {
      throw new Error(`Setup AGENTS merge policy flags do not accept values: ${arg}`);
    }
  }
  return policy;
}

View on GitHub (pinned to 3ad79a8a6f)

Solutions

  1. Remove the value: use the bare flag (e.g. `--merge-agents` not `--merge-agents true`)
  2. Use the opposite flag to express false: `--no-merge-agents`
  3. Reorder args so a positional value doesn't land right after a policy flag

Example fix

# before
omx setup --merge-agents true

# after
omx setup --merge-agents
Defensive patterns

Strategy: validation

Validate before calling

const BOOL_POLICY = ['--merge-agents', '--no-merge-agents', '--clear-merge-agents-policy'];
for (let i = 0; i < args.length; i++) {
  if (BOOL_POLICY.includes(args[i])) {
    const next = args[i + 1];
    if (next && !next.startsWith('--')) {
      console.error(`${args[i]} takes no value`);
      process.exit(1);
    }
  }
}

Try / catch

try {
  await main(args);
} catch (e) {
  if (/merge policy flags do not accept values/.test((e as Error).message)) {
    // remove the stray value token and retry
  } else throw e;
}

Prevention

When it happens

Trigger: `omx setup --merge-agents true` or `omx setup --no-merge-agents false` — any non-flag token directly following one of these flags.

Common situations: Habitually adding `=true`/` true` to boolean flags; scripts generated from config maps that always emit a value after each option.

Related errors


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