Files
PTSRaiAgent/tests/test_dialog_idle_agent.py
ElebobaandClaude Opus 5.5 31585c7f35
CI / ruff · pytest (pull_request) Successful in 2m41s
feat(bot): every free-text message gets the agent's answer; every demo entry is a private copy
- Idle chat: all messages go to the agent (greetings, side-effect and substitute questions included); check-in
  signals are still recorded silently, quit intent keeps its rule reaction. Seen live: «какие будут побочки»
  was logged as a complaint («Спасибо, отметил»), «привет» got a canned phrase.
- Agent prompt: warm short replies to small talk; substitutes → only the doctor changes the drug.
- ЕМИАС demo persona button creates a private copy too (starting from consent + questionnaires, subject to
  the screening switch); the web app drops a stored session of the old shared demo account.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 22:27:26 +03:00

25 lines
1.1 KiB
Python

"""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)