Ajustes conforme relatorio de testes 2026-08-27

This commit is contained in:
2026-08-29 09:53:32 -03:00
parent 0ecff719b7
commit 88e1f070d7
791 changed files with 27040 additions and 29038 deletions

View File

@@ -0,0 +1,41 @@
from types import SimpleNamespace
from app.workflows.agent_graph import AgentWorkflow
def decision(code, allowed=False, reason=""):
return SimpleNamespace(code=code, allowed=allowed, reason=reason)
def test_coer_block_is_clarification_not_fake_security_message():
msg = AgentWorkflow._input_guardrail_user_message(
[decision("COER", reason="fala incompreensível ou negação ambígua na transcrição")],
{},
"está cobrando um",
)
assert "incompleta ou ambígua" in msg
assert "regra de segurança" not in msg.lower()
assert "COER" not in msg
def test_other_input_block_has_safe_non_internal_fallback():
msg = AgentWorkflow._input_guardrail_user_message(
[decision("UNKNOWN_RAIL", reason="internal implementation detail")],
{},
"texto",
)
assert "reformular" in msg.lower()
assert "internal implementation detail" not in msg
def test_blocked_input_is_routed_through_output_guardrails():
src = open("app/workflows/agent_graph.py", encoding="utf-8").read()
assert '{"blocked": "output_guardrails", "continue": "load_long_term_memory"}' in src
assert '{"blocked": "persist", "continue": "judge"}' in src
def test_blocked_input_clears_stale_tool_state():
src = open("app/workflows/agent_graph.py", encoding="utf-8").read()
assert '"mcp_tools": []' in src
assert '"mcp_results": []' in src
assert '"intent": "input_guardrail_blocked"' in src