fix(cursor): use real API key instead of dummy spawn-proxy value (#3169)

Cursor CLI validates CURSOR_API_KEY before connecting to the configured
endpoint. The dummy value "spawn-proxy" fails validation immediately,
causing an infinite restart loop. Use the actual OPENROUTER_API_KEY as
CURSOR_API_KEY so it passes Cursor's key format check.

Fixes #3166

Agent: ux-engineer

Co-authored-by: B <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
A 2026-04-03 17:54:38 -07:00 committed by GitHub
parent 8e9af23c63
commit 7292ddef0e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 2 deletions

View file

@ -299,7 +299,8 @@
"install": "curl https://cursor.com/install -fsS | bash",
"launch": "agent",
"env": {
"OPENROUTER_API_KEY": "${OPENROUTER_API_KEY}"
"OPENROUTER_API_KEY": "${OPENROUTER_API_KEY}",
"CURSOR_API_KEY": "${OPENROUTER_API_KEY}"
},
"config_files": {
"~/.cursor/cli-config.json": {

View file

@ -222,6 +222,14 @@ describe("createCloudAgents", () => {
}
});
it("cursor agent uses real API key as CURSOR_API_KEY (not a dummy value)", () => {
const envVars = result.agents.cursor.envVars("sk-or-v1-real-key");
const cursorKeyVar = envVars.find((v: string) => v.startsWith("CURSOR_API_KEY="));
expect(cursorKeyVar).toBeDefined();
// Must use the actual API key, not a dummy like "spawn-proxy"
expect(cursorKeyVar).toBe("CURSOR_API_KEY=sk-or-v1-real-key");
});
it("all agents have launchCmd returning non-empty string", () => {
for (const agent of Object.values(result.agents)) {
const cmd = agent.launchCmd();

View file

@ -1093,7 +1093,7 @@ function createAgents(runner: CloudRunner): Record<string, AgentConfig> {
),
envVars: (apiKey) => [
`OPENROUTER_API_KEY=${apiKey}`,
"CURSOR_API_KEY=spawn-proxy",
`CURSOR_API_KEY=${apiKey}`,
],
configure: () => setupCursorProxy(runner),
preLaunch: () => startCursorProxy(runner),