Skip to content

Build your personal knowledge base with Trilium Notes

feat(llm): show Antigravity's web search as "Web search" in the chat

Elian Doran09d4df5f1c3f
diff --git a/apps/server/src/services/llm/providers/acp_agent.ts b/apps/server/src/services/llm/providers/acp_agent.ts
index f6199c3da6..2c72cd7e72 100644
--- a/apps/server/src/services/llm/providers/acp_agent.ts
+++ b/apps/server/src/services/llm/providers/acp_agent.ts
@@ -201,6 +201,14 @@ export abstract class AcpAgentProvider implements LlmProvider {
return false;
}
+ /**
+ * The chat's name for a built-in tool call it has a label for, such as
+ * `web_search`; undefined shows the call's title. Display only.
+ */
+ protected builtInToolName(_update: AcpToolCallUpdate): string | undefined {
+ return undefined;
+ }
+
/** Map a failure to an actionable message. */
protected describeFailure(error: unknown): string {
return describeError(error);
@@ -333,7 +341,7 @@ export abstract class AcpAgentProvider implements LlmProvider {
wakeup?.();
};
- const collector = createUpdateCollector(emit, update => this.isInternalToolCall(update));
+ const collector = createUpdateCollector(emit, update => this.isInternalToolCall(update), update => this.builtInToolName(update));
let client: AcpClient | undefined;
let sessionId: string | undefined;
let sessionModels: AcpSessionModelState | undefined;
@@ -626,9 +634,14 @@ export function denyPermission(request: AcpPermissionRequest, logLabel: string):
* pushes them through `emit`. `muted` suppresses the replay flood during
* session/load; `sessionId` filters stray updates from other sessions.
* `isHidden` keeps a tool call, and with it every update for that call, out
- * of the chat.
+ * of the chat. `nameTool` names a built-in tool call the chat has a label for;
+ * a call it leaves unnamed shows its title.
*/
-export function createUpdateCollector(emit: (chunk: LlmStreamChunk) => void, isHidden?: (update: AcpToolCallUpdate) => boolean) {
+export function createUpdateCollector(
+ emit: (chunk: LlmStreamChunk) => void,
+ isHidden?: (update: AcpToolCallUpdate) => boolean,
+ nameTool?: (update: AcpToolCallUpdate) => string | undefined
+) {
// toolCallId → display name, for labelling results; also the guard that
// only this turn's tool calls produce result chunks.
const toolNamesById = new Map<string, string>();
@@ -665,7 +678,7 @@ export function createUpdateCollector(emit: (chunk: LlmStreamChunk) => void, isH
break; // malformed, a re-announcement of a known call, or hidden
}
const mcpTool = mcpToolName(update._meta);
- const toolName = mcpTool ?? (update.title || "tool");
+ const toolName = mcpTool ?? nameTool?.(update) ?? (update.title || "tool");
toolNamesById.set(update.toolCallId, toolName);
emit({
type: "tool_use",
diff --git a/apps/server/src/services/llm/providers/antigravity_agent.spec.ts b/apps/server/src/services/llm/providers/antigravity_agent.spec.ts
index 1c3e05fbba..b5085bb4c8 100644
--- a/apps/server/src/services/llm/providers/antigravity_agent.spec.ts
+++ b/apps/server/src/services/llm/providers/antigravity_agent.spec.ts
@@ -355,6 +355,21 @@ describe("AntigravityAgentProvider tool calls", () => {
const chunks = await collect(new AntigravityAgentProvider().chatChunks([{ role: "user", content: "hi" }], { enableNoteTools: true }));
expect(chunks.filter(c => c.type === "tool_use" || c.type === "tool_result").map(c => c.toolCallId)).toEqual(["call_token", "call_token", "cf21", "cf21"]);
});
+
+ it("names the web search like the other providers do, and nothing the model titled after it", async () => {
+ FakeAcpClient.promptUpdates = [
+ { sessionUpdate: "tool_call", toolCallId: "7bba", title: "Run search_web?", kind: "search", status: "pending", rawInput: { query: "weather Sibiu today" } },
+ { sessionUpdate: "tool_call_update", toolCallId: "7bba", status: "completed", rawOutput: "Sunny" },
+ { sessionUpdate: "tool_call", toolCallId: "sh1", title: "Run search_web?", kind: "execute", status: "pending", rawInput: { CommandLine: "Run search_web?" } }
+ ];
+
+ const chunks = await collect(new AntigravityAgentProvider().chatChunks([{ role: "user", content: "hi" }], { enableWebSearch: true }));
+ expect(chunks.filter(c => c.type === "tool_use" || c.type === "tool_result")).toEqual([
+ { type: "tool_use", toolCallId: "7bba", toolName: "web_search", toolInput: { query: "weather Sibiu today" } },
+ { type: "tool_result", toolCallId: "7bba", toolName: "web_search", result: "Sunny", isError: false },
+ { type: "tool_use", toolCallId: "sh1", toolName: "Run search_web?", toolInput: { CommandLine: "Run search_web?" } }
+ ]);
+ });
});
describe("buildAntigravityModelList", () => {
diff --git a/apps/server/src/services/llm/providers/antigravity_agent.ts b/apps/server/src/services/llm/providers/antigravity_agent.ts
index 5737b48475..5231c4f029 100644
--- a/apps/server/src/services/llm/providers/antigravity_agent.ts
+++ b/apps/server/src/services/llm/providers/antigravity_agent.ts
@@ -157,6 +157,11 @@ export class AntigravityAgentProvider extends AcpAgentProvider {
return isToolDescriptionAccess(update, agentHome());
}
+ /** The web search, under the name the other providers' searches carry. */
+ protected builtInToolName(update: AcpToolCallUpdate): string | undefined {
+ return isWebSearch(update) ? "web_search" : undefined;
+ }
+
/**
* Open a session, signing in first when the server has no saved sign-in and
* the user is on the add-provider screen to complete it. The server opens
@@ -220,9 +225,8 @@ export function decideAntigravityPermission(
const meta = toolCall?._meta;
const mcp = meta?.mcp as { server?: unknown } | undefined;
const isNoteTool = meta?.is_mcp_tool_call === true && mcp?.server === NOTE_TOOLS_MCP_SERVER_NAME;
- const isWebSearch = toolCall?.kind === "search" && toolCall.title === "Run search_web?";
const allowOnce = request.options?.find(o => o.kind === "allow_once");
- if ((isNoteTool || (webSearch && isWebSearch)) && allowOnce) {
+ if ((isNoteTool || (webSearch && isWebSearch(toolCall))) && allowOnce) {
return { outcome: { outcome: "selected", optionId: allowOnce.optionId } };
}
return denyPermission(request, logLabel);
@@ -395,6 +399,15 @@ function agentHome(): string {
return path.resolve(dataDirs.TRILIUM_DATA_DIR, "antigravity-agent", "home");
}
+/**
+ * Whether a tool call or permission request is the server's web search: the
+ * kind `search` with the title the server gives it, `Run search_web?` while it
+ * waits for permission and `Running search_web` once it runs.
+ */
+function isWebSearch(toolCall: { kind?: string; title?: string } | undefined): boolean {
+ return toolCall?.kind === "search" && /^Run(?:ning)? search_web\??$/.test(toolCall.title ?? "");
+}
+
function isSignInRequired(error: unknown): boolean {
return error instanceof AcpError && error.code === -32000 && /authentication required/i.test(error.message);
}