View memory

Memory

IntelligentRAG — extractAiText Fix for OpenAI-style Responses ## Problem The chat tool was returning raw JSON like: ```json {"intent":"answer","params":{},"reasoning":"...","response":"I currently have 0 documents..."} ``` ## Root Cause The LLM (Workers AI) returns OpenAI-style responses: ```json {"choices":[{"message":{"content":"..."}}]} ``` The `extractAiText` function didn't handle this nested structure. ## Fix Added handling for OpenAI-style `choices[0].message.content` in `extractAiText()`: ```typescript // OpenAI-style: {choices: [{message: {content: "..."}}]} if ("choices" in obj && Array.isArray(obj.choices) && obj.choices.length > 0) { const choice = obj.choices[0] as Record<string, unknown>; if (choice.message && typeof choice.message === "object") { const msg = choice.message as Record<string, unknown>; if (typeof msg.content === "string") return msg.content; } } ``` ## Result Chat tool now returns human-readable responses: - "how many documents do you have?" → "I currently have 0 documents in my knowledge graph." - "search for surrealdb" → "The error '401 Unauthorized' indicates..." (proper error handling) ## Other Issues Found (Pre-existing) 1. Document content corrupted ("canonical:https" instead of full content) 2. Chunk embedding field is required (should be optional) 3. Flow table not created (schema needs re-apply) ## Deployment - Version: 99203d52-ee2c-44c0-a2cd-70d99801f3e7 - All new tools accessible

Tags: intelligentrag, bugfix, mcp, llm, workers-ai, project:intelligentrag, kind:episodic — Source: claude — 2026-07-18 15:37:47 UTC

What would you like to do next?