Skip to content

fix(acp): merge layered session _meta so Antigravity keeps standing instructions - #46368

Merged
nwparker merged 1 commit into
stablyai:mainfrom
Nanako0129:fix/merge-acp-session-meta
Nov 21, 2026
Merged

nwparker merged 1 commit into
stablyai:mainfrom
Nanako0129:fix/merge-acp-session-meta

Conversation

@Nanako0129

@Nanako0129 Nanako0129 commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

When Orca starts or reopens a managed Antigravity chat or bot, it sends the agent a few notes: which tools are off, the workspace rules, and the bot's own standing instructions (who it is, its memory, its tools). A bug let the first notes overwrite the last one, so the bot never got its instructions. Now the notes are combined, so the bot gets all of them.

What Changed

Before: managed Antigravity chats and bots silently lost their standing instructions on every session/new and on reopen, even in workspaces with no rules files. In acp-structured-handshake.ts, setup carried ...acpSessionStartMeta(spec, meta) and was spread after _meta: sessionMeta. Managed Antigravity always sets spec.sessionMeta = { antigravity: { disabledTools: ['run_workflow'] } }, so setup._meta always replaced the standing instructions.

After: the agent receives the disabled tools, workspace rules, and standing instructions together.

  • acpSessionStartMeta (src/main/acp/launch/acp-session-meta.ts) takes ordered layers: spec meta, then workspace rules (resolveSessionMeta), then Orca standing instructions. Later layers still win key by key, and the antigravity key is still merged one level deep. The one special case is antigravity.systemPrompt.append: the Antigravity server reads a single append string, so each layer's append is joined in order with a blank line (workspace rules first, then standing instructions). This is a targeted join, not a generic recursive merge.
  • acp-structured-handshake.ts no longer spreads _meta from setup. session/new and the reopen (session/resume/session/load) both build _meta through the helper. Reopen adds standing instructions only when sessionMetaOnReopen is set, as before.
  • The single-argument call in antigravity-sign-in-server.ts is unchanged in behavior.

Why

This fixes the dropped instructions at the one shared helper both handshake calls already use, instead of adding a second merge in the handshake. A generic recursive merge (with prototype-key guards) was considered and dropped: every layer is built inside Orca, and only systemPrompt.append needs combining, so a narrow join is simpler and easier to reason about. Host agy (no spec meta), Grok and Kiro (no _meta in setup) behave as before.

Linked Issue

Fixes #46367

Visual Proof

N/A. This changes the JSON _meta payload sent on ACP session/new / session/load, with no renderer or UI change. The behavior evidence (unit test before/after and a live server check) is 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

  • New test in acp-structured-session-instructions.test.ts checks the exact _meta on session/new and session/load when spec disabledTools, workspace rules and standing instructions are all present. On main it fails (the append is only Workspace rules.); on this branch it passes.

  • Targeted vitest (macOS): acp-structured-session-instructions, acp-structured-antigravity, and src/main/antigravity pass, except the existing process-spawning tests (posix-hook-invocation, antigravity-browser-helper) that fail locally for an unrelated environment reason (exit 69 from a local toolchain shim) and also fail on main.

  • Static gates clean on the touched files: oxlint, oxfmt, anti-slop oxlint, code-quality native plugins, ast-grep, and the changed-code quality gate.

  • Live check on a separate macOS machine against the pinned managed server (agy-acp-server 1.5.2, sha256 matching the pin in antigravity-acp-runtime.ts): session/new with disabledTools plus rules + "\n\n" + instructions was accepted, and the model repeated a marker from each part. This drove the server over raw ACP rather than through a full Orca bot session; the reopen path is covered by the unit test.

Performance

None, because acpSessionStartMeta runs once per ACP session open or reopen in the main process (not a hot path), with no new I/O, subprocesses, timers or polling. Node microbenchmark: typical case 0.034 us (main, instructions dropped) vs 0.67 us; no meta 0.013 vs 0.034 us; adversarial 88KB rules + 200KB instructions 27 us mean, 139 us max. Nothing comes near 16 ms.

