Minimal failure isolation script
Use a small script to prove the API key and agent surface work before debugging a large repository task:
import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI({
apiKey: process.env.GEMINI_API_KEY,
});
try {
const response = await ai.interactions.create({
agent: "antigravity-preview-05-2026",
input: "Reply with one sentence confirming the agent can receive this task.",
environment: { type: "remote" },
});
console.log({
id: response.id,
environmentId: response.environment_id,
text: response.output_text,
});
} catch (error) {
console.error(error);
}
Error patterns to check first
401 unauthorized
Your key is missing, invalid, blocked, or loaded from the wrong environment. Print whether the variable exists without printing the key:
console.log(Boolean(process.env.GEMINI_API_KEY));
Unknown agent
Do not assume the preview ID is permanent. Check the latest Antigravity Agent docs and update the agent value in configuration.
previous_interaction_id not found
This usually means you passed the wrong ID, used a different account or project, disabled storage, or tried to continue an expired interaction.
environment not found
Check whether the environment ID came from the same response and whether it is still valid. If in doubt, start a new environment and reproduce the task.
Task timeout
Ask for a plan first, then ask for one file or one patch. Broad prompts are harder to debug because they hide whether the failure is access, state, or task complexity.