Where does the bug appear (feature/product)?
Cursor SDK
Describe the Bug
Long-lived Node host (@cursor/sdk 1.0.28, Windows) with a valid CURSOR_API_KEY passed into Agent.create / Agent.resume.
Observed window
- Idle under ~1 hour: dispose +
Agent.resume/ in-process retry often recovers. - Idle over ~1 hour: every in-process method fails (
reload(), dispose +resume, retrysend()). Only restarting the Node process restores the same API key and the samesdk_agent_id. Then it is healthy for about another hour.
The user-facing text is:
Authentication error
If you are logged in, try logging out and back in.
That copy is for the Cursor IDE session. This host is not using IDE login. Cursor.auth.login() / logout() only mint/clear ~/.cursor/sdk/auth.json and do not fix it.
Cursor.me({ apiKey }) still works while send() is dead. Same key works immediately after process restart. Looks like the short-lived token the SDK exchanges from the API key cannot be refreshed in-process after ~1h.
Still broken vs confirmed threads:
- Idle local agent gRPC connection returns `ERROR_NOT_LOGGED_IN` (AuthenticationError) instead of NetworkError after ~15 minutes
- @cursor/sdk 1.0.22 — Local agent returns bare status=ERROR after idle; process restart fixes it (not quota)
Steps to Reproduce
-
Node 22+, Windows,
@cursor/[email protected],CURSOR_API_KEYset. -
Keep a live handle:
const agent = await Agent.create({
apiKey: process.env.CURSOR_API_KEY!,
model: { id: "composer-2.5" },
local: { cwd: "C:\\path\\to\\repo" },
});
await agent.send("hello");
- Idle under 1 hour, then
send()again. Often recoverable with:
await agent.close();
const resumed = await Agent.resume(agent.agentId, {
apiKey: process.env.CURSOR_API_KEY!,
model: { id: "composer-2.5" },
local: { cwd: "C:\\path\\to\\repo" },
});
await resumed.send("hello again");
- Idle over 1 hour, then
send()again. TerminalAuthenticationError:
Authentication error
If you are logged in, try logging out and back in.
agent.reload(), close() + Agent.resume, and retries all fail.
- Restart the Node process.
Agent.resumethe sameagentIdwith the same API key. Works for about another hour, then repeats.
Expected Behavior
After idle, the SDK should re-exchange the API key on the same Node process, or return a retryable error (NetworkError / isRetryable: true) so the host can:
await agent.close();
const resumed = await Agent.resume(agentId, { apiKey, local: { cwd } });
without restarting the process.
It should not surface a terminal AuthenticationError with IDE copy:
If you are logged in, try logging out and back in.
API-key hosts (CURSOR_API_KEY / explicit apiKey) are not logged into the Cursor IDE. Cursor.auth.login() / logout() only touch ~/.cursor/sdk/auth.json and are not a fix.
In this environment the hard latch is ~1 hour, not ~15 minutes. After that, only a full Node process restart restores the same key and the same agentId.
Operating System
Windows 10/11
Version Information
Not the Cursor IDE. This is the TypeScript SDK in a long-lived Node process.
@cursor/sdk: 1.0.28
Node: 24.13.1
OS: Windows 11 (10.0.26200)
Runtime: local Agent.create / Agent.resume
Host: HTTP service holding live SDKAgent handles for hours
For AI issues: which model did you use?
Reproduced with:
composer-2.5(fast=false)grok-4.6
The failure is on agent.send() before a model turn. Same for both.
Additional Information
Credential setup:
apiKeyis passed explicitly (CURSOR_API_KEY).- Not using Cursor IDE login.
Cursor.auth.login()/logout()only mint/clear~/.cursor/sdk/auth.json. They do not refresh the in-process exchanged token and do not fix this.
Workarounds tried (over 1h idle):
- in-process retry of
send() agent.reload()close()+Agent.resume(agentId)with the same key and cwd
All fail. Restarting the Node process restores the same key and the same agentId for about another hour.
Under ~1 hour idle, resume often recovers.
Related (still open):
WARN: run ended in error: Authentication error If you are logged in, try logging out and back in.
jobId: “job_dc44235c-…”
runId: “run-f50ada83-…”
terminalStatus: “error”
sdkStatusMessage: “Authentication error If you are logged in, try logging out and back in.”
runResultDetail: null
streamThrew: null
Does this stop you from using Cursor
Sometimes - I can sometimes use Cursor