New features: Route Stickness, Handoff, Clarification, Read-Only/Transactional, Long Term Memory

This commit is contained in:
2026-08-03 08:57:02 -03:00
parent e684b0ecc3
commit 8e414e4e26
604 changed files with 38978 additions and 402 deletions

View File

@@ -291,6 +291,11 @@ async def _process_gateway_message(req: GatewayRequest, emit_sse: bool = False)
"conversation_key": agent_session_id,
"workflow_id": workflow_id,
"agent_profile": normalized_context["agent_profile"],
# Chave estável de LTM. Nunca use session_id como identidade de longo prazo.
"long_term_memory_subject_key": business_context.customer_key or session.user_id,
"customer_key": business_context.customer_key,
"user_id": session.user_id,
"business_context": business_context.model_dump(),
"user_text": msg.text,
"history": history,
"context": {
@@ -365,6 +370,13 @@ async def _process_gateway_message(req: GatewayRequest, emit_sse: bool = False)
"identity_missing": missing_identity_keys,
"judges": result.get("judge_results"),
"guardrails": result.get("guardrail_decisions"),
"long_term_memory": {
"subject_key": business_context.customer_key or session.user_id,
"loaded": result.get("long_term_memories", []),
"context": result.get("long_term_memory_context", ""),
"load_error": result.get("long_term_memory_load_error"),
"write_result": result.get("long_term_memory_write_result", {}),
},
},
)
rendered = await gateway.render(response)
@@ -387,6 +399,14 @@ async def health():
"sse_enabled": settings.ENABLE_SSE,
"session_repository": settings.SESSION_REPOSITORY_PROVIDER,
"memory_repository": settings.MEMORY_REPOSITORY_PROVIDER,
"long_term_memory": {
"enabled": getattr(settings, "ENABLE_LONG_TERM_MEMORY", False),
"provider": getattr(settings, "LONG_TERM_MEMORY_PROVIDER", None),
"sqlite_path": getattr(settings, "LONG_TERM_MEMORY_SQLITE_PATH", None),
"table": getattr(settings, "LONG_TERM_MEMORY_TABLE", None),
"auto_extract": getattr(settings, "LONG_TERM_MEMORY_AUTO_EXTRACT", None),
"inject_context": getattr(settings, "LONG_TERM_MEMORY_INJECT_CONTEXT", None),
},
"checkpoint_repository": settings.CHECKPOINT_REPOSITORY_PROVIDER,
"usage_repository": settings.USAGE_REPOSITORY_PROVIDER,
"identity_config_path": settings.IDENTITY_CONFIG_PATH,