from app.agent import AgentResult from app.commands.ai import agent_reply def test_agent_reply_escapes_html(): result = AgentResult("CPU & RAM ", ()) reply = agent_reply(result) assert reply.text == "CPU & RAM " assert reply.html == "CPU & RAM <hoch>" def test_agent_reply_escaped_length_stays_within_limit(): result = AgentResult("&" * 3000, ()) reply = agent_reply(result) assert len(reply.html) <= 3000 assert reply.html == "&" * (len(reply.html) // 5) def test_agent_reply_plain_text_truncated_to_answer_max(): result = AgentResult("x" * 4000, ()) reply = agent_reply(result) assert len(reply.text) == 3000