Risk

Level: Low

  • Only _meta construction for ACP session/new, session/load and session/resume changes. The visible effect is that managed Antigravity system prompts now include the standing instructions, so they are longer (more tokens per turn). That is intended: on main those instructions were silently dropped. The workspace-rules part is unchanged (capped near 88KB).
  • When two layers both carry antigravity.systemPrompt, it is rebuilt as { append } only; no other systemPrompt subkeys exist today.
  • Back out with a plain revert; no saved data or settings are touched.

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.

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
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

Original fix by @Nanako0129 in #46368. Their authorship is preserved on the commit.

@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

The session metadata helper now merges multiple optional metadata layers in order. When both layers contain an Antigravity system-prompt append string, the helper joins the strings with a blank line. Structured-session initialization uses the helper for new-session requests and for reopen requests when sessionMetaOnReopen is enabled. Tests check merged metadata in both request types.

Severity of issue fixed: Medium

Merge Risk: Low · up to c796d

Metadata layers can still drop earlier instructions when a later layer holds an undefined entry or shares a nested record. The main case of combining workspace rules with standing instructions works. Fixing the merge helper before merge is a small change.

Pre-merge checks: Passed 4

Check name Status Explanation
Linked Issues check Passed [#46367] requires managed Antigravity standing instructions to reach ACP _meta on session/new, session/load, and session/resume, and requires GEMINI.md/AGENTS.md rules to combine with stan…
Out of Scope Changes check Passed The supplied whole-PR summary lists three changed files: src/main/acp/launch/acp-session-meta.ts, src/main/acp/session/acp-structured-session-instructions.test.ts, and `src/main/acp/session/start/…
Title check Passed The title names the main change: ACP session _meta layers are now merged so Antigravity keeps its standing instructions. It matches the raw summary (ordered layer merge in acpSessionStartMeta, handsha…
Description check Passed The description follows the repository template. It includes ELI5, What Changed, Why, Linked Issue (Fixes #46367), Visual Proof (N/A with reason), Testing with checkboxes, Performance (None, because .…
Full details: Linked Issues check

Explanation

[#46367] requires managed Antigravity standing instructions to reach ACP _meta on session/new, session/load, and session/resume, and requires GEMINI.md/AGENTS.md rules to combine with standing instructions in antigravity.systemPrompt.append.

At reviewed head c796de2, initializeAcpStructuredSession in acp-structured-handshake.ts no longer spreads _meta from setup. setup now holds only authMethodId, authMethodUnavailableMessage, and resumePreference. The new-session and replacement path calls acpSessionStartMeta(spec, meta, sessionMeta). The reopenIn path calls acpSessionStartMeta(spec, meta, reopenMeta), where reopenMeta is set only when launch.sessionMetaOnReopen is true. Grok and Kiro therefore keep non-reopen gating.

At head, acpSessionStartMeta in acp-session-meta.ts merges the layers spec.sessionMeta, meta, and the session layer in order. When two layers both supply string antigravity.systemPrompt.append, it joins them with \n\n. This satisfies the append-combining requirement. The single-argument call in antigravity-sign-in-server.ts remains valid.

Discrepancy: the PR description says the merge is recursive, skips __proto__, constructor, and prototype, and skips undefined values. The head code is a one-level top-level spread plus an antigravity-level merge. It has no prototype-key filter and no undefined filter. The issue does not require these behaviors, so they do not change this verdict. The description overstates the implementation.

The test file was not re-read at head, so the regression tests rest on the PR summary and the author's report. This review did not run tests.

Full details: Out of Scope Changes check

Explanation

The supplied whole-PR summary lists three changed files: src/main/acp/launch/acp-session-meta.ts, src/main/acp/session/acp-structured-session-instructions.test.ts, and src/main/acp/session/start/acp-structured-handshake.ts. All three are ACP session _meta construction or its regression tests, which serve #46367. The head contents of the two source files match this scope.

The incremental diff from previous reviewed head 2616bf3 to c796de2 could not be read. The whole-PR diff also could not be read, so no file list beyond the summary was confirmed. Changes after 2616bf3 are therefore established only through the head file reads and the summary. No unrelated change is demonstrated.

Full details: Title check

Explanation

The title names the main change: ACP session _meta layers are now merged so Antigravity keeps its standing instructions. It matches the raw summary (ordered layer merge in acpSessionStartMeta, handshake no longer overwrites _meta) and the PR objectives. It is 10 words and 80 characters, which is concise. It uses a conventional 'fix(acp):' prefix, which is acceptable.

Full details: Description check

Explanation

The description follows the repository template. It includes ELI5, What Changed, Why, Linked Issue (Fixes #46367), Visual Proof (N/A with reason), Testing with checkboxes, Performance (None, because ...), Risk with level Low and a revert plan, AI Disclosure, the agent skill boundary checkbox, and the Checklist. It explains the before and after behavior and the mechanism in detail. Minor gaps: the template's 'Review' and 'Notes' sections are left as template text or omitted, the 'Level' is stated only in the Risk section, and the final lint/typecheck/test/build checklist item is unchecked. These are non-critical, so the check passes.

  • 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

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

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: f9182f1f-bcad-493b-900c-7c31f4d08c9b
Commits

Reviewing files that changed from the base of the PR and between c326a2e and c62b405.

Files selected for processing: 3

  • src/main/acp/launch/acp-session-meta.ts
  • src/main/acp/session/acp-structured-session-instructions.test.ts
  • src/main/acp/session/start/acp-structured-handshake.ts

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

Comment thread src/main/acp/launch/acp-session-meta.ts Resolved
@Nanako0129

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor
Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

…nstructions

Managed Antigravity always sets spec.sessionMeta (disabledTools), and the
handshake spread setup._meta after the standing instructions, so bot and chat
standing instructions were silently dropped on session/new and on reopen.

Build _meta for session/new and the reopen through acpSessionStartMeta, which
now takes ordered layers (spec meta, workspace rules, standing instructions).
Later layers win key by key; the antigravity key merges one level deep and
every layer's systemPrompt.append is joined with a blank line, since the
Antigravity server reads a single append string.

Fixes stablyai#46367

Co-authored-by: Neil <[email protected]>
@nwparker
nwparker force-pushed the fix/merge-acp-session-meta branch from 2616bf3 to c796de2 Compare November 21, 2026 14:42
@nwparker nwparker changed the title fix(acp): merge layered session _meta instead of overwriting standing instructions fix(acp): merge layered session _meta so Antigravity keeps standing instructions Nov 21, 2026

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

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: 329ed1bd-ccbb-460d-8aad-b4239dc9354b
Commits

Reviewing files that changed from the base of the PR and between 2616bf3 and c796de2.

Files selected for processing: 2

  • src/main/acp/launch/acp-session-meta.ts
  • src/main/acp/session/acp-structured-session-instructions.test.ts

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

for (const layer of layers) {
const base = meta.antigravity
const added = layer?.antigravity
meta = { ...meta, ...layer }

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.

Minor · Data Integrity & Integration · Quick win

Skip undefined entries before applying a layer.

If earlier metadata contains workspace rules and the next layer contains { antigravity: undefined }, this spread removes those rules. The guard on Line 22 then skips append preservation.

Ignore undefined entries instead of assigning them. Add a regression that confirms an undefined entry preserves the earlier value, while a defined later value still takes precedence.


Minor · Data Integrity & Integration · Quick win

Merge nested metadata records recursively.

With spec.sessionMeta = { vendor: { a: 1 } } and a resolved layer { vendor: { b: 2 } }, Line 21 drops a. Line 24 also merges antigravity only shallowly. This violates the PR objective to preserve nested fields through recursive merging.

Merge records recursively. Preserve later-layer precedence for leaves, array replacement, and append concatenation. Add a regression that expects both nested fields.

Also applies to: 24-24

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.

[Bug]: Managed Antigravity chats drop standing instructions (SOUL.md / MEMORY.md / visuals) because setup._meta overwrites launch.sessionMeta

2 participants