jackwener/OpenCLI · error · ArgumentError

chatgpt send cannot use --new and --conversation together

Error message

chatgpt send cannot use --new and --conversation together

What it means

ArgumentError thrown by `chatgpt send` when both `--new` (a truthy boolean flag) and `--conversation` are provided. The two are mutually exclusive: one starts a new chat, the other targets an existing conversation.

Source

Thrown at clis/chatgpt/send.js:37

    access: 'write',
    description: 'Send a prompt to ChatGPT web without waiting for the response',
    domain: CHATGPT_DOMAIN,
    strategy: Strategy.COOKIE,
    browser: true,
    siteSession: 'persistent',
    navigateBefore: false,
    args: [
        { name: 'prompt', positional: true, required: true, help: 'Prompt to send' },
        { name: 'new', type: 'boolean', default: false, help: 'Start a new chat before sending' },
        { name: 'conversation', valueRequired: true, help: 'Continue an existing ChatGPT conversation ID or /c/<id> URL' },
        { name: 'project', valueRequired: true, help: 'Start a new chat inside a ChatGPT project ID or /g/g-p-<id> URL' },
    ],
    columns: ['Status', 'InjectedText'],
    func: async (page, kwargs) => {
        const prompt = requireNonEmptyPrompt(kwargs.prompt, 'chatgpt send');

        if (normalizeBooleanFlag(kwargs.new) && kwargs.conversation) {
            throw new ArgumentError(
                'chatgpt send cannot use --new and --conversation together',
                'Choose either a new chat or an existing conversation.',
            );
        }
        if (kwargs.project && kwargs.conversation) {
            throw new ArgumentError(
                'chatgpt send cannot use --project and --conversation together',
                'Choose either a project new chat or an existing conversation.',
            );
        }

        if (kwargs.conversation) {
            await openChatGPTConversation(page, kwargs.conversation);
        } else if (kwargs.project) {
            await navigateToProject(page, kwargs.project);
        } else if (normalizeBooleanFlag(kwargs.new)) {
            await startNewChat(page);
        } else {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Remove --new if you want to send into the existing conversation.
  2. Remove --conversation if you want a fresh chat.
  3. Review wrapper scripts/config for a hardcoded --new flag.

Example fix

// before
opencli chatgpt send "hello" --new --conversation conv_abc
// after (pick one)
opencli chatgpt send "hello" --conversation conv_abc
Defensive patterns

Strategy: validation

Validate before calling

const args = ['--new', '--conversation', 'conv_abc'];
const hasNew = args.includes('--new');
const convIdx = args.indexOf('--conversation');
if (hasNew && convIdx !== -1) {
  throw new Error('chatgpt send cannot use --new and --conversation together');
}

Type guard

function flagsAreExclusive(opts) { return !(opts.new && Boolean(opts.conversation)); }

Try / catch

try {
  await run(['chatgpt', 'send', prompt, ...flags]);
} catch (err) {
  if (String(err.message).includes('cannot use --new and --conversation')) {
    console.error('Pick either a new chat or an existing conversation.');
  }
}

Prevention

When it happens

Trigger: Invoking `opencli chatgpt send "prompt" --new --conversation <id>` — normalizeBooleanFlag(kwargs.new) is true while kwargs.conversation is set.

Common situations: Scripts accumulating flags from defaults; alias/config files that always add --new; misunderstanding of flag semantics; copy-pasting example commands with conflicting options.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/29aaa231bc48360c. Report an issue: GitHub.