Summary
AI Cleanup (POST /api/user-profile/ai-cleanup) never succeeds with opencodeProvider/opencodeModel (no external memoryApiUrl). Every failure surfaces as Error: No AI provider configured for profile cleanup even though the provider is configured and working (auto-capture and profile learning use it fine), because callAICleanup catches any error from the opencode path and falls through to the unset memoryModel/memoryApiUrl branch.
Five stacked bugs, each hidden behind the next. Four are in callViaOpencodeWithClient (ai-cleanup.js), one is in the web UI (web/app.js):
noReply: true on the session.prompt call suppresses assistant generation, so no response is produced. The working auto-capture path avoids noReply for this reason. Set it to false.
- Reads a nonexistent field. The prompt response is
{ info: AssistantMessage, parts: Array<Part> }, and AssistantMessage has no text field (per SDK types). Reading info.text yields undefined, then "AI response did not contain valid JSON". Read the text from promptResult.data.parts filtered by type === "text", as the rest of the codebase does.
- Server timeout too short. The
session.prompt race uses TIMEOUT_MS = 120000, but a real cleanup on a sizable profile takes longer, so it aborts. Raise it.
- Client default timeout too short.
fetchAPI in web/app.js defaults the /ai-cleanup fetch to 180000ms.
- Explicit client timeout overrides the default. The cleanup call passes an explicit
timeout: 180000, which wins over the fetchAPI default via options.timeout || .... This is the one that actually keeps hanging the modal: the browser aborts before the server responds, so the loading spinner never clears even though the server completed. Raise this explicit value too.
Repro
- Configure
opencodeProvider + opencodeModel, no external memory API.
- Confirm auto-capture / profile learning work.
- Web UI, click "AI Cleanup".
- Fails or hangs; log chain:
prompt timeout, then AI response did not contain valid JSON, then No AI provider configured.
Verified: with all five fixes applied, cleanup completes and the diff renders for review/apply.
Environment
- opencode-mem v2.19.4, OpenCode v1.18.3, macOS
opencodeProvider: amazon-bedrock, opencodeModel: global.anthropic.claude-sonnet-5, no external memory API
Summary
AI Cleanup (
POST /api/user-profile/ai-cleanup) never succeeds withopencodeProvider/opencodeModel(no externalmemoryApiUrl). Every failure surfaces asError: No AI provider configured for profile cleanupeven though the provider is configured and working (auto-capture and profile learning use it fine), becausecallAICleanupcatches any error from the opencode path and falls through to the unsetmemoryModel/memoryApiUrlbranch.Five stacked bugs, each hidden behind the next. Four are in
callViaOpencodeWithClient(ai-cleanup.js), one is in the web UI (web/app.js):noReply: trueon thesession.promptcall suppresses assistant generation, so no response is produced. The working auto-capture path avoidsnoReplyfor this reason. Set it tofalse.{ info: AssistantMessage, parts: Array<Part> }, andAssistantMessagehas notextfield (per SDK types). Readinginfo.textyieldsundefined, then"AI response did not contain valid JSON". Read the text frompromptResult.data.partsfiltered bytype === "text", as the rest of the codebase does.session.promptrace usesTIMEOUT_MS = 120000, but a real cleanup on a sizable profile takes longer, so it aborts. Raise it.fetchAPIinweb/app.jsdefaults the/ai-cleanupfetch to 180000ms.timeout: 180000, which wins over thefetchAPIdefault viaoptions.timeout || .... This is the one that actually keeps hanging the modal: the browser aborts before the server responds, so the loading spinner never clears even though the server completed. Raise this explicit value too.Repro
opencodeProvider+opencodeModel, no external memory API.prompt timeout, thenAI response did not contain valid JSON, thenNo AI provider configured.Verified: with all five fixes applied, cleanup completes and the diff renders for review/apply.
Environment
opencodeProvider: amazon-bedrock,opencodeModel: global.anthropic.claude-sonnet-5, no external memory API