mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-04-11 05:33:36 +00:00
Some LLM providers (OpenAI-compat, Azure, vLLM, Ollama) reject requests with consecutive same-role messages or trailing assistant messages. Add _enforce_role_alternation() to merge consecutive same-role user/assistant messages and strip trailing assistant messages before sending to the API.