Skip to content

fix(daemon): restore Antigravity STDIN pipe by omitting legacy -p flag#6060

Open
pratikforge wants to merge 6 commits into
nexu-io:mainfrom
pratikforge:fix-agy-stdin
Open

fix(daemon): restore Antigravity STDIN pipe by omitting legacy -p flag#6060
pratikforge wants to merge 6 commits into
nexu-io:mainfrom
pratikforge:fix-agy-stdin

Conversation

@pratikforge

@pratikforge pratikforge commented Jul 24, 2026

Copy link
Copy Markdown

Fixes #5495

Why

This fixes the ENAMETOOLONG crash on Windows when using the latest agy 1.1.x versions with large plugins (like the Default design router).

As noted in #5495, agy 1.1.x broke the legacy -p - CLI flag contract, treating the dash as an empty prompt rather than a STDIN sentinel. However, the background STDIN pipe itself still works natively in 1.1.x if the flag is omitted entirely.

This PR removes the explicit -p flag argument from buildArgs. When promptViaStdin is enabled, the daemon now correctly pipes the payload natively, completely resolving the Windows limit crash without needing temporary files or legacy binary downgrades.

What users will see

  • Windows users will no longer experience spawn failed: spawn ENAMETOOLONG crashes when generating designs with large context windows.
  • Users can safely use the latest global agy versions (1.1.x) instead of being pinned to 1.0.3.

Proof it works!
Here is Open Design flawlessly rendering a massive payload using the latest agy 1.1.x on Windows without crashing:

Surface area

  • UI — new page / dialog / panel / menu item / setting / empty state in apps/web or apps/desktop (including Electron menu bar)
  • Keyboard shortcut — new or changed
  • CLI / env var — new od subcommand or flag, new tools-dev / tools-pack / tools-pr flag, or new OD_* env var
  • API / contract — new /api/* endpoint, new SSE event, or changed shape in packages/contracts
  • Extension point — new entry under skills/, design-systems/, design-templates/, or craft/, or change to the skills protocol
  • i18n keys — added new translation keys (see TRANSLATIONS.md for the locale workflow)
  • New top-level dependency — adding any new entry to the root package.json
  • Default behavior change — changes what existing users experience without opting in
  • None — internal refactor, docs, tests, or translation update only

Bug fix verification

  • Test path that reproduces the bug: apps/daemon/tests/runtimes/agent-args.test.ts
  • Did the test go red on main and green on this branch? yes
  • We explicitly verified the new STDIN logic against agy 1.1.5 on Windows where a 30KB payload previously triggered ENAMETOOLONG.

Validation

  • npx vitest run tests/runtimes/agent-args.test.ts
  • End-to-end testing with a large context generation via npx pnpm run tools-dev.
Screenshot (1396)

ARareUsername and others added 5 commits July 21, 2026 02:43
agy's -p/--print/--prompt takes the prompt as a command-line argument; it
does not read from stdin and has no '-' stdin sentinel. The adapter invoked
'agy -p -' with promptViaStdin, so agy received the literal '-' as an empty
prompt and replied "your request was empty or a placeholder (-)".

- antigravity.ts: emit ['-p', <prompt>] and set promptViaStdin: false
- executables.ts / app-config.ts: add missing AGY_BIN override key + allowlist
  entry so agy can be pointed at an explicit binary when auto-detection fails
  (parity with every other agent)
- agent-args.test.ts: assert the new argv contract
Copilot AI review requested due to automatic review settings July 24, 2026 15:21
@lefarcen
lefarcen requested a review from nettee July 24, 2026 15:25
@lefarcen lefarcen added size/S PR changes 20-100 lines risk/high High risk: apps/desktop, daemon, auth, migration, workflows, package deps type/bugfix Bug fix needs-validation Runtime change detected; needs human or /explore agent validation. labels Jul 24, 2026

@lefarcen lefarcen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @pratikforge — the regression write-up and the Windows reproduction are clear, especially the way you tied the ENAMETOOLONG failure back to the Antigravity prompt-delivery path. Before pool review picks this up, could you add the missing Surface area checklist and a short Validation section describing exactly what you ran to verify the fix?

Related: #5585 and #5997 are also open against this same Antigravity prompt-delivery area, so it would be good to compare approaches and avoid duplicate merge work.

@lefarcen

Copy link
Copy Markdown
Contributor

🧪 Queued for QA validation — this PR changes a live runtime path, so we’ll keep the needs-validation label on it and run the manual QA pass once it is merge-ready. Nothing needed from you right now; we’ll update here after validation. Thanks for the contribution! 🙏

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the daemon’s Antigravity (agy) runtime integration to avoid the legacy -p - prompt-flag contract and improve compatibility with newer agy behavior (notably on Windows where long argv can trigger ENAMETOOLONG).

Changes:

  • Adjust Antigravity runtime argument construction to stop relying on the legacy -p - stdin-sentinel behavior.
  • Add AGY_BIN as a supported env override for resolving the Antigravity executable.
  • Update unit tests that pin the Antigravity argv/prompt-delivery contract.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
apps/daemon/src/runtimes/defs/antigravity.ts Changes Antigravity runtime startup behavior (argv building, PATH handling, prompt delivery assumptions).
apps/daemon/tests/runtimes/agent-args.test.ts Updates the pinned Antigravity argv/prompt-delivery expectations.
apps/daemon/src/runtimes/executables.ts Adds AGY_BIN as the env var override key for Antigravity binary resolution.
apps/daemon/src/app-config.ts Allows AGY_BIN in the agent CLI env allowlist for Antigravity.
Comments suppressed due to low confidence (2)

apps/daemon/tests/runtimes/agent-args.test.ts:563

  • The model-selection argv assertion still expects -p <prompt>, but after switching antigravity back to stdin prompt delivery, buildArgs should stay prompt-free and only include --log-file (plus any other non-prompt flags). Update this deep-equality assertion accordingly.
      agentLogFilePath: '/tmp/od-agy-test.log',
      antigravitySettingsPath: join(settingsDir, 'settings.json'),
    });
    assert.equal(withModel.includes('--model'), false);
    assert.deepEqual(withModel, ['--log-file', '/tmp/od-agy-test.log', '-p', 'hi']);

apps/daemon/tests/runtimes/agent-args.test.ts:580

  • Follow-up/first-turn assertions still expect -p <prompt> argv. With stdin prompt delivery, buildArgs should return the same prompt-free argv regardless of turn (and should still avoid -c). Update these expectations to match the new contract.
  const followUp = antigravity.buildArgs('next message', [], [], {}, {
    hasPriorAssistantTurn: true,
  });
  assert.deepEqual(followUp, ['-p', 'next message']);
  assert.equal(followUp.includes('-c'), false);

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +9 to +14
import { dirname, join, delimiter } from 'node:path';

const localAgyPath = join(process.cwd(), '.agy');
if (existsSync(localAgyPath) && !process.env.PATH?.includes(localAgyPath)) {
process.env.PATH = localAgyPath + delimiter + process.env.PATH;
}
Comment on lines 209 to 213
// plain-stream models like Gemini 3.5 Flash.
buildArgs: (
_prompt,
prompt,
_imagePaths,
_extra = [],
Comment on lines 231 to 235
// Flag order is load-bearing on agy: `agy -p --log-file /tmp/x <prompt>`
// runs, while the reverse leaves the log empty.
if (runtimeContext.agentLogFilePath) {
args.push('--log-file', runtimeContext.agentLogFilePath);
}
Comment on lines 537 to 541
test('antigravity passes the prompt as the -p argument (print mode)', () => {
assert.equal(antigravity.bin, 'agy');
assert.equal(antigravity.streamFormat, 'plain');
assert.equal(antigravity.promptViaStdin, true);
assert.equal(antigravity.promptViaStdin, false);

@lefarcen

Copy link
Copy Markdown
Contributor

Hey @pratikforge — there are a couple of concrete follow-ups in the current review thread now: the test expectations still need to match the stdin-based prompt contract, and the module-level PATH mutation in antigravity.ts needs another pass. Once those are addressed, please also fill in Surface area, Bug fix verification, and Validation in the PR body so the next review round has the full context.

💡 To drive this PR to merge hands-free, paste this to your AI coding agent (Claude Code / Codex / opencode / Cursor …):
Take over nexu-io/open-design#6060 until it merges — read https://raw.githubusercontent.com/nexu-io/looper/main/skills/pr-takeover/SKILL.md and follow it.

@lefarcen lefarcen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @pratikforge — thanks for updating the PR body; the added sections make the intent much easier to follow. There’s still one template pass left before pool review can scope this quickly: could you turn Surface area into the checklist form from the template, and make Bug fix verification / Validation a bit more concrete about the exact red→green repro and command(s) you ran?

@pratikforge

Copy link
Copy Markdown
Author

Hey @lefarcen , thanks for the review!

I've just pushed a new commit that addresses all the follow-ups:

  1. Removed the module-level .agy PATH mutation hack.
  2. Updated agent-args.test.ts to align the test assertions with the new prompt-free STDIN contract.
  3. Added the Surface area, Bug fix verification, and Validation sections to the PR body for context.

Everything is green on my end, let me know if anything else is needed for merge!

@pratikforge

Copy link
Copy Markdown
Author

All done! Updated the description to match the template checklist and added the exact test path + repro details. @lefarcen

@lefarcen

Copy link
Copy Markdown
Contributor

Thanks @pratikforge — I can see the body updates landed, and the bot-side follow-ups you were responding to are covered now. From here the next step is pool review on the current head; once the PR is merge-ready, QA can pick up the needs-validation pass.

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

Labels

needs-validation Runtime change detected; needs human or /explore agent validation. risk/high High risk: apps/desktop, daemon, auth, migration, workflows, package deps size/S PR changes 20-100 lines type/bugfix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Antigravity agent adapter fails to pass prompts: agy CLI reads -p - literally instead of from stdin

4 participants