new feature: frontend with separated responses

This commit is contained in:
2026-09-11 11:59:51 -03:00
parent 82ae25b85b
commit 2ac3e4e702
21 changed files with 697 additions and 34 deletions

View File

@@ -1,5 +1,8 @@
from agent_framework.routing.config_loader import load_intents, load_multi_intent_config
import pytest
from agent_framework.routing.multi_intent import MultiIntentPlanner
from agent_framework.routing.pending_topics import drain_pending_topics
from agent_framework.mcp.tool_policy import ToolPolicyRegistry
@@ -53,3 +56,55 @@ def test_duas_mais_caras_sao_calculadas_sobre_evidencia_autorizada():
selected = _select_relative_invoice_charges("as duas mais caras", args)
assert [row["value"] for row in selected] == [29.90, 24.90]
assert [row["charge_date"] for row in selected] == ["02/09/26", "04/09/26"]
@pytest.mark.asyncio
async def test_promocao_transacional_substitui_snapshot_de_continuidade_anterior():
async def orders_handler(state):
assert state["intent"] == "retail_order_cancel"
return {
"answer": "Informe o número do pedido que deseja cancelar.",
"transaction_status": "COLLECTING_PARAMETERS",
"active_transaction": {
"tool_name": "cancelar_pedido",
"status": "COLLECTING_PARAMETERS",
},
"missing_parameters": ["order_id"],
"pending_tool_call": {
"tool_name": "cancelar_pedido",
"arguments": {},
},
"next_state": "COLLECTING_PARAMETERS",
}
drained = await drain_pending_topics(
{
"answer": "Devolução concluída.",
"route": "support_agent",
"active_agent": "support_agent",
"intent": "retail_support_exchange_return",
"transaction_status": "COMPLETED",
"route_decision": {
"route": "support_agent",
"agent": "support_agent",
"intent": "state:WAITING_SUPPORT_CONFIRMATION",
},
"pending_topics": [{
"operation_id": "op-3",
"agent": "orders_agent",
"intent": "retail_order_cancel",
"domain": "retail",
"tools": ["consultar_pedido", "cancelar_pedido"],
"source_text": "quero cancelar pedido",
"disposition": "defer",
}],
},
"Devolução concluída.",
{"orders_agent": orders_handler},
)
assert drained.state_patch["route"] == "orders_agent"
assert drained.state_patch["transaction_status"] == "COLLECTING_PARAMETERS"
assert drained.state_patch["route_decision"]["agent"] == "orders_agent"
assert drained.state_patch["route_decision"]["intent"] == "retail_order_cancel"
assert drained.state_patch["route_decision"]["metadata"]["promoted_from_pending_topics"] is True