feat(ai/providers): added forced tool directive for antigravity gemini routes

- Added a markdown template defining a tool-only turn directive for Gemini models.
- Appended the forced tool directive to request contents when using Antigravity Gemini routes with forced tool mode.
This commit is contained in:
can1357
2026-08-12 00:58:25 +02:00
parent 93fed035f6
commit 78ef4f6bb9
2 changed files with 9 additions and 0 deletions
@@ -0,0 +1 @@
TOOL-ONLY TURN. This turn accepts a tool call and nothing else; a text reply here is discarded unread and you will be re-prompted. Emit the tool call now.
@@ -14,6 +14,7 @@ import {
getGeminiCliHeaders,
} from "@oh-my-pi/pi-catalog/wire/gemini-headers";
import { extractHttpStatusFromError, fetchWithRetry, readSseJson } from "@oh-my-pi/pi-utils";
import forcedToolDirective from "./google-antigravity-forced-tool.md" with { type: "text" };
import * as AIError from "../error";
import type {
Api,
@@ -1347,6 +1348,13 @@ export function buildRequest(
},
};
}
// Cloud Code Assist drops `toolConfig` on Antigravity's Gemini routes:
// the backend answers in text under `mode: "ANY"` and still emits calls
// under `"NONE"`. Claude routes implement it, so only Gemini needs the
// forced choice restated in the transcript.
if (isAntigravity && !isClaudeModel(model.id) && request.toolConfig?.functionCallingConfig.mode === "ANY") {
contents.push({ role: "user", parts: [{ text: forcedToolDirective }] });
}
}
// Antigravity's default tool mode is VALIDATED (verified for Gemini and
// Claude); an explicit non-auto tool choice above wins.