mastra-ai/mastra · error
Cursor run ${result.id} ended with status ${result.status}
Error message
Cursor run ${result.id} ended with status ${result.status} What it means
runCursorGenerate sends the prompt via agent.send, waits for the run to finish with run.wait(), and throws if the finished run's status is 'error' or 'cancelled' — i.e. the Cursor agent run did not complete successfully.
Source
Thrown at agent-sdks/cursor/src/index.ts:320
if (structuredOutput && 'schema' in structuredOutput) {
throw new Error(
'CursorSDKAgent does not support structuredOutput because the Cursor TypeScript SDK does not expose a schema-constrained output API.',
);
}
}
async function runCursorGenerate(
prompt: string,
options: CursorAgentOptions,
agent: SDKAgent,
telemetry: CursorToolTelemetry,
): Promise<SDKModelGenerateResult> {
const usage = createCursorUsageCollector();
const run = await agent.send(prompt, createCursorSendOptions(options, usage, telemetry));
const result = await run.wait();
if (result.status === 'error' || result.status === 'cancelled') {
throw new Error(`Cursor run ${result.id} ended with status ${result.status}`);
}
const responseModel = getModelId(result.model ?? run.model ?? getRequestedModel(options) ?? agent.model);
const providerMetadata = getCursorProviderMetadata(
options,
agent.agentId,
result.id,
result.status,
result.durationMs,
usage.totals(),
responseModel,
);
return {
content: [{ type: 'text', text: result.result ?? '' }],
finishReason: { unified: 'stop', raw: 'stop' },
usage: usage.toV3Usage(),
response: {View on GitHub (pinned to 75dd419e61)
Solutions
- Check Cursor API credentials and account status/limits.
- Determine whether the run was cancelled externally (user action, abort signal) and avoid aborting.
- Retry the generate call if the error was transient.
- Log result.status (included in the message) and any Cursor-side run details for diagnosis.
Defensive patterns
Strategy: retry
Validate before calling
// Validate Cursor credentials/config before sending
if (!process.env.CURSOR_API_KEY) throw new Error('CURSOR_API_KEY missing before Cursor generate'); Type guard
function isFinishedOk(result: { status: string }): boolean {
return result.status !== 'error' && result.status !== 'cancelled';
} Try / catch
try {
const res = await cursorAgent.generate(prompt);
} catch (e) {
if (e instanceof Error && /ended with status (error|cancelled)/.test(e.message)) {
if (e.message.includes('status error')) await retryWithBackoff(() => cursorAgent.generate(prompt));
// cancelled: do not retry, handle cancellation
} else throw e;
} Prevention
- Check Cursor API key validity and account limits before long runs.
- Distinguish cancelled (no retry) from error (transient retry with backoff).
- Log result.id from the message for Cursor-side debugging.
When it happens
Trigger: cursorAgent.generate(prompt) where the awaited Cursor run ends with result.status === 'error' or 'cancelled'.
Common situations: Cursor API authentication failure; run cancelled by the user or a timeout; the remote agent crashing server-side; hitting Cursor usage limits.
Related errors
- ${message.errors.join('\n') || `Claude Agent SDK failed with
- CursorSDKAgent resumeData must include a message.
- CursorSDKAgent resumeData.agentId must be a string when prov
- CursorSDKAgent does not support structuredOutput because the
- GitHub cursor must be a positive page number.
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/90faf2df75e217aa.
Report an issue: GitHub.