refactor(agent): tighten comments, extract constant, strengthen edge case test

- Extract synthetic user message string to module-level constant
- Tighten comments in _snip_history recovery branch
- Strengthen no-user edge case test to verify safety net interaction
This commit is contained in:
chengyongru
2026-04-17 16:20:53 +08:00
committed by Xubin Ren
parent 44b526c4ee
commit 8c0c4e5b31
4 changed files with 20 additions and 7 deletions
@@ -1,6 +1,6 @@
"""Tests for LLMProvider._enforce_role_alternation."""
from nanobot.providers.base import LLMProvider
from nanobot.providers.base import LLMProvider, _SYNTHETIC_USER_CONTENT
class TestEnforceRoleAlternation:
@@ -208,7 +208,7 @@ class TestEnforceRoleAlternation:
result = LLMProvider._enforce_role_alternation(msgs)
non_system = [m for m in result if m["role"] != "system"]
assert non_system[0]["role"] == "user"
assert non_system[0]["content"] == "(conversation continued)"
assert non_system[0]["content"] == _SYNTHETIC_USER_CONTENT
# The original assistant should follow.
assert non_system[1]["role"] == "assistant"