jackwener/OpenCLI · error · CommandExecutionError

Failed to send ChatGPT message:

Error message

Failed to send ChatGPT message: 

What it means

Wrapper error for `chatgpt-app send`: any exception during model selection, app activation, or sendPrompt() is rethrown as CommandExecutionError 'Failed to send ChatGPT message: ' + underlying message. It is the single failure surface for the whole send pipeline on macOS.

Source

Thrown at clis/chatgpt-app/send.js:34

    columns: ['Status'],
    func: async (kwargs) => {
        if (process.platform !== 'darwin') {
            throw new ConfigError('ChatGPT Desktop integration requires macOS (osascript is not available on this platform)');
        }
        const text = kwargs.text;
        const model = kwargs.model;
        try {
            // Switch model before sending if requested
            if (model) {
                activateChatGPT();
                selectModel(model);
            }
            activateChatGPT();
            sendPrompt(text);
            return [{ Status: 'Success' }];
        }
        catch (err) {
            throw new CommandExecutionError("Failed to send ChatGPT message: " + getErrorMessage(err));
        }
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Check the text after the prefix for the root cause
  2. Verify --model is one of MODEL_CHOICES (auto, instant, thinking, 5.2-instant, 5.2-thinking) or omit it
  3. Ensure ChatGPT Desktop is running and unlocked, permissions are granted, then retry

Example fix

// before
execSync('opencli chatgpt-app send "hi" --model gpt4');
// after
execSync('opencli chatgpt-app send "hi" --model instant'); // valid choice from MODEL_CHOICES
Defensive patterns

Strategy: try-catch

Validate before calling

const MODEL_CHOICES = ['auto','instant','thinking','5.2-instant','5.2-thinking'];
if (model && !MODEL_CHOICES.includes(model)) throw new Error(`bad --model: ${model}`);
if (process.platform !== 'darwin') throw new Error('macOS required');

Try / catch

try {
  execSync(`opencli chatgpt-app send "${text}" --model ${model}`);
} catch (e) {
  const msg = String(e.message);
  if (msg.includes('Failed to send')) console.error('send failed:', msg.split('Failed to send ChatGPT message: ')[1]);
  throw e;
}

Prevention

When it happens

Trigger: `chatgpt-app send` where selectModel/activateChatGPT/sendPrompt throws: invalid --model choice, osascript exec failure, Automation permission denied, app not running, or keystroke paste failing.

Common situations: Typo in --model value; ChatGPT app quit; accessibility keystroke simulation blocked; sending while the screen is locked.

Related errors


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