"""In idle every message goes to the chat agent (when it is on); quit intent keeps the rule reaction.""" from app.llm import agent from app.llm.agent import AgentAnswer from tests.test_dialog_knowledge import TOKEN, engine, joined, say # noqa: F401 async def test_idle_text_goes_to_agent(engine, monkeypatch): # noqa: F811 seen = [] async def fake(token, text, **kw): seen.append(str(text)) return AgentAnswer(text="ОТВЕТ АГЕНТА", sources=[], tools=["search_guidelines"], provider="fake") monkeypatch.setattr(agent, "answer_chat", fake) for msg in ("прив", "какие у меня будут ощущения и побочки от лекарств", "а какие аналоги моего лекарства есть"): replies = await say(engine, msg) assert "ОТВЕТ АГЕНТА" in joined(replies), msg assert len(seen) == 3 and all(t == TOKEN for t in [TOKEN]) async def test_idle_falls_back_when_agent_off(engine): # noqa: F811 replies = await say(engine, "прив") assert replies and "ОТВЕТ АГЕНТА" not in joined(replies)