Skip to content

[Bug]: Antigravity runs shell commands in ~/.t3/userdata/attachments instead of the thread workspace #37908

Closed

Description

@yanhao98

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

Antigravity threads run their shell in ~/.t3/userdata/attachments, not in the thread's workspace. Ask any Antigravity thread for pwd and it answers with the attachments directory; any relative-path command writes there.

Root cause: AntigravityAdapterV2.ts:150 sends the attachments directory as additionalDirectories on session/new:

additionalDirectories: [options.host.paths.attachmentsDir],

The ACP schema T3 ships with says that field must not move the cwd:

Additional workspace roots for this session. Each path must be absolute.
These expand the session's workspace scope without changing cwd, which
remains the base for relative paths.

The Antigravity CLI (agy 1.5.9) does not honor that. It merges cwd and additionalDirectories into one root set and runs run_command in the lexicographically smallest path of that set. Since .t3/ sorts before projects/, the attachments directory wins for essentially every project path.

Minimal ACP-only repro (one real turn per run, no T3 checkout needed):

// repro.mjs — node repro.mjs <workspaceDir> <extraDir> [with|without]
import { spawn } from "node:child_process";
const [CWD, EXTRA] = process.argv.slice(2);
const withExtra = process.argv[4] !== "without";

const child = spawn("agy", ["acp"], { cwd: CWD, stdio: ["pipe", "pipe", "pipe"] });
let buf = "", id = 0, out = [];
const pending = new Map();
const call = (method, params) => {
  const myId = ++id;
  child.stdin.write(JSON.stringify({ jsonrpc: "2.0", id: myId, method, params }) + "\n");
  return new Promise((r) => pending.set(myId, r));
};
child.stdout.on("data", (d) => {
  buf += d;
  let i;
  while ((i = buf.indexOf("\n")) >= 0) {
    const line = buf.slice(0, i); buf = buf.slice(i + 1);
    if (!line.trim()) continue;
    let m; try { m = JSON.parse(line); } catch { continue; }
    if (m.id !== undefined && pending.has(m.id)) { pending.get(m.id)(m); pending.delete(m.id); continue; }
    if (m.method === "session/request_permission") {
      const o = (m.params?.options ?? []).find((x) => /allow/i.test(x.optionId ?? "")) ?? m.params?.options?.[0];
      child.stdin.write(JSON.stringify({ jsonrpc: "2.0", id: m.id, result: { outcome: { outcome: "selected", optionId: o?.optionId } } }) + "\n");
    } else if (m.method === "session/update" && m.params?.update?.sessionUpdate === "tool_call_update") {
      for (const c of [].concat(m.params.update.content ?? [])) out.push(String(c.text ?? ""));
    }
  }
});

await call("initialize", { protocolVersion: 1, clientCapabilities: {} });
const params = { cwd: CWD, mcpServers: [] };
if (withExtra) params.additionalDirectories = [EXTRA];
const { result } = await call("session/new", params);
await call("session/prompt", { sessionId: result.sessionId, prompt: [{ type: "text", text: "Run pwd and reply with only its output." }] });
await new Promise((r) => setTimeout(r, 1500));
child.kill();
console.log(withExtra ? "WITH" : "WITHOUT", "additionalDirectories ->", out.join("").match(/Command output:\s*(.*)/)?.[1]?.trim());

Run it twice against a real workspace and its attachments directory:

$ node repro.mjs /home/devel/projects/try /home/devel/.t3/userdata/attachments without
WITHOUT additionalDirectories -> /home/devel/projects/try

$ node repro.mjs /home/devel/projects/try /home/devel/.t3/userdata/attachments with
WITH additionalDirectories -> /home/devel/.t3/userdata/attachments

To confirm the selection rule is the lexicographic minimum rather than "first extra directory", add unrelated directories on a plain agy CLI run started from /home/devel/projects/try:

agy --add-dir /tmp        -p "pwd"   -> /home/devel/projects/try    (home... < tmp)
agy --add-dir /etc        -p "pwd"   -> /etc                        (etc    < home)
agy --add-dir /var        -p "pwd"   -> /home/devel/projects/try    (home   < var)
agy --add-dir /home/devel -p "pwd"   -> /home/devel
agy --add-dir /home/devel/aaa --add-dir /home/devel/projects/zzz -p "pwd" -> /home/devel/aaa

Order of the flags does not matter; a longer path still wins if it sorts first.

Expected behavior

The thread's workspace stays the base for relative paths, as the ACP field documentation requires. pwd returns the project root, and relative writes land inside the checkout.

Actual behavior

The shell starts in ~/.t3/userdata/attachments:

$ pwd
/home/devel/.t3/userdata/attachments

That directory is empty, so ls shows nothing and the model can conclude the workspace is empty. Relative writes go there:

run_command: echo hello > relative-probe.txt
$ cat /home/devel/.t3/userdata/attachments/relative-probe.txt
hello
$ ls /home/devel/projects/try/relative-probe.txt
No such file or directory

Meanwhile T3's own state records the correct directory, so the mismatch is not visible in the thread:

// orchestration_v2_projection_provider_sessions.payload_json
"cwd": "/home/devel/projects/try"

// agy's conversation metadata for the same session
"workspace_uris": ["file:///home/devel/.t3/userdata/attachments",
                   "file:///home/devel/projects/try"]

Every Antigravity thread in a project is affected. In 9 Antigravity threads on this machine, 8 have the attachments directory first in agy's root list; the one that escaped was a Scratch thread, whose root is ~/.t3/scratch/<name> and sorts before ~/.t3/userdata/. Threads overpi are unaffected because they use their own shell rather than agy's.

The failure is quiet but has a second-order effect: agents that hit an unexpected empty directory work around it with absolute paths and explicit cd. One 172-step thread on this machine used 44 absolute or cd commands and only 1 relative command. The behaviour looks like a cautious agent rather than a broken cwd.

Impact

Major degradation or frequent failure

Version or commit

main @ e9d5bae (also present in the released t3 v0.1.9 bundle)

Environment

Linux (aarch64), t3 0.1.9 server, agy (Antigravity CLI) 1.5.9, model gemini-3.8-flash, runtime mode full-access.

Logs or stack traces

# Antigravity thread, user prompt "pwd"
turn-item command_execution  input="pwd"
  output="Command exited with code 0. Command output:
          /home/devel/.t3/userdata/attachments"

# agy conversation db for that session (conversation_summaries.workspace_uris)
["file:///home/devel/.t3/userdata/attachments","file:///home/devel/projects/try"]

Workaround

Agents can pass absolute paths or cd into the workspace first, which is what they do today. Forcing every turn to start with cd <workspace> would mask it but would not fix it.

A code-level workaround on the T3 side would be to keep the attachments directory out of additionalDirectories for Antigravity and let the existing client file-read roots (antigravityClientFileRoots, which already lists both directories) serve attachment reads, since those run through T3's fs/read_text_file handler rather than agy's shell.

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

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