Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/web/src/app/setup/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1740,7 +1740,8 @@ export default function SetupPage() {
setGeminiError("");
}}
onPaste={(e) => {
const pasted = e.clipboardData.getData("text");
e.preventDefault();
const pasted = e.clipboardData.getData("text").trim();
if (pasted) {
setGeminiKey(pasted);
setGeminiValidated(false);
Expand Down
9 changes: 9 additions & 0 deletions packages/agent-adapters/src/gemini.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ export class GeminiAdapter implements AgentAdapter {
OPTIO_PROMPT: prompt,
OPTIO_AGENT_TYPE: "gemini",
OPTIO_BRANCH_NAME: `${TASK_BRANCH_PREFIX}${input.taskId}`,
// Ensure the CLI doesn't prompt for trust in isolated ephemeral pods
GEMINI_CLI_TRUST_WORKSPACE: "true",
};

const requiredSecrets: string[] = [];
Expand Down Expand Up @@ -164,6 +166,13 @@ export class GeminiAdapter implements AgentAdapter {
let hasError = false;
let lastAssistantMessage: string | undefined;

// Check for JSON error messages embedded in non-JSON output
const apiKeyErrorMatch = logs.match(/API key not valid|API_KEY_INVALID/i);
if (apiKeyErrorMatch) {
errorMessage = "API key not valid. Please pass a valid API key.";
hasError = true;
}

for (const line of logs.split("\n")) {
if (!line.trim()) continue;

Expand Down
12 changes: 12 additions & 0 deletions packages/shared/src/error-classifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,18 @@ const ERROR_PATTERNS: Array<{
retryable: true,
}),
},
{
pattern: /API key not valid|API_KEY_INVALID/i,
classify: () => ({
category: "auth",
title: "Invalid API key",
description:
"The provided API key is invalid. This can affect Gemini, Anthropic, or OpenAI depending on which agent was running.",
remedy:
"Go to Secrets and verify your API keys (GEMINI_API_KEY, ANTHROPIC_API_KEY, etc.) are valid and have not been revoked.",
retryable: false,
}),
},
{
pattern: /exit code: (\d+)/i,
classify: (match) => ({
Expand Down
Loading