Skip to content

consult: agy consumes --sandbox as the --print prompt due to invalid argv ordering #1079

Description

@mohidmakhdoomi

Problem

The Gemini consultation lane delivers the wrong prompt to Antigravity CLI (agy) because Codev orders the --print argument incorrectly.

With agy 1.0.10, --print is a string-valued flag and requires its prompt immediately afterward. Codev currently builds:

agy --print --sandbox --print-timeout 5m --add-dir <workspace> --add-dir <temp> <actual-prompt>

As a result, agy consumes the next token, --sandbox, as the print prompt. The real consultation prompt is never delivered. The command can still exit 0 and emit non-empty, plausible-looking meta-output, so Codev records the lane as successful.

This is a concrete root cause for the off-task/no-verdict behavior tracked more broadly in #1032.

Environment reproduced

  • agy --version: 1.0.10
  • globally installed @cluesmith/codev: 3.1.9
  • repository main: 3.2.0
  • Linux

Both the globally installed release and current main exhibit the bug.

Reproduction matrix

All three Codev front doors fail:

consult -m gemini --prompt 'Reply with exactly: CONSULT_GEMINI_OK'
consult -m pro --prompt 'Reply with exactly: PRO_ALIAS_OK'
consult -m gemini --prompt-file /tmp/prompt.txt

Observed responses include:

  • generic guidance about using a sandbox;
  • "It looks like you've sent me the --sandbox flag";
  • an explicit statement that only --sandbox was received and no review prompt/diff was provided.

The commands exit 0 and Codev writes these responses as consultation output.

Direct control tests isolate the ordering problem:

# Broken: reproduces Codev ordering; agy responds to --sandbox rather than the prompt
agy --print --sandbox --print-timeout 45s 'Reply with exactly: AGY_OK'

# Working: prompt is the value of --print
agy --sandbox --print-timeout 45s --print 'Reply with exactly: AGY_OK'

# Also working
agy --print='Reply with exactly: AGY_OK' --sandbox --print-timeout 45s

The correctly ordered form also successfully used agentic file access to read packages/codev/package.json and return its exact 3.2.0 version.

Root cause

packages/codev/src/commands/consult/index.ts constructs:

const args = ['--print', '--sandbox', '--print-timeout', AGY_PRINT_TIMEOUT];
for (const d of addDirs) args.push('--add-dir', d);
args.push(promptArg);

For the current agy CLI contract, args[1] becomes the --print value. Therefore the model receives --sandbox, not promptArg.

The unit tests only assert that --print, --sandbox, and --add-dir are present. The prompt-folding test explicitly expects promptArg to be the final argv item, preserving the invalid ordering rather than validating the CLI contract.

Second affected call site: codev doctor

packages/codev/src/commands/doctor.ts has the same pattern:

spawn(bin, ['--print', '--print-timeout', '20s', 'Reply with just OK'], ...)

Here --print-timeout can be consumed as the prompt. Any non-empty generic response may make the probe falsely report agy as operational without testing the intended prompt or timeout behavior.

Expected fix

Construct the argv so the prompt is the actual value of --print, for example:

const args = ['--sandbox', '--print-timeout', AGY_PRINT_TIMEOUT];
for (const d of addDirs) args.push('--add-dir', d);
args.push('--print', promptArg);

Apply equivalent ordering to the doctor probe.

Acceptance criteria

  • consult -m gemini --prompt 'Reply with exactly: OK' delivers the complete prompt and returns OK, not sandbox meta-commentary.
  • consult -m pro and --prompt-file use the same corrected path.
  • Structured Gemini reviews receive the complete role + query and can return a parseable verdict.
  • Large-prompt temp-file indirection remains functional.
  • codev doctor passes its intended probe text as the value of --print and retains the 20-second print timeout.
  • Unit tests assert the prompt immediately follows --print (or is supplied as --print=<prompt>), not merely that both tokens occur somewhere in argv.
  • A guarded real-agy test covers the current 1.0.10 argument contract.

Related

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