{"slug": "middleware-that-catches-when-llm-conversations-slowly-drift-off-topic", "title": "Middleware that catches when LLM conversations slowly drift off-topic", "summary": "HALLUCINATIOFF, a recursive middleware for LLM output regulation, detects semantic drift, premise flaws, and response risks through second-order observation, achieving 95% accuracy on 20 synthetic cases with version v0.1. The system, developed from the SIIPP clinical framework, sits between the LLM and user to decide whether to emit, reformulate, or block responses without modifying model weights.", "body_md": "EN:Recursive middleware for LLM output regulation. Detects semantic drift, premise flaws, and response risks through multi-order observation. Psychology-informed architecture.\n\nES:Middleware recursivo de regulación de output para LLMs. Detecta deriva semántica, fallos de premisas y riesgos de respuesta mediante observación multi-orden. Arquitectura informada por psicofísica.\n\n**EN:** HALLUCINATIOFF sits between the LLM and the user. It does not train the model. It does not modify weights. It **observes the response before it reaches the user** and decides: emit, emit with caution, reformulate, request context, reduce intensity, refer, pause, or block.\n\nThe difference from other safeguarding systems: HALLUCINATIOFF implements **second-order observation**. It does not only detect if a response is coherent (1st order). It detects if **the coherence criterion itself is becoming unstable** (2nd order).\n\nThis framework comes from **SIIPP** (Sistema Integral de Intervención Psicofísica), developed from clinical body-based practice.\n\n**ES:** HALLUCINATIOFF se sitúa entre el LLM y el usuario. No entrena el modelo. No modifica pesos. **Observa la respuesta antes de que llegue al usuario** y decide: emitir, emitir con cautela, reformular, pedir contexto, reducir intensidad, derivar, pausar o bloquear.\n\nLa diferencia con otros sistemas de safeguarding: HALLUCINATIOFF implementa **observación de segundo orden**. No solo detecta si una respuesta es coherente (1° orden). Detecta si **el propio criterio de coherencia se está volviendo inestable** (2° orden).\n\nEste marco proviene del **SIIPP** (Sistema Integral de Intervención Psicofísica), desarrollado desde la práctica clínica corporal.\n\n| Version | Readings | Features | Benchmark |\n|---|---|---|---|\n| v0.1 | 6 | SC, CI, V_ext, AE, NI, RR | 95% (20 synthetic cases) |\n| v0.2 | 7 | + Semantic drift (DS) | Pending |\n| v0.3 | 8 | + Premise interrogation (IP) | Pending |\n\n**EN:** SC = Contextual sufficiency, CI = Internal coherence, V_ext = External verifiability, AE = Entry ambiguity, NI = Uncertainty level, RR = Response risk, DS = Semantic drift, IP = Premise interrogation.\n\n**ES:** SC = Suficiencia contextual, CI = Coherencia interna, V_ext = Verificabilidad externa, AE = Ambigüedad de entrada, NI = Nivel de incertidumbre, RR = Riesgo de respuesta, DS = Deriva semántica, IP = Interrogación de premisas.\n\n``` python\nfrom src.hallucinatioff import Hallucinatioff\n\nh = Hallucinatioff()\n\nresult = h.procesar(\n    respuesta_candidata=\"The capital of France is Paris.\",\n    contexto=\"What is the capital of France?\"\n)\n\nprint(result['accion'])      # \"emitir\"\nprint(result['omega'])       # 0.823\nprint(result['lecturas'])    # dict with 8 readings\n# Turn 0 / Turno 0\nr0 = h.procesar(\n    respuesta_candidata=\"Inclusive education requires curricular adaptations.\",\n    contexto=\"What is inclusive education?\",\n    turno=0\n)\n\n# Turn 1 — semantic drift / Turno 1 — deriva semántica\nr1 = h.procesar(\n    respuesta_candidata=\"Asian financial markets are rising this quarter.\",\n    contexto=\"And what about the stock market?\",\n    turno=1\n)\n\nprint(r1['lecturas']['DS'])  # Semantic drift detected / Deriva detectada\n```\n\n| Component | Status | Notes |\n|---|---|---|\n| Reading engine (6 basic) | ✅ Functional | Regex and count-based heuristics |\n| Semantic drift (DS) | ✅ Functional | Keyword similarity + topic detection |\n| Premise interrogation (IP) | ✅ Functional | Individualizing framing detection |\n| Ω calculator | ✅ Functional | Dynamic weights with interaction penalties |\n| Operative matrix | ✅ Functional | 8 possible actions |\n| Benchmark v0.1 | 20 cases, 95% accuracy. 6 readings only. Dataset included. | |\n| Benchmark v0.3 | ❌ Pending | Needs dataset with DS and IP |\n| 2nd-order meta-observer | ❌ Not implemented | Specified, pending development |\n\n**EN:** Result: **95% accuracy** on 20 synthetic cases (6 readings).\n\nSingle failure: Case 2 (factual hallucination) — Ω=0.713, action=\"emit\" when it should have been \"emit_with_caution\". The system failed to detect that external verifiability (V_ext=0.7) was falsely high.\n\n**ES:** Resultado: **95% de precisión** en 20 casos sintéticos (6 lecturas).\n\nFallo único: Caso 2 (halucinación factual) — Ω=0.713, acción=\"emitir\" cuando debería haber sido \"emitir_con_cautela\". El sistema no detectó que la verificabilidad externa (V_ext=0.7) era falsamente alta.\n\nThis benchmark does not prove production readiness. It validates that the 6-reading architecture does not degrade performance on constructed cases.\n\nEste benchmark no prueba funcionamiento en producción. Valida que la arquitectura de 6 lecturas no degrada el rendimiento en casos construidos.\n\n-\n**EN:** Real multi-turn data with annotated drift. Conversations where drift occurs naturally, not synthetically.\n\n**ES:** Datos reales multi-turno con deriva anotada. Conversaciones donde la deriva ocurra de forma natural, no sintética. -\n**EN:** Mathematical formalization of \"phase coupling\" and \"attractor\" in terms of system dynamics applied to embedding sequences.\n\n**ES:** Formalización matemática del \"acoplamiento de fase\" y del \"atractor\" en términos de dinámica de sistemas aplicada a secuencias de embeddings. -\n**EN:** Implementation of the 2nd-order meta-observer: the system observes the variance of its own coherence judgments over time.\n\n**ES:** Implementación del meta-observador de 2° orden: el sistema observa la varianza de sus propios juicios de coherencia a lo largo del tiempo.\n\nIf you have any of these three, write to: [your-email]\n\nSi tienes alguno de estos tres, escribe a: [tu-email]\n\n```\nInput (question + candidate response)\n    ↓\nSemantic Memory Engine (multi-turn drift)\n    ↓\n8 Structural Readings → Ω → Operative Matrix → Action\n    ↓\nOutput (final response + metadata)\n```\n\nSee [docs/arquitectura.md](/ojki74/hallucinatoff/blob/main/docs/arquitectura.md) for full technical specification.\n\nVer [docs/arquitectura.md](/ojki74/hallucinatoff/blob/main/docs/arquitectura.md) para especificación técnica completa.\n\n[docs/nota_marco_conceptual.md](/ojki74/hallucinatoff/blob/main/docs/nota_marco_conceptual.md)— Conceptual framework / Marco conceptual[docs/arquitectura.md](/ojki74/hallucinatoff/blob/main/docs/arquitectura.md)— Technical specification / Especificación técnica[docs/isomorfismo_siipp.md](/ojki74/hallucinatoff/blob/main/docs/isomorfismo_siipp.md)— SIIPP ↔ engineering isomorphism / Isomorfismo SIIPP ↔ ingeniería\n\nMIT — Use, modify, improve. If used in research, cite.\n\nMIT — Usa, modifica, mejora. Si lo usas en investigación, cita.\n\n**Óscar Fernández Sanz** — Psychologist. SIIPP developer. Not an ML engineer.\n\n**Óscar Fernández Sanz** — Psicólogo. Desarrollador de SIIPP. No ingeniero de ML.\n\n\"Recursion is not a bug in the system. It is the mechanism by which a system generates a model of itself.\"\n\n\"La recursividad no es un bug del sistema. Es el mecanismo por el cual un sistema genera un modelo de sí mismo.\"", "url": "https://wpnews.pro/news/middleware-that-catches-when-llm-conversations-slowly-drift-off-topic", "canonical_source": "https://github.com/ojki74/hallucinatoff", "published_at": "2026-07-23 23:39:19+00:00", "updated_at": "2026-07-23 23:52:18.042441+00:00", "lang": "en", "topics": ["large-language-models", "ai-safety", "ai-tools", "ai-agents"], "entities": ["HALLUCINATIOFF", "SIIPP"], "alternates": {"html": "https://wpnews.pro/news/middleware-that-catches-when-llm-conversations-slowly-drift-off-topic", "markdown": "https://wpnews.pro/news/middleware-that-catches-when-llm-conversations-slowly-drift-off-topic.md", "text": "https://wpnews.pro/news/middleware-that-catches-when-llm-conversations-slowly-drift-off-topic.txt", "jsonld": "https://wpnews.pro/news/middleware-that-catches-when-llm-conversations-slowly-drift-off-topic.jsonld"}}