Skip to content

Add TTY detection for interactive prompts to prevent agent hangs #1536

@waldekmastykarz

Description

@waldekmastykarz

Parent: #1534

Problem

cert remove uses Console.ReadLine() in a while(true) loop to prompt for confirmation. When called by an AI agent or in any non-interactive context (CI, piped stdin, headless), the command hangs indefinitely waiting for input that will never come.

The --force flag exists to skip the prompt, but:

  • The help text doesn't mention that --force is required for non-interactive use
  • There's no TTY detection — the prompt runs regardless of whether stdin is a terminal

Rationale

AI agents and CI pipelines don't have interactive terminals. A CLI that hangs waiting for input is a blocker — the agent can't recover from it, can't detect it's happening, and can't time out gracefully. This is the most common way CLIs break in automated contexts.

Proposed solution

  1. Add TTY detection before prompting. If stdin is not a terminal and --force is not set, fail immediately with:

    Error: Confirmation required but running in non-interactive mode. Use --force to skip confirmation.
    

    In .NET: Console.IsInputRedirected detects non-TTY stdin.

  2. Consider a global --no-input flag that disables all interactive prompts across all commands. Any command requiring confirmation without --force should fail with a clear error.

  3. Update help text for cert remove to note that --force is required for non-interactive use.

  4. Audit all commands for other Console.ReadLine() calls that could hang.

Affected code

  • DevProxy/Commands/CertCommand.csPromptConfirmation() method
  • Any other code using Console.ReadLine() or similar interactive patterns

Metadata

Metadata

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions