{"record":{"id":"06c4e18db66e1bc2","repo":"mastra-ai/mastra","slug":"cursorsdkagent-does-not-support-structuredoutput-b","errorCode":null,"errorMessage":"CursorSDKAgent does not support structuredOutput because the Cursor TypeScript SDK does not expose a schema-constrained output API.","messagePattern":"CursorSDKAgent does not support structuredOutput because the Cursor TypeScript SDK does not expose a schema-constrained output API\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent-sdks/cursor/src/index.ts","lineNumber":303,"sourceCode":"  }\n}\n\nfunction validateCursorResumeData(resumeData: CursorSDKAgentResumeData): CursorSDKAgentResumeData {\n  if (!toRecord(resumeData) || !('message' in resumeData)) {\n    throw new Error('CursorSDKAgent resumeData must include a message.');\n  }\n\n  if (resumeData.agentId !== undefined && typeof resumeData.agentId !== 'string') {\n    throw new Error('CursorSDKAgent resumeData.agentId must be a string when provided.');\n  }\n\n  return resumeData;\n}\n\nfunction assertStructuredOutputUnsupported(options?: unknown): void {\n  const structuredOutput = toRecord(toRecord(options)?.structuredOutput);\n  if (structuredOutput && 'schema' in structuredOutput) {\n    throw new Error(\n      'CursorSDKAgent does not support structuredOutput because the Cursor TypeScript SDK does not expose a schema-constrained output API.',\n    );\n  }\n}\n\nasync function runCursorGenerate(\n  prompt: string,\n  options: CursorAgentOptions,\n  agent: SDKAgent,\n  telemetry: CursorToolTelemetry,\n): Promise<SDKModelGenerateResult> {\n  const usage = createCursorUsageCollector();\n  const run = await agent.send(prompt, createCursorSendOptions(options, usage, telemetry));\n  const result = await run.wait();\n\n  if (result.status === 'error' || result.status === 'cancelled') {\n    throw new Error(`Cursor run ${result.id} ended with status ${result.status}`);\n  }","sourceCodeStart":285,"sourceCodeEnd":321,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/agent-sdks/cursor/src/index.ts#L285-L321","documentation":"assertStructuredOutputUnsupported is called by generate, stream, resumeGenerate, and resumeStream on CursorSDKAgent. If options.structuredOutput contains a 'schema' key it throws, because the Cursor TypeScript SDK has no schema-constrained output API, so structured output cannot be honored.","triggerScenarios":"agent.generate(prompt, { structuredOutput: { schema: zodSchema } }) (or stream/resume* equivalents) — any call passing structuredOutput.schema to a CursorSDKAgent.","commonSituations":"Sharing a generate call helper across Claude/OpenAI/Cursor agents where structuredOutput is set unconditionally; porting code from an SDK that supports schemas; expecting parity in the agent-sdks packages' feature sets.","solutions":["Remove structuredOutput.schema from options when using CursorSDKAgent.","Get plain text and parse/validate it yourself with your schema (e.g. zod parse) as a post-processing step.","Use a different SDK agent (Claude/OpenAI) if schema-constrained output is a hard requirement.","Feature-detect per-agent: only pass structuredOutput for agents that support it."],"exampleFix":"// before\nawait cursorAgent.generate(prompt, { structuredOutput: { schema: MySchema } });\n// after\nconst res = await cursorAgent.generate(prompt);\nconst output = MySchema.parse(JSON.parse(res.text));","handlingStrategy":"validation","validationCode":"const opts = options as { structuredOutput?: { schema?: unknown } } | undefined;\nif (opts?.structuredOutput && 'schema' in opts.structuredOutput) {\n  delete (opts.structuredOutput as any).schema; // Cursor agent cannot honor schemas\n}\nawait cursorAgent.generate(prompt, opts);","typeGuard":"function supportsStructuredOutput(agent: unknown): boolean {\n  return !(agent instanceof CursorSDKAgent);\n}","tryCatchPattern":"try {\n  return await cursorAgent.generate(prompt, options);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('does not support structuredOutput')) {\n    const res = await cursorAgent.generate(prompt, { ...options, structuredOutput: undefined });\n    return Schema.parse(JSON.parse(res.text)); // validate manually\n  }\n  throw e;\n}","preventionTips":["Strip structuredOutput.schema when routing work to CursorSDKAgent.","Centralize agent selection so schema-dependent calls only go to schema-capable agents.","After Cursor text output, always validate/parse against your schema manually."],"tags":["cursor","structured-output","unsupported-feature","validation"],"backgroundTag":"unsupported-feature","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}