Skip to content

[auto] CRITICAL: RPC search_agent_memory_smart 404 — memory recall falhando 171x/4h #2

Description

@louambrosio

🚨 Regressão Crítica — Auto-Healing QA

Detectado: 2026-06-17 | Frequência: 171 ocorrências em ~4h (1x a cada 2min)
Serviço: memory-engine → recall do agente astro
Severidade: CRÍTICA — todo recall semântico está falhando silenciosamente


Erro (PM2 logs synapses-api)

[memory-engine] recall falhou para astro
err=Supabase RPC search_agent_memory_smart 404: PGRST202
hint: Perhaps you meant to call the function public.match_memories
message: Could not find the function public.search_agent_memory_smart(p_agent_id, p_embedding, p_layers, p_threshold, p_top_k) in the schema cache

Root Cause

  • memory-engine.jsc chama search_agent_memory_smart(p_agent_id, p_embedding, p_layers, p_threshold, p_top_k)
  • No Supabase só existe match_memories(query_embedding, match_threshold, match_count, p_agent_id) — definida em migrations/05_pgvector_agent_memory.sql
  • A migration correspondente à nova função NUNCA foi aplicada no banco

Fix — Nova Migration 026_search_agent_memory_smart.sql

CREATE OR REPLACE FUNCTION public.search_agent_memory_smart(
  p_agent_id text,
  p_embedding vector(1536),
  p_layers text[] DEFAULT NULL,
  p_threshold float DEFAULT 0.7,
  p_top_k int DEFAULT 10
) RETURNS TABLE (
  id uuid,
  agent_id text,
  content text,
  title text,
  type text,
  created_at timestamptz,
  similarity float
) LANGUAGE sql STABLE AS $$
  SELECT
    m.id, m.agent_id, m.content, m.title, m.type, m.created_at,
    1 - (m.embedding <=> p_embedding) AS similarity
  FROM agent_memory m
  WHERE m.agent_id = p_agent_id
    AND 1 - (m.embedding <=> p_embedding) > p_threshold
  ORDER BY m.embedding <=> p_embedding
  LIMIT p_top_k;
$$;

Evidência

  • Primeiro erro: 18:20:30 | Último: 21:09:40
  • 171 falhas consecutivas, cadência 2min
  • Impacto: recall semântico de todos os agentes offline silenciosamente

Arquivos

  • synapses/memory-engine.jsc (caller — bytenode compilado)
  • migrations/05_pgvector_agent_memory.sql (só define match_memories)
  • Criar: migrations/026_search_agent_memory_smart.sql

Criado automaticamente por QA Auto-Healing — LogicaOS v1.9.126 — 2026-06-17

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions