Skip to content

fix(antigravity): skip the hook script and python3 outside an Orca pane - #42790

Merged
brennanb2025 merged 1 commit into
mainfrom
brennanb2025/agy-hook-orca-gate
Nov 15, 2026
Merged

brennanb2025 merged 1 commit into
mainfrom
brennanb2025/agy-hook-orca-gate

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Orca adds a status hook to Antigravity (agy). agy runs it on every message, and before and after every tool call. That includes agy sessions that have nothing to do with Orca, and machines where Orca was uninstalled long ago. Each run started two shells and a python3 just to find out that Orca wasn't there. A widely shared post blamed this for agy feeling laggy.

Now the hook checks for Orca first, with one shell test, and only starts the script inside an Orca terminal.

Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​25 $\color{#cf222e}{\Huge{\mathbf{−}}}$​16 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​9
Prod 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​27 $\color{#cf222e}{\Huge{\mathbf{−}}}$​12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​15

What Changed

  • Before: agy runs /bin/sh -c → /bin/sh antigravity-hook.sh → python3 reads stdin → the script sees ORCA_PANE_KEY is empty → exits. That's about 0.1s per hook, about 0.2s per tool call, and 4–5s across a 20-tool-call task. Measured with agy 1.5.8 on macOS.
  • After: the /bin/sh -c command checks ORCA_PANE_KEY before running the script, the same way Grok's command already does. Outside an Orca pane it prints the reply the script would have printed and returns:
    • PreToolUse: {"decision":"ask"}
    • Stop: {"decision":""}
    • other events: {}
  • Stdin outside Orca is still drained, so agy never writes to a closed pipe. The drain runs cat in the background (new stdinMayStayOpen option on wrapPosixHookCommand), so hosts that keep stdin open, such as ACP clients, never block on it.
  • Missing script: when ~/.orca is deleted, non-PreToolUse events now get {} instead of nothing. That's the reply the script itself always gives.
  • Inside Orca nothing changes.
  • Existing installs get the new command the next time Orca starts, because the installer rewrites hook entries that don't match.

Why

  • Why gate in the command: this skips every process the hook would start. Moving the check inside the script would still start two shells.
  • Why a background drain: a foreground cat would hang on hosts that never close stdin. agy treats a timed-out PreToolUse hook as "deny", so a hang would block tool calls. A background cat keeps the always-drain-stdin rule without that risk.
  • Relation to fix(agent-hooks): drain and exit before the reader when no Orca context exists #42655: that PR moves the Orca check first for 14 other agents but deliberately skips agy, which is the agent in the report.

Linked Issue

Part of #42601. This fixes the slowdown from hooks that run outside Orca. Removing hooks on uninstall is separate work.

Visual Proof

N/A. No UI change. Real-agy timings are under Testing.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below
  • Every added test fails without this change and avoids the test anti-patterns

Real agy 1.5.8 on macOS, one agy -p turn that reads a file with one tool call. The new commands were installed into ~/.gemini/config/hooks.json and restored afterwards.

  • Outside Orca: the hook script ran 0 times (7 times before). The tool call went through, and agy's log shows no hook failures.
  • Inside Orca (pane variables plus a local hook server): all 7 events posted. That's PreInvocation ×2, PreToolUse, PostToolUse, PostInvocation ×2 and Stop, the same as before.
  • Background drain across shells: checked under /bin/sh, dash, zsh and bash. Each returns at once while the background cat still reads the full payload.
  • New test: posix-hook-invocation.test.ts runs the installed command for PreToolUse, Stop and PreInvocation with stdin held open and no pane key. It asserts the reply and that the script never ran. Reverting the fix makes the script run. A foreground drain makes the test hang and fail.
  • pnpm test src/main/antigravity src/main/agent-hooks/installation src/shared/agent-hook-listener passes. pnpm tc:node, oxlint and oxfmt pass.

Risk

  • Riskiest part: the PreToolUse reply outside Orca. agy treats silence as "deny", so a wrong reply would block every agy tool call outside Orca. It prints the same {"decision":"ask"} the script printed, and the real-agy run above exercised it.
  • Platforms: POSIX only. The SSH remote install uses the same command builder. Windows hooks are unchanged; they already check for Orca before reading stdin.
  • Back out: a plain revert, after which the next Orca launch reinstalls the old command.

Level: Low

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out

@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 395ff248-7c69-4068-a7ac-74d7d88027e0
Commits

Reviewing files that changed from the base of the PR and between 8dc93c4 and 1d168a8.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The POSIX hook command wrapper now supports background stdin draining when stdin may remain open. When ORCA_PANE_KEY is absent, the Antigravity service provides event-specific fallback stdout. Tests cover three hook events, confirm successful command exit, and verify that the managed hook script does not run. The flaky-test baseline entry for the POSIX invocation test was removed.

Merge Risk: Minimal · previous review 8dc93

Antigravity hooks outside an Orca pane now return the expected reply without starting the hook script, and behavior inside Orca is unchanged. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the fix (skipping the hook script and python3 outside an Orca pane) and the scope (antigravity). The changeset gates the Antigravity hook command on ORCA_PANE_KEY, so the title matches…
Description check Passed The description follows the repository template. It includes ELI5, What Changed, Why, Linked Issue, Visual Proof (N/A with reason), Testing with checkboxes, Risk with level, Review, Agent skill upstre…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the fix (skipping the hook script and python3 outside an Orca pane) and the scope (antigravity). The changeset gates the Antigravity hook command on ORCA_PANE_KEY, so the title matches the main change. The title is 71 characters, which is within a typical length for a conventional-commit subject.

Full details: Description check

Explanation

The description follows the repository template. It includes ELI5, What Changed, Why, Linked Issue, Visual Proof (N/A with reason), Testing with checkboxes, Risk with level, Review, Agent skill upstream boundary, Notes, and Checklist. The AI Disclosure section is left empty, which the template allows for Stablyai team members but which may need a fill-in for outside contributors. The Linked Issue section says 'Part of #42601' and 'Fixes #' is not filled in, so the template's requirement to link an issue with 'Fixes' is not fully met.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 30173e81-3673-4572-a022-c0e89cd47cfa
Commits

Reviewing files that changed from the base of the PR and between e516efc and 8dc93c4.

Files selected for processing: 7

  • config/flaky-test-pattern-baseline.txt
  • src/main/agent-hooks/installation/commands/posix-hook-command.ts
  • src/main/agent-hooks/installation/scripts/hook-stdin-contract.ts
  • src/main/antigravity/hook-events.ts
  • src/main/antigravity/hook-service.test.ts
  • src/main/antigravity/hook-service.ts
  • src/main/antigravity/posix-hook-invocation.test.ts
Files with no reviewable changes: 1

  • config/flaky-test-pattern-baseline.txt

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

agy runs Orca's hook on every message and before and after every tool call.
Outside Orca the command still started two shells and python3 before the
script noticed ORCA_PANE_KEY was empty: about 0.1s per hook, ~0.2s per tool
call, even after Orca was uninstalled (#42601).

The /bin/sh -c command now checks ORCA_PANE_KEY first, like Grok's. Outside a
pane it prints the reply the script would have printed and drains stdin in
the background, so hosts that keep stdin open (ACP) never block.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant