{"record":{"id":"fe3ed01ac51e7817","repo":"mastra-ai/mastra","slug":"acp-connection-is-not-initialized","errorCode":null,"errorMessage":"ACP connection is not initialized","messagePattern":"ACP connection is not initialized","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent-sdks/acp/src/connection.ts","lineNumber":155,"sourceCode":"  async prompt(task: string, signal?: AbortSignal): Promise<string> {\n    const parts: string[] = [];\n\n    for await (const event of this.promptStream(task, signal)) {\n      if (event.type === 'text') {\n        parts.push(event.text);\n      }\n    }\n\n    return parts.join('');\n  }\n\n  async *promptStream(task: string, signal?: AbortSignal): AsyncGenerator<ACPStreamEvent> {\n    await this.ensureConnected();\n\n    const sessionId = this.session?.sessionId;\n\n    if (!this.connection || !sessionId) {\n      throw new Error('ACP connection is not initialized');\n    }\n\n    if (signal?.aborted) {\n      await this.cancel();\n      throw signal.reason ?? new Error('ACP prompt aborted');\n    }\n\n    const queue = createAsyncQueue<ACPStreamEvent>();\n    const state: PromptState = {\n      sessionId,\n      onEvent: event => queue.push(event),\n    };\n    this.currentPrompt = state;\n\n    const abortHandler = () => {\n      void this.cancel();\n      queue.throw(signal?.reason ?? new Error('ACP prompt aborted'));\n    };","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/agent-sdks/acp/src/connection.ts#L137-L173","documentation":"After the agent is found, the handler fetches the stored version record by versionId; a null result yields a 404 with this message. The version row simply does not exist in the agents store.","triggerScenarios":"GET/POST /api/agents/:agentId/versions/:versionId where :versionId was never created, was pruned, or belongs to a different storage backend.","commonSituations":"Reusing a versionId copied from logs of another environment; databases reset between test runs; retention/cleanup jobs deleting old versions; calling before any version snapshot has been persisted.","solutions":["List available versions via GET /api/agents/:agentId/versions and use a valid versionId","Fix the versionId path parameter (check casing/format)","Connect the server to the storage environment that actually holds the version","Restore the version data from backup if it was deleted unintentionally"],"exampleFix":"// before\nawait fetch(`/api/agents/${agentId}/versions/${versionId}`);\n// after\nconst versions = await fetch(`/api/agents/${agentId}/versions`).then(r => r.json());\nconst valid = versions.find(v => v.id === versionId);\nif (valid) await fetch(`/api/agents/${agentId}/versions/${versionId}`);","handlingStrategy":"validation","validationCode":"const versions = await fetch(`/api/agents/${agentId}/versions`).then(r => r.json());\nif (!versions.some(v => v.id === versionId)) throw new Error(`Version ${versionId} does not exist for ${agentId}`);","typeGuard":"function versionExists(versions: {id: string}[], id: string): boolean {\n  return versions.some(v => v.id === id);\n}","tryCatchPattern":"try {\n  await fetch(`/api/agents/${agentId}/versions/${versionId}`);\n} catch (e) {\n  if (isHttpError(e) && e.status === 404 && e.message.startsWith('Version with id')) {\n    // refetch version list and pick a valid id\n  } else throw e;\n}","preventionTips":["Always obtain versionIds from the versions list endpoint","Persist version references with the environment/DB they came from","Account for retention policies that prune old versions","Verify versionId format (uuid) before calling"],"tags":["http-404","not-found","versions","rest-api"],"backgroundTag":"resource-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}