Skip to content

feat(acp): chat agents can run with their own temp folder, cleared when they exit - #28462

Merged
brennanb2025 merged 1 commit into
mainfrom
brennanb2025/agy-chat-3-private-temp
Oct 16, 2026
Merged

brennanb2025 merged 1 commit into
mainfrom
brennanb2025/agy-chat-3-private-temp

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​29 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​29
Prod 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​61 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​60

ELI5

Antigravity's chat needs a separate program, its chat server, which Orca downloads for it. When chats fetched that program on their own, the first chat sat on "Working for Ns" for about 18 seconds with no progress and no way to cancel, and opening several chats started several downloads. This stack changes that: nothing downloads until the person clicks Install, with progress and Cancel in Settings and in the chat.

This PR handles a second cost of running that server. Every time it starts, it unpacks itself, about 1 GB, into the computer's temp folder. If the server is killed instead of exiting normally, that copy stays there for good. With this PR an agent can ask Orca for a temp folder of its own for each run, inside Orca's data folder, so Orca can clean up whatever a run leaves behind.

What Changed

  • Before: Agent Client Protocol (ACP) agents always used the shared system temp folder. A killed process's leftovers stayed there, and Orca could not tell whose they were.
  • After: an ACP launch spec can set privateTempDirectory: true. Then:
    • Each start gets a new folder <Orca data folder>/acp-temp/<agent>/run-XXXXXX (created exclusively, never reused), and the agent's TMPDIR, TEMP and TMP point at it.
    • The folder is removed when that agent process exits, and also if the start is cancelled or fails before the process starts.
    • The first start of that agent after the Orca host starts removes the whole acp-temp/<agent> folder first, which clears anything a killed process left behind.
    • Removal is best effort and logged; it never blocks a chat. Windows can hold a file open briefly after a kill; the next host start removes what stayed.
  • Agents without the flag start exactly as before: no new wait between Orca's last cancellation check and the process start.
  • Merged alone: nothing changes for anyone. Antigravity (feat(acp): Antigravity in the Chat UI over its ACP server #28595) is the first agent to set the flag.

Why

Clearing the whole folder at host start is safe because Orca talks to these agents over their standard input and output: a process left over from an earlier Orca run can never be reconnected, so nothing can still be using its files. Only one Orca host runs per data folder, and the system temp folder is never touched. One folder per process keeps one run's cleanup from deleting files another run still reads.

The alternative, keeping folders until a reboot could be proven, needs boot-identity records and keeps growing edge cases; this design needs none.

Linked Issue

N/A (maintainer; part of the stack that adds Antigravity to chat).

Visual Proof

N/A: no agent sets the flag yet, so nothing visible changes in this PR.

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • One test through the existing ACP adapter rig: a leftover run folder is cleared at the first start, the child gets an existing run-* folder as TMPDIR/TEMP/TMP, and that folder is gone after the child exits.

  • pnpm tc:node and all 341 ACP tests pass. The real Antigravity server is exercised in the PR that adds it (feat(acp): Antigravity in the Chat UI over its ACP server #28595).

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

  • SSH / remote hosts: the folder lives in the data folder of the host that runs the agent. Plain SSH and WSL launches are refused for ACP agents as before.
  • Windows: long data-folder paths add about 24 characters to the paths the agent unpacks under; not yet measured with the real server.
  • Stack: based on main, which now has feat(acp): chat agents can declare a managed runtime that a start runs but never installs #28460 (merged: a chat start runs an installed program Orca provides, never downloads it).
  • PR author: @BrennanKB5

Differences from the common pattern

  • Intended: the leftover-folder sweep runs at the first start of the agent in this host process rather than when the provider is constructed; the invariant is the same (no process of that agent exists yet), and a host that never starts the agent never touches the folder.
  • Intended: the per-process temp folders live under one generic folder per agent in Orca's data directory rather than a hashed per-instance folder; Orca's chats of one agent share one account root per host.
  • Intended: TMPDIR, TEMP and TMP are all set on every platform instead of only the platform's own variable; the extra variables are ignored where unused.
  • Intended: the folder is removed when the child process is seen to exit, rather than when the owning scope closes; removal stays best effort and the next first start sweeps what remains.

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)
  • 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)

@brennanb2025

Copy link
Copy Markdown
Contributor Author

A bundled chat server can leave a large extracted copy in system temp when it is force-killed. This rebuilt PR gives an opted-in agent a fresh private folder for each process, sets its temp environment variables, removes that folder best-effort on exit or a cancelled/failed start, and clears earlier leftovers before that agent's first start in each host process.

