{"record":{"id":"583edec0cb383adb","repo":"mastra-ai/mastra","slug":"acp-prompt-stopped-before-completing-response-s","errorCode":null,"errorMessage":"ACP prompt stopped before completing: ${response.stopReason}","messagePattern":"ACP prompt stopped before completing: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent-sdks/acp/src/connection.ts","lineNumber":345,"sourceCode":"      },\n      ...this.options.initialize,\n    };\n  }\n\n  private getNewSessionRequest(): NewSessionRequest {\n    return {\n      cwd: this.options.cwd ?? process.cwd(),\n      mcpServers: [],\n      ...this.options.session,\n    };\n  }\n\n  private throwIfPromptDidNotComplete(response: PromptResponse): void {\n    if (response.stopReason === 'end_turn') {\n      return;\n    }\n\n    throw new Error(`ACP prompt stopped before completing: ${response.stopReason}`);\n  }\n\n  private withStderr(error: unknown): Error {\n    const stderr = this.stderr.trim();\n\n    if (error instanceof Error) {\n      if (stderr && !error.message.includes(stderr)) {\n        error.message = `${error.message}\\n\\nACP agent stderr:\\n${stderr}`;\n      }\n\n      return error;\n    }\n\n    return new Error(stderr ? `${String(error)}\\n\\nACP agent stderr:\\n${stderr}` : String(error));\n  }\n}\n\ntype AsyncQueue<T> = AsyncIterable<T> & {","sourceCodeStart":327,"sourceCodeEnd":363,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/agent-sdks/acp/src/connection.ts#L327-L363","documentation":"Same as error 2580 but in the restore-version handler: it requires a configured storage adapter before it can read or write agent versions. mastra.getStorage() returning undefined produces this 500 HTTPException.","triggerScenarios":"POST (restore) on /api/agents/:agentId/versions/:versionId against a Mastra instance without `storage` configured.","commonSituations":"Dev instances built without persistence; storage omitted from server/mastra config after refactoring; environment gating that disables storage in the deployed build.","solutions":["Add storage: new PostgresStore({...}) (or equivalent) to the Mastra instance options","Ensure the server hosting these handlers uses the Mastra instance that includes storage","Check env vars used to build the storage connection (DATABASE_URL etc.) so config isn't silently skipped","Redeploy after fixing config"],"exampleFix":"// before\nconst mastra = new Mastra({ agents });\n// after\nconst mastra = new Mastra({ agents, storage: new PostgresStore({ connectionString: process.env.DATABASE_URL }) });","handlingStrategy":"try-catch","validationCode":"const mastra = getMastra();\nif (!mastra?.getStorage?.()) throw new Error('Cannot restore agent version: storage not configured');","typeGuard":"function storageReady(m: unknown): m is { getStorage: () => object } {\n  return !!m && typeof (m as any).getStorage === 'function' && !!(m as any).getStorage();\n}","tryCatchPattern":"try {\n  await fetch(`/api/agents/${agentId}/versions/${versionId}/restore`, { method: 'POST' });\n} catch (e) {\n  if (isHttpError(e) && e.status === 500 && /Storage is not configured/.test(e.message)) {\n    // add storage to Mastra config, redeploy, retry\n  } else throw e;\n}","preventionTips":["Configure storage before enabling version/restore features","Assert storage presence at server startup","Keep storage wiring in shared config used by all server entrypoints","Test restore endpoints in CI against a storage-backed instance"],"tags":["storage","configuration","server","http-500"],"backgroundTag":"storage-not-configured","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}