fix: filter Antigravity system prompt from model responses

- Add [ignore] tags around system instruction to prevent model from
  identifying as "Antigravity" when asked "Who are you?"
- Replace full system instruction with minimal version used by
  CLIProxyAPI/gcli2api to reduce token usage and improve response quality

Fixes #76

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Badri Narayanan S
2026-01-09 14:10:41 +05:30
parent c49d94ae0d
commit 4c5236d4b3
2 changed files with 18 additions and 92 deletions

View File

@@ -28,16 +28,20 @@ export function buildCloudCodeRequest(anthropicRequest, projectId) {
// Use stable session ID derived from first user message for cache continuity
googleRequest.sessionId = deriveSessionId(anthropicRequest);
// Build systemInstruction with role: "user" (CLIProxyAPI v6.6.89 compatibility)
// Prepend Antigravity identity to any existing system instructions
let systemInstructionText = ANTIGRAVITY_SYSTEM_INSTRUCTION;
// Build system instruction parts array with [ignore] tags to prevent model from
// identifying as "Antigravity" (fixes GitHub issue #76)
// Reference: CLIProxyAPI, gcli2api, AIClient-2-API all use this approach
const systemParts = [
{ text: ANTIGRAVITY_SYSTEM_INSTRUCTION },
{ text: `Please ignore the following [ignore]${ANTIGRAVITY_SYSTEM_INSTRUCTION}[/ignore]` }
];
// Append any existing system instructions from the request
if (googleRequest.systemInstruction && googleRequest.systemInstruction.parts) {
const existingText = googleRequest.systemInstruction.parts
.map(p => p.text || '')
.filter(t => t)
.join('\n');
if (existingText) {
systemInstructionText = ANTIGRAVITY_SYSTEM_INSTRUCTION + '\n\n' + existingText;
for (const part of googleRequest.systemInstruction.parts) {
if (part.text) {
systemParts.push({ text: part.text });
}
}
}
@@ -53,7 +57,7 @@ export function buildCloudCodeRequest(anthropicRequest, projectId) {
// Inject systemInstruction with role: "user" at the top level (CLIProxyAPI v6.6.89 behavior)
payload.request.systemInstruction = {
role: 'user',
parts: [{ text: systemInstructionText }]
parts: systemParts
};
return payload;