diff --git a/extensions/cli/src/commands/chat.ts b/extensions/cli/src/commands/chat.ts index 762fe2781..82301610b 100644 --- a/extensions/cli/src/commands/chat.ts +++ b/extensions/cli/src/commands/chat.ts @@ -446,7 +446,7 @@ async function runHeadlessMode( ): Promise { // Critical validation: Ensure we have a prompt in headless mode // This prevents the CLI from hanging in TTY-less environments - if (!prompt) { + if (!prompt && !options.prompt?.length && !options.agent) { throw new Error( 'Headless mode requires a prompt. Use: cn -p "your prompt"\n' + 'Or pipe input: echo "prompt" | cn -p\n' +