Ajustes conforme relatorio de testes 2026-08-27
This commit is contained in:
@@ -90,3 +90,89 @@ async def test_tim_aoferta_still_uses_llm_outside_transaction_continuation():
|
||||
assert llm.calls == 1
|
||||
assert decision.allowed is False
|
||||
assert decision.reason == 'oferta proativa'
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_tim_aoferta_allows_structurally_authorized_human_handoff_without_calling_llm():
|
||||
decision = await TimProactiveOfferRail().evaluate(
|
||||
'Vou encaminhar seu atendimento para uma pessoa.',
|
||||
{
|
||||
'current_route': 'human_handoff',
|
||||
'current_intent': 'human_handoff',
|
||||
'session_control': 'HUMAN_HANDOFF',
|
||||
'human_handoff_requested': True,
|
||||
'guardrail_llm': _FailIfCalledLLM(),
|
||||
},
|
||||
)
|
||||
|
||||
assert decision.allowed is True
|
||||
assert decision.reason == 'handoff_humano_autorizado'
|
||||
assert decision.metadata['mechanism'] == 'deterministic_handoff_bypass'
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_tim_aoferta_does_not_bypass_transfer_phrase_without_structural_handoff():
|
||||
llm = _BlockingLLM()
|
||||
decision = await TimProactiveOfferRail().evaluate(
|
||||
'Vou encaminhar seu atendimento para uma pessoa.',
|
||||
{
|
||||
'current_route': 'faturas_agent',
|
||||
'current_intent': 'contas_invoice_query',
|
||||
'guardrail_llm': llm,
|
||||
},
|
||||
)
|
||||
|
||||
assert llm.calls == 1
|
||||
assert decision.allowed is False
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_tim_aoferta_allows_terminal_handoff_from_resumed_workflow_without_router_handoff():
|
||||
decision = await TimProactiveOfferRail().evaluate(
|
||||
'Para continuar com a sua solicitação, aguarde um instante.',
|
||||
{
|
||||
'current_route': 'faturas_agent',
|
||||
'current_intent': 'contas_invoice_explanation',
|
||||
'mcp_results': [{
|
||||
'tool_name': 'retomar_workflow',
|
||||
'result': {
|
||||
'status': 'COMPLETED',
|
||||
'output': {
|
||||
'mensagem': 'Para continuar com a sua solicitação, aguarde um instante.',
|
||||
'session_control': 'HUMAN_HANDOFF',
|
||||
'human_handoff_requested': True,
|
||||
'handoff': True,
|
||||
'session_ended': True,
|
||||
'terminal_status': 'human_handoff',
|
||||
},
|
||||
},
|
||||
}],
|
||||
'guardrail_llm': _FailIfCalledLLM(),
|
||||
},
|
||||
)
|
||||
|
||||
assert decision.allowed is True
|
||||
assert decision.reason == 'handoff_humano_autorizado'
|
||||
assert decision.metadata['mechanism'] == 'deterministic_handoff_bypass'
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_tim_aoferta_does_not_trust_non_terminal_workflow_handoff_flag():
|
||||
llm = _BlockingLLM()
|
||||
decision = await TimProactiveOfferRail().evaluate(
|
||||
'Vou encaminhar seu atendimento para uma pessoa.',
|
||||
{
|
||||
'current_route': 'faturas_agent',
|
||||
'current_intent': 'contas_invoice_explanation',
|
||||
'mcp_results': [{
|
||||
'result': {
|
||||
'output': {
|
||||
'handoff': True,
|
||||
},
|
||||
},
|
||||
}],
|
||||
'guardrail_llm': llm,
|
||||
},
|
||||
)
|
||||
|
||||
assert llm.calls == 1
|
||||
assert decision.allowed is False
|
||||
|
||||
Reference in New Issue
Block a user