Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(llm): hide Antigravity's reads of its saved tool output
Elian Dorane6cee3dbb16d
diff --git a/apps/server/src/services/llm/providers/antigravity_agent.spec.ts b/apps/server/src/services/llm/providers/antigravity_agent.spec.tsindex acb8201805..95029cc1ec 100644--- a/apps/server/src/services/llm/providers/antigravity_agent.spec.ts+++ b/apps/server/src/services/llm/providers/antigravity_agent.spec.ts@@ -359,8 +359,11 @@ describe("AntigravityAgentProvider tool calls", () => {const MCP_DIR = path.join(DATA_DIR, "antigravity-agent", "home", "antigravity-acp", "brain", "06ada25b", "mcp", "trilium");const TOKEN_FILE = path.join(DATA_DIR, "antigravity-agent", "home", "antigravity-acp", "acp_token.json");- it("hides the agent's reads of its own tool descriptions, and nothing else", async () => {+ it("hides the agent's reads of its own working files, and nothing else", async () => {+ const savedPage = path.join(DATA_DIR, "antigravity-agent", "home", "antigravity-acp", "brain", "f0c024c5", ".system_generated", "steps", "10", "content.md");FakeAcpClient.promptUpdates = [+ // Reading a fetched page the server saved, which the agent never completes: hidden, so it cannot end up "stopped".+ { sessionUpdate: "tool_call", toolCallId: "call_228152", title: "Running view_file", kind: "read", status: "in_progress", rawInput: { AbsolutePath: savedPage, StartLine: 1, EndLine: 60 } },// Listing the tool descriptions: hidden, and so is its completion.{ sessionUpdate: "tool_call", toolCallId: "06ada25b:2", title: "Running list_directory", kind: "search", status: "in_progress", locations: [{ path: MCP_DIR }], rawInput: { directory_path: MCP_DIR } },{ sessionUpdate: "tool_call_update", toolCallId: "06ada25b:2", status: "completed", rawOutput: "List trilium MCP tools" },diff --git a/apps/server/src/services/llm/providers/antigravity_agent.ts b/apps/server/src/services/llm/providers/antigravity_agent.tsindex dbb4d57317..27818595d3 100644--- a/apps/server/src/services/llm/providers/antigravity_agent.ts+++ b/apps/server/src/services/llm/providers/antigravity_agent.ts@@ -153,13 +153,13 @@ export class AntigravityAgentProvider extends AcpAgentProvider {}/**- * The agent writes a description of every MCP tool to- * `<home>/antigravity-acp/brain/<session>/mcp/<server>/<tool>.json` and reads- * them with its own file tools before calling one. Those reads are how it- * looks a tool up, not work on the user's behalf.+ * The agent reads its own working files with its file tools: the+ * description of an MCP tool before calling it, and the saved output of a+ * long tool result such as a fetched page. Those reads are how it follows+ * its own tools, not work on the user's behalf.*/protected isInternalToolCall(update: AcpToolCallUpdate): boolean {- return isToolDescriptionAccess(update, agentHome());+ return isWorkingFileAccess(update, agentHome());}/**@@ -291,11 +291,13 @@ export function resolveAntigravityModel(model: string, effort: LlmReasoningEffor}/**- * Whether a built-in tool call only touches the agent's tool descriptions:- * every path it names lies under `<home>/antigravity-acp/brain/<session>/mcp/`.- * Anything else in the home, such as the sign-in token, does not qualify.+ * Whether a built-in tool call only touches the agent's working files: every+ * path it names lies under `<home>/antigravity-acp/brain/<session>/`, where the+ * server keeps the tool descriptions (`mcp/`) and the output of long tool+ * results, such as a fetched page (`.system_generated/`). Anything else in the+ * home, such as the sign-in token, does not qualify.*/-export function isToolDescriptionAccess(update: AcpToolCallUpdate, home: string): boolean {+export function isWorkingFileAccess(update: AcpToolCallUpdate, home: string): boolean {if (update._meta && (update._meta as { is_mcp_tool_call?: unknown }).is_mcp_tool_call === true) {return false;}@@ -305,7 +307,7 @@ export function isToolDescriptionAccess(update: AcpToolCallUpdate, home: string)].filter((value): value is string => typeof value === "string" && path.isAbsolute(value));return paths.length > 0 && paths.every(candidate => {const segments = path.relative(home, path.resolve(candidate)).split(path.sep);- return segments[0] === "antigravity-acp" && segments[1] === "brain" && segments[3] === "mcp";+ return segments[0] === "antigravity-acp" && segments[1] === "brain" && segments.length > 3;});}