Reviewed commit 036c13a3cb8 against the managed-runtime stack base. The architecture challenger, adversarial correctness review, final readiness review, and dedicated performance/resource scan found no proven defects within the approved design. No source fixes or deferred functional findings remain from this review. No current agent enables the flag, so existing chats keep their tabs, setup, focus, status, and notices.

Validation: 341 ACP tests passed across 41 files under Node. Local static checks passed 22/23; normal typecheck passed, while typecheck:ci failed because the installed Bun 1.3.14 cannot run the repository's pinned 1.4.3 command. GitHub CI passed every non-skipped check, including static analysis/typecheck, both packaging jobs, relay integration, all five Node 24 test shards, selection evidence and final verify (CI run).

Electron QA is N/A because the flag has no production consumer. Real bundled-agent runs and native Windows/Linux/SSH execution were not tested here; large-tree first-start latency and Windows delayed-handle cleanup remain unmeasured and should be exercised when an agent enables this path. No merge or rebase was performed.

@brennanb2025 brennanb2025 changed the title feat(acp): chat agents can run with a private temp folder, reclaimed only on proof feat(acp): chat agents can run with their own temp folder, cleared when they exit Oct 14, 2026
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-2-managed-runtime branch from 326badf to cb90367 Compare October 14, 2026 17:32
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-3-private-temp branch from 036c13a to d9f69b7 Compare October 14, 2026 17:32
@brennanb2025
brennanb2025 marked this pull request as ready for review October 14, 2026 17:54
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-2-managed-runtime branch from cb90367 to 2c93757 Compare October 15, 2026 06:08
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-3-private-temp branch from d9f69b7 to 0b238ba Compare October 15, 2026 06:11
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-2-managed-runtime branch from 2c93757 to afbbbaf Compare October 15, 2026 06:13
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-3-private-temp branch from 0b238ba to 1d09719 Compare October 15, 2026 06:13
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-2-managed-runtime branch from afbbbaf to 101a7d2 Compare October 15, 2026 06:18
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-3-private-temp branch 2 times, most recently from e7e1d04 to d35f207 Compare October 15, 2026 13:33
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-2-managed-runtime branch from d147816 to f88b5de Compare October 15, 2026 14:23
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-3-private-temp branch from d35f207 to 37e6a6f Compare October 15, 2026 14:24
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-3-private-temp branch from 37e6a6f to 6fefe39 Compare October 15, 2026 19:57
@brennanb2025
brennanb2025 changed the base branch from brennanb2025/agy-chat-2-managed-runtime to main October 15, 2026 21:17
@brennanb2025
brennanb2025 force-pushed the brennanb2025/agy-chat-3-private-temp branch from 6fefe39 to 6b936b2 Compare October 15, 2026 21:20
@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3a652be3-e2bf-4779-b447-d65b6f30adbd
📥 Commits

Reviewing files that changed from the base of the PR and between 76735ed and 6b936b2.

📒 Files selected for processing: 7
  • src/main/acp/acp-launch-specs.ts
  • src/main/acp/acp-private-temp.ts
  • src/main/acp/acp-structured-acquire.ts
  • src/main/acp/acp-structured-adapter.test-support.ts
  • src/main/acp/acp-structured-private-temp.test.ts
  • src/main/acp/acp-structured-session-adapter-deps.ts
  • src/main/runtime/structured-agent-runtime-registrations.ts

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

📝 Walkthrough

The ACP launch specification adds an optional flag for private temporary directories. When enabled, the adapter clears the agent temp root, creates a unique run folder, sets the child’s TMPDIR, TEMP, and TMP variables, and removes the folder after connection exit or setup failure. The adapter receives its data directory from runtime registration. A lifecycle test checks folder cleanup and the child’s temp environment.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 6b936

This adds an opt-in private temp folder for ACP agents. No current agent uses it, so existing chats are unaffected, and no merge-blocking risk is identified.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 7 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
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.
Title check Passed The title clearly and concisely describes the main change: ACP agents receive isolated temporary folders that are cleaned up when they exit.
Description check Passed The description includes all required sections and clearly explains the user impact, implementation, rationale, testing, platform considerations, and limitations. It also identifies the change as main…
  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • 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

Comment @coderabbitai help to get the list of available commands.

@brennanb2025
brennanb2025 merged commit f06404d into main Oct 16, 2026
30 checks passed
@brennanb2025
brennanb2025 deleted the brennanb2025/agy-chat-3-private-temp branch October 16, 2026 01:13
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