bugfix: oci_openai provider

This commit is contained in:
2026-08-27 20:34:15 -03:00
parent fc64c6ddd7
commit 0ecff719b7
329 changed files with 864 additions and 144 deletions

Binary file not shown.

View File

@@ -161,8 +161,81 @@ class AgentWorkflow:
if current_user_text:
if not history or str((history[-1] or {}).get("content") or "") != current_user_text or str((history[-1] or {}).get("role") or "") != "user":
history.append({"role": "user", "content": current_user_text})
ctx["conversation_history"] = history
ctx["history_texts"] = [str(item.get("content") or "") for item in history if isinstance(item, dict) and item.get("content") not in (None, "")]
# Guardrails de domínio precisam julgar a solicitação do turno atual, não
# reabrir semanticamente uma transação já encerrada. O router já ignora
# COMPLETED/FAILED/CANCELLED/BLOCKED/OUT_OF_SCOPE para continuidade; o
# mesmo princípio precisa valer para o contexto operacional dos rails.
#
# Importante: não apagamos o histórico do state/checkpoint (auditoria).
# Apenas recortamos o contexto enviado aos guardrails quando há evidência
# explícita de que o turno atual saiu da transação anterior: seja por
# interrupção semântica (transaction_interruption=intent_shift), seja por
# preempção de stickiness após uma transação terminal.
route_decision = state.get("route_decision") or {}
route_metadata = route_decision.get("metadata") if isinstance(route_decision, dict) else {}
route_metadata = route_metadata if isinstance(route_metadata, dict) else {}
pre_validation = state.get("transaction_pre_validation") or {}
pre_validation = pre_validation if isinstance(pre_validation, dict) else {}
tx_status = str(
state.get("transaction_status")
or pre_validation.get("status")
or ""
).strip().upper()
terminal_tx = bool(pre_validation.get("terminal")) or tx_status in {
"COMPLETED", "FAILED", "CANCELLED", "BLOCKED", "OUT_OF_SCOPE"
}
semantic_intent_shift = (
str(route_metadata.get("transaction_interruption") or "").strip().lower()
== "intent_shift"
)
stickiness_intent_shift = bool(route_metadata.get("route_stickiness_preempted"))
should_isolate_history = semantic_intent_shift or (terminal_tx and stickiness_intent_shift)
current_route = str(
state.get("route")
or (route_decision.get("route") if isinstance(route_decision, dict) else "")
or ""
).strip()
current_intent = str(
state.get("intent")
or (route_decision.get("intent") if isinstance(route_decision, dict) else "")
or ""
).strip()
ctx["current_user_message"] = current_user_text
ctx["current_route"] = current_route
ctx["current_intent"] = current_intent
if should_isolate_history:
operational_history = (
[{"role": "user", "content": current_user_text}]
if current_user_text else []
)
ctx["historical_transaction_ignored"] = True
ctx["historical_transaction_status"] = tx_status or (
"INTERRUPTED" if semantic_intent_shift else "TERMINAL"
)
if semantic_intent_shift:
ctx["historical_transaction_interruption"] = "intent_shift"
# Remova do contexto operacional quaisquer snapshots transacionais
# antigos eventualmente carregados em state.context. Eles continuam
# preservados no state para auditoria/checkpoint.
for stale_key in (
"transaction_pre_validation",
"transaction_status",
"active_transaction",
"transaction",
):
ctx.pop(stale_key, None)
else:
operational_history = history
ctx["conversation_history"] = operational_history
ctx["history_texts"] = [
str(item.get("content") or "")
for item in operational_history
if isinstance(item, dict) and item.get("content") not in (None, "")
]
protocols: list[str] = []
seen: set[str] = set()