diff --git a/Console/Commands/BrainIngestCommand.php b/Console/Commands/BrainIngestCommand.php index 3b3170b..4f808c4 100644 --- a/Console/Commands/BrainIngestCommand.php +++ b/Console/Commands/BrainIngestCommand.php @@ -133,11 +133,19 @@ class BrainIngestCommand extends Command } try { + $text = $section['heading']."\n\n".$section['content']; + + // embeddinggemma has a 2048-token context (~4K chars). + // Truncate oversized sections to avoid Ollama 500 errors. + if (strlen($text) > 3800) { + $text = mb_substr($text, 0, 3800).'…'; + } + $brain->remember([ 'workspace_id' => $workspaceId, 'agent_id' => $agentId, 'type' => $type, - 'content' => $section['heading']."\n\n".$section['content'], + 'content' => $text, 'tags' => $tags, 'project' => $project, 'confidence' => $this->confidenceForSource($source), @@ -400,9 +408,13 @@ class BrainIngestCommand extends Command $prop = $reflection->getProperty('collection'); $collection = $prop->getValue($brain); + // Clear Qdrant collection. \Illuminate\Support\Facades\Http::withoutVerifying() ->timeout(10) ->delete("{$qdrantUrl}/collections/{$collection}"); + + // Truncate the DB table so rows stay in sync with Qdrant. + \Core\Mod\Agentic\Models\BrainMemory::query()->forceDelete(); } private function expandHome(string $path): string