Skip to content

Add TTY detection before TUI fallbacks to prevent agent/CI hangs #685

@DennisTraub

Description

@DennisTraub

Summary

When agentcore commands are invoked without flags in a non-interactive environment (CI, piped stdin, agent automation), several commands fall through to Ink TUI rendering. Without a TTY attached, this causes the process to hang indefinitely.

The CLI already has a strong "any flag = CLI mode" pattern, but there's no safety net when no flags are provided and stdin is not a terminal.

Affected commands

Commands that render Ink TUI when no flags are given:

  • agentcore (bare - launches <App> TUI in alternate screen buffer)
  • agentcore create (renders <CreateFlow>)
  • agentcore deploy (renders <DeployFlow>)
  • agentcore invoke (renders <InvokeFlow>)
  • agentcore dev (enters fullscreen TUI without --logs/--invoke)
  • agentcore add (renders <AddFlow>)
  • agentcore remove (renders <RemoveResourceFlow>)

Suggested fix

Guard TUI launches with process.stdout.isTTY. When not a TTY and no CLI-mode flags are present, print help and exit with code 1 instead of rendering Ink.

Example pattern:

// Before launching any TUI flow
if (!process.stdout.isTTY) {
  cmd.help(); // prints help to stdout
  process.exit(1);
}

Alternatively, a global --non-interactive flag could force CLI-only behavior regardless of TTY state, giving automation consumers an explicit opt-in.

Why this matters

AI agents and CI pipelines are increasingly common consumers of CLIs. A hung process on bare invocation is a blocker for autonomous use - agents cannot answer prompts or interact with TUI flows, and the only recovery is a timeout or SIGKILL. TTY detection is the standard safety net (used by git, gh, docker, and most modern CLIs).

Reproduction

echo "" | agentcore create
# Expected: help text + exit 1
# Actual: process hangs waiting for TUI input

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions