from agr_assistent.core.assistant import build_messages def _history(count: int) -> list[dict[str, str]]: return [{"role": "user", "content": str(i)} for i in range(count)] def test_build_messages_adds_system_prompt_and_trims_history() -> None: messages = build_messages(" be nice ", _history(5), max_history_messages=2) assert messages == [ {"role": "system", "content": "be nice"}, {"role": "user", "content": "3"}, {"role": "user", "content": "4"}, ] def test_build_messages_without_limit_or_prompt() -> None: assert build_messages("", _history(3), max_history_messages=0) == _history(3)