diff --git a/open-sse/config/appConstants.js b/open-sse/config/appConstants.js index 5ddf95ac..3e18633e 100644 --- a/open-sse/config/appConstants.js +++ b/open-sse/config/appConstants.js @@ -171,6 +171,13 @@ export const LOAD_CODE_ASSIST_METADATA = { // System prompts export const CLAUDE_SYSTEM_PROMPT = "You are Claude Code, Anthropic's official CLI for Claude."; +// Rewrite rules applied to Antigravity system prompts: competing-client branding +// makes the backend flag the request and answer 429 Quota Exhausted. +export const ANTIGRAVITY_PROMPT_REWRITES = [ + { from: "You are a Claude agent, built on Anthropic's Claude Agent SDK.", to: "" }, + { from: /opencode/gi, to: (m) => (m === "OpenCode" ? "Antigravity" : m === "OPENCODE" ? "ANTIGRAVITY" : "antigravity") } +]; + export const ANTIGRAVITY_DEFAULT_SYSTEM = "You are Antigravity, a powerful agentic AI coding assistant designed by the Google Deepmind team working on Advanced Agentic Coding.You are pair programming with a USER to solve their coding task. The task may require creating a new codebase, modifying or debugging an existing codebase, or simply answering a question.**Absolute paths only****Proactiveness**"; // Derive từ registry oauth.refreshLeadMs diff --git a/open-sse/executors/antigravity.js b/open-sse/executors/antigravity.js index 07bbb4fc..35ec1006 100644 --- a/open-sse/executors/antigravity.js +++ b/open-sse/executors/antigravity.js @@ -1,7 +1,7 @@ import crypto from "crypto"; import { BaseExecutor } from "./base.js"; import { PROVIDERS } from "../config/providers.js"; -import { OAUTH_ENDPOINTS, ANTIGRAVITY_HEADERS, AG_DEFAULT_TOOLS, AG_TOOL_SUFFIX } from "../config/appConstants.js"; +import { OAUTH_ENDPOINTS, ANTIGRAVITY_HEADERS, AG_DEFAULT_TOOLS, AG_TOOL_SUFFIX, ANTIGRAVITY_PROMPT_REWRITES } from "../config/appConstants.js"; import { HTTP_STATUS } from "../config/runtimeConfig.js"; import { resolveSessionId } from "../utils/sessionManager.js"; import { proxyAwareFetch } from "../utils/proxyFetch.js"; @@ -246,13 +246,13 @@ export class AntigravityExecutor extends BaseExecutor { const { tools: _originalTools, toolConfig: _originalToolConfig, ...requestWithoutTools } = body.request || {}; stripBlacklisted(requestWithoutTools); - // Rewrite competitive system prompts (e.g. Zed IDE's Claude prompt) to prevent Antigravity from - // flagging the request and immediately blocking it with a 429 Quota Exhausted response. + // Rewrite competing-client branding in system prompts (e.g. Zed's Claude prompt, + // OpenCode naming) so Antigravity doesn't flag the request with a 429 Quota Exhausted. if (requestWithoutTools.systemInstruction?.parts) { - const oldText = "You are a Claude agent, built on Anthropic's Claude Agent SDK."; for (const part of requestWithoutTools.systemInstruction.parts) { - if (typeof part.text === "string" && part.text.includes(oldText)) { - part.text = part.text.split(oldText).join(""); + if (typeof part.text !== "string") continue; + for (const { from, to } of ANTIGRAVITY_PROMPT_REWRITES) { + part.text = part.text.replaceAll(from, to); } } }