Skip to content

[CLI] snapshot --json can exit 0 with empty stdout after daemon success #1706

Description

@AdzeB

Summary

With agent-device 0.20.6, an Android snapshot -i --json --force-full request can finish successfully in the daemon and the CLI can exit 0 while emitting zero bytes on stdout.

A caller that correctly treats --json stdout as the response then has no snapshot envelope to parse, even though agent-device recorded the request as successful.

Observed evidence

Command shape:

agent-device snapshot -i --json --force-full --platform android

In a session with the expected Android app foregrounded:

  • the CLI process exited 0;
  • captured stdout was an empty string;
  • the session event log recorded one snapshot request with status: ok and durationMs: 9646;
  • no interaction command ran;
  • an independent snapshot immediately afterward returned a complete JSON envelope for the unchanged screen: success=true, 13 visible nodes, truncated=false, visibility.partial=false.

This was observed after upgrading both the client and daemon to 0.20.6. It is separate from Android helper content failures: the request was not reported as COMMAND_FAILED, and the outer caller received neither an error envelope nor a typed error.

Expected

When --json is requested, exit code 0 always emits one complete success JSON envelope on stdout. If a response cannot be serialized or flushed, the CLI should exit nonzero with a typed error.

Actual

The command can exit 0 with empty stdout even though the daemon records the request as successful.

Likely boundary

The generic success path writes JSON through process.stdout.write, while explicit failure/early-exit paths use the exitAfterFlush helper. The retained evidence cannot prove whether the response was dropped before the writer or during process shutdown, so this is a boundary hypothesis rather than a claimed root cause.

Suggested regression

Run the real CLI as a piped child process against a stub/local daemon success response and assert:

  1. exit code is 0;
  2. stdout is non-empty;
  3. stdout parses as JSON;
  4. the envelope has success === true;
  5. the child does not resolve until the full payload has been read.

A companion negative should force stdout/serialization failure and assert a nonzero typed failure rather than exit 0 with an empty payload.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions