Skip to content

agy --print / -p silently drops stdout when run with a non-TTY (pipe, subprocess, redirect) #76

Description

@rdfitted

agy --print / -p silently drops stdout when run with a non-TTY (pipe, subprocess, redirect)

Summary

When agy is invoked in headless print mode from a non-TTY stdout context (e.g. piped, redirected to a file, or spawned as a subprocess from another tool), the binary completes a full model round trip but emits no output on stdout — exit code 0, no stderr indicator. Output appears only when stdout is attached to a real terminal.

This breaks every automation / orchestration scenario that wraps agy as a sub-process (CI scripts, agentic frameworks, multi-agent CLIs, IDE integrations, etc.) — the caller cannot distinguish "model returned nothing" from "model returned a useful answer that was silently discarded."

Environment

  • Antigravity CLI: 1.0.0 (agy --version)
  • OS: Windows 11 (Build 26200.8457)
  • Shells tested: Git Bash (MSYS), PowerShell 7, cmd.exe, winpty agy …
  • Account: signed in to Antigravity, confirmed working (interactive prompts return output normally)
  • Model: Gemini 3.1 Pro (High) (set in ~/.gemini/antigravity-cli/settings.json)
  • Verbosity: low

Reproduction

From any shell where stdout is NOT a TTY:

agy --dangerously-skip-permissions -p "Reply with the word PONG only"

Observed:

  • Exit code 0
  • ~6 seconds wall clock (confirms a real LLM round trip occurred)
  • Zero bytes on stdout
  • Zero bytes on stderr

The same command in an interactive terminal (Warp, Windows Terminal, PowerShell ISE) returns PONG as expected.

Variants tried — all silently empty:

# Long-form print flag
agy --dangerously-skip-permissions --print "Reply PONG"

# Explicit timeout
agy --print-timeout 30s --dangerously-skip-permissions -p "Reply PONG"

# Redirect to file (rules out pipe-buffering)
agy --dangerously-skip-permissions -p "Reply PONG" > out.txt 2> err.txt
# out.txt and err.txt are both 0 bytes

# Via cmd.exe wrapper
cmd.exe /c "agy --dangerously-skip-permissions -p \"Reply PONG\""

# Via winpty (fails earlier because winpty itself needs a TTY)
winpty agy --dangerously-skip-permissions -p "Reply PONG"
# → stdin is not a tty (exit 1)

# Via PowerShell Start-Process with redirected streams
Start-Process -FilePath "agy" -ArgumentList "--dangerously-skip-permissions","-p","Reply PONG" `
              -RedirectStandardOutput out.txt -RedirectStandardError err.txt -Wait -NoNewWindow
# Hangs indefinitely (3+ minutes, no progress)

What the log shows

~/.gemini/antigravity-cli/cli.log shows the print-mode invocations starting the language server, completing auth, and exiting cleanly — there is no error or warning corresponding to the dropped output.

Expected behavior

agy -p / --print should:

  1. Write the model response to stdout regardless of whether stdout is a TTY, OR
  2. Provide a --no-tty, --json, or --output <path> flag that guarantees output is captured in non-interactive contexts, AND
  3. Emit a clear error to stderr if a non-TTY context is unsupported, rather than exiting 0 with empty output.

Compare to gemini-cli (the deprecated predecessor) which exposed -o text and printed reliably to stdout in any context — this is the headless contract orchestration tools depend on.

Impact

This is a hard blocker for using agy inside any agentic framework or CI pipeline. We migrated ~10 multi-agent orchestration commands from gemini-cli to agy (per the deprecation announcement) and discovered every command silently produces empty results when the orchestrator captures agy's stdout. We are rolling back to gemini-cli until a non-TTY headless mode ships.

Suggested fix

  • Flush stdout unconditionally in print mode regardless of TTY detection, OR
  • Add --output <path> to write the response to a file, OR
  • Add a --format json mode that emits structured output to stdout, decoupled from terminal rendering.

Workarounds we considered

  • ConPTY wrapper (e.g. pywinpty) — requires writing a wrapper, defeats the convenience of a CLI.
  • Run agy inside a real terminal via scheduled task — too brittle for synchronous orchestration.
  • Tail cli.log for the response — log doesn't contain model output, only operational events.

None of these are acceptable for production multi-agent use.


Happy to provide additional diagnostics, log excerpts, or a minimal repro repo if useